3
$\begingroup$

Cross-posting this from Stack Overflow, because it's a bit of a stats/ technology cross-over.

I'm relatively new to R and the forecast package I believe authored by Rob Hyndman.

I'm having trouble understanding how the objects (time series, model, forecast) exactly relate to each other, but more importantly, the proper arguments for the forecast() function.

Say I have a time-series object called Sales.ts

Now, I wanted to verify that I understood the forecast() function -- which can accept both raw time series, or models based on time series, or both, as inputs.

First, I did Sales.ets<-ets(Sales.ts). Here the ets() function chose a best-fit ets model that estimates the Sales.ts time series, now called Sales.ets.

Now I do forecast(Sales.ets,h=12) to predict the next 12 values in the future, based on the ets model.

I can also do forecast(Sales.ts,model=Sales.ets,h=12). I wanted to check that if it forecasted the Sales.ts time series using the same ets model, it should produce the same results as the first method. MAINLY, because I want to validate partitions of the data using the Sales.ets model.

HOWEVER, here's the problem:

forecast(Sales.ets, h=12) and forecast(Sales.ts, model=Sales.ets,h=12) produce slightly, but signficantly enough, different forecasts. My question is --- why? Why does it do this?

My follow up question would be how to validate the Sales.ets model. I was going to try to validate it by doing (Sales.ts(1:k),model=Sales.ets,h=1) to check the accuracy of 1-step forecasts at each point in history in the past. Any help appreciated - thanks!

$\endgroup$

1 Answer 1

6
$\begingroup$

Only the smoothing parameters are held fixed, the initial states are re-estimated. See the help file:

model It is also possible for the model to be of class "ets", and equal to the output from a previous call to ets. In this case, the same model is fitted to y without re-estimating any smoothing parameters. See also the use.initial.values argument.

use.initial.values If TRUE and model is of class "ets", then the initial values in the model are also not re-estimated.

On the same data set, you might expect the results to be identical, but the likelihood is bumpy and can converge to slightly different answers when re-estimated.

Compare these:

> data.ts <- USAccDeaths

> (data.ets <- ets(data.ts))
ETS(M,N,M) 

  Smoothing parameters:
    alpha = 0.4989 
    gamma = 1e-04 

  Initial states:
    l = 9839.3709 
    s=0.9995 0.9689 1.0272 0.9919 1.1112 1.1906
           1.0892 1.0371 0.9394 0.9123 0.8234 0.9091

  sigma:  0.029

   AIC   AICc    BIC 
1133.5 1140.9 1165.4 

Re-estimate initial-states but not smoothing parameters:

> ets(data.ts, model=data.ets)
ETS(M,N,M) 

  Smoothing parameters:
    alpha = 0.4989 
    gamma = 1e-04 

  Initial states:
    l = 9838.524 
    s=0.9987 0.967 1.0255 0.9916 1.1111 1.1905
           1.0899 1.0369 0.9387 0.9136 0.826 0.9106

  sigma:  0.029

   AIC   AICc    BIC 
1129.4 1134.7 1156.7 

Don't re-estimate anything:

> ets(data.ts, model=data.ets, use.initial = TRUE)
ETS(M,N,M) 

  Smoothing parameters:
    alpha = 0.4989 
    gamma = 1e-04 

  Initial states:
    l = 9839.3709 
    s=0.9995 0.9689 1.0272 0.9919 1.1112 1.1906
           1.0892 1.0371 0.9394 0.9123 0.8234 0.9091

  sigma:  0.029

   AIC   AICc    BIC 
1133.5 1140.9 1165.4 
$\endgroup$
1
  • 1
    $\begingroup$ That definitely makes sense and will help me with cross-validation. The forecast package already seems lightyears ahead of my holt-winters model in Excel. Thanks! $\endgroup$ Commented Nov 21, 2014 at 17:38

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.