Time Series Analysis and Exponential Smoothing

 Hello world! This week in advanced statistics we covered time series analysis and exponential smoothing. The problem for this week is as follows:

The table below represents charges for a student credit card.

a. Construct a time series plot using R.

b. Employ Exponential Smoothing Model as outlined in Avril Voghlan’s notes and report the statistical  outcome.

c. Provide a discussion on time series and Exponential Smoothing Model result you led to. 

Month20122013
Jan31.939.4
Feb2736.2
March31.340.5
Apr3144.6
May39.446.8
Jun40.744.7
Jul42.352.2
Aug49.554
Sep4548.8
Oct5055.8
Nov50.958.7
Dec58.563.4

Here’s the R data I used for the problem:

# Creating data frame for credit card
y_2012 <- as.data.frame(rbind(31.9, 27, 31.3, 31, 39.4, 40.7, 42.3, 49.5, 45, 50, 50.9, 58.5))
y_2013 <-as.data.frame(rbind(39.4, 36.2, 40.5,44.6,46.8, 44.7,52.2,54,48.8,55.8,58.7,63.4))
creditcard <- as.data.frame(cbind(y_2012, y_2013))
colnames(creditcard)<- c("2012", "2013")
rownames(creditcard) <- c("Jan", "Feb","March", "Apr", "May","Jun","Jul", "Aug","Sep", "Oct", "Nov", "Dec")

#Creates time series for credit card
creditcard_ts<- ts(creditcard, start = c(2012,1), end = c(2013, 12), frequency = 12)
creditcard_ts

#Plots credit card time series
plot.ts(creditcard_ts)

#Creates an exponential smoothing forecast
creditcardforecasts <- HoltWinters(creditcard_ts, beta = FALSE, gamma = FALSE)

#Plots Exponential smoothing forecast
creditcardforecasts$fitted
plot(creditcardforecasts) 

These graphs did not work the way I wanted them to. First of all, I fear I messed up while inputting the credit card data, leading to my plot displaying two graphs instead of one. I erroneously assumed that the time series data must be properly labeled in order to compute properly, but such was not the case. I re-entered my data as follows, which lead to my success: 

# Creating data frame for credit card
creditcard <- as.data.frame(rbind(31.9, 27, 31.3, 31, 39.4, 40.7, 42.3, 49.5, 45, 50, 50.9, 58.5, 39.4, 36.2, 40.5,44.6,46.8, 44.7,52.2,54,48.8,55.8,58.7,63.4))
#creditcard <- as.data.frame(cbind(y_2012, y_2013))
#colnames(creditcard)<- c("2012", "2013")
#rownames(creditcard) <- c("Jan", "Feb","March", "Apr", "May","Jun","Jul", "Aug","Sep", "Oct", "Nov", "Dec")

#Creates time series for credit card
creditcard_ts<- ts(creditcard, start = c(2012,1), end = c(2013, 12), frequency = 12)
creditcard_ts

#Plots credit card time series
plot.ts(creditcard_ts)

#Creates an exponential smoothing forecast
creditcardforecasts <- HoltWinters(creditcard_ts, beta = FALSE, gamma = FALSE)

#Plots Exponential smoothing forecast
creditcardforecasts$fitted
plot(creditcardforecasts)

My next issue came while formatting the exponential smoothing. Here are my time series and exponential smoothing graphs, respectively:

Time Series Graph
Exponential Smoothing Graph

In the time series and exponential smoothing graphs, we can observe high points at the end of 2012 and 2013. Since this occurs around the holidays, we can assume the student is spending more around this time on gifts. As we begin 2012 and 2013, we notice steep drops in the student’s card usage. The student is likely beginning to financially recover from the holidays at this time. As the year goes on, the student becomes more comfortable spending before it culminates in December. That’s all for this week!

Leave a comment