Holt's Linear and Holt-Winters in R

With the below code, I have run Holt's linear and Holt-Winters forecasts using Excel / Solver. I wanted to replicate this using R (Excel can be a pain) but I am getting the below error with hw().

It is my first time running this with R so I am trying to go by the docs. I assume running the function will pick the initialization and also optimize the parameters? Or am I way off?

Either way, I thought hw() would work, but clearly I am doing something wrong here.

   x<-c(12638.8,11583.3,13024.1,12594.2,13068.1,12765.4,13125.6,13316.3,13054.7,13879.3,14436.6,17861,13923.8,12418.4,13854.4,13558.8,14335,13639.9,14132.2,14457.2,14045.4,14941.2,15556,18984.2,14825.5,13138.3,14473.6,14507.6,15055.9,14384.2,15199.7,15169.7,15223.5,16412.9,16662.9,20638.9,16154.8,14696,15793.8,15804.2,15895,15868.6,16435.6,15945.9,16381.4,17084.2,17261,21652.6,16330.6,14840.5,16419.8,16104.2,16326.2,16453.4,16750.3,16678,16816.4,17431.7,17920.6,22491.3,17016.6,15534.8,17339.2,17065.6,17313.3,17448.2,17617.5,17814.2,17747.6,18592.4,19223.3,23636.1)
x.ts <- ts(x, start=2001, frequency=12)

plot(x.ts)

####Holt's Linear
holt(x, h=12, damped=FALSE, level=c(80,95), fan=FALSE,
initial=c("optimal"), exponential=FALSE,
alpha=NULL, beta=NULL)

#Holt-Winters
hw(x, h=2*frequency(x), seasonal="multiplicative", damped=FALSE,
level=c(80,95), fan=FALSE, initial=c("optimal"),
exponential=TRUE, alpha=NULL, beta=NULL, gamma=NULL)

# hw gives the following error
#Error in ets(x, "AAA", alpha = alpha, beta = beta, gamma = gamma, damped = damped,  : Nonseasonal data

• Some confusion here. Holt was the supervisor and Winters was his student and co-author. Their methods are thus often known as Holt-Winters. Nothing to do with the season "winter". Commented Oct 8, 2013 at 14:38
• Corrected title. Cheers for the spot. Commented Oct 8, 2013 at 14:43

The error tells you the problem. You have passed non-seasonal data to hw(). Note that you have passed x rather than x.ts to both functions.
• Wow that was a comical error. (late night coding) Thanks for the response. Looking at the HoltWinters() function this morning, is this the preferred method? If my dataset is a seasonal Multiplicative data set, is this the only thing that needs to be coded using R that will estimate and optimise the parameters, (m <- HoltWinters(AirPassengers, seasonal = "mult")) Commented Oct 9, 2013 at 0:20
• You are better off using ets() from the forecast package. It includes Holt-Winters as a special case, but provides a much richer class of models and selects the best one for you. Commented Oct 9, 2013 at 3:54
• Thanks for the tip. Using ets() I would specify ets(x.ts, model="MAN" with the opt.crit=c("mse") for Holt's Linear and for Holt-Winters' model="MAM" I want to be able to demonstrate the differences between these 2 models rather than let the algorithm decide which model best suits. Commented Oct 9, 2013 at 4:55
• Great! tks. Does the algorithm iterate through the parameters? I left alpha=NULL, beta=NULL and I used opt.crit=c("mse") However, the number produced for the ZAN model is 2490139. I tested for arbitrary parameter of 0.5 for both alpha and beta and the number is even bigger. Is the 2490139 an acceptable value for MSE? seems rather large.. Or is this because the data set I am using is multiplicative (tested using model="ZZZ") & using a model that does not factor seasonal will produce this large number? Where as model="ZAM" does a much better job because it factors seasonal with HW model. Commented Oct 9, 2013 at 23:31