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.ts <- ts(x, start=2001, frequency=12)


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

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
  • $\begingroup$ 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". $\endgroup$
    – Nick Cox
    Commented Oct 8, 2013 at 14:38
  • $\begingroup$ Corrected title. Cheers for the spot. $\endgroup$
    – digdeep
    Commented Oct 8, 2013 at 14:43

1 Answer 1


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.

  • $\begingroup$ 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")) $\endgroup$
    – digdeep
    Commented Oct 9, 2013 at 0:20
  • $\begingroup$ 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. $\endgroup$ Commented Oct 9, 2013 at 3:54
  • $\begingroup$ 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. $\endgroup$
    – digdeep
    Commented Oct 9, 2013 at 4:55
  • $\begingroup$ Use model="ZAN" for Holt and "ZAM" for Holt-Winters additive. The Z allows ets() to decide if you it is better to use an additive or multiplicative error. And use damped=FALSE if you don't want damping. $\endgroup$ Commented Oct 9, 2013 at 11:36
  • $\begingroup$ 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. $\endgroup$
    – digdeep
    Commented Oct 9, 2013 at 23:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.