Search code examples
rcross-validationforecastingholtwinters

How to refit a Holt-Winters exponential smoothing model on test data without re-estimation of parameters


I try to generate multiple one-step forecasts by using the HoltWinters method for exponential smoothing. I, therefore, split my data into training and testing and fit a HoltWinters model on my training set. Now I want to produce multiple one-step forecasts for the length of my test data, in a way that the model is "updated" with every new observation of the test set, without re-estimation of the parameters. Kind of in a way rolling origin cross-validation would be done. I found the refit()-function, but that only seems to work with ARIMA models. Does someone know some code that could work? Or somewhere I could read about it?


Solution

  • The Holt-Winters method is a special case of an ETS model. So you can use the ETS function from the fable package like this:

    library(fable)
    library(dplyr)
    
    fit <- as_tsibble(USAccDeaths) %>%
      filter(lubridate::year(index) < 1977) %>%
      model(ets = ETS(value))
    
    fit %>%
      refit(as_tsibble(USAccDeaths)) %>%
      report()
    #> Series: value 
    #> Model: ETS(A,N,A) 
    #>   Smoothing parameters:
    #>     alpha = 0.6570182 
    #>     gamma = 0.004485907 
    #> 
    #>   Initial states:
    #>      l[0]      s[0]     s[-1]    s[-2]     s[-3]    s[-4]    s[-5]    s[-6]
    #>  9753.881 -30.20712 -286.0886 227.9668 -65.55104 977.0047 1673.521 806.8883
    #>     s[-7]     s[-8]     s[-9]    s[-10]   s[-11]
    #>  327.0867 -529.6172 -754.7921 -1551.379 -794.833
    #> 
    #>   sigma^2:  80017.07
    #> 
    #>      AIC     AICc      BIC 
    #> 1131.232 1137.507 1160.828
    

    Created on 2022-06-02 by the reprex package (v2.0.1)

    If you specifically wanted the Holt-Winters variant, you could use

    model(ets = ETS(value ~ trend("A") + season("M")))
    

    for a multiplicative Holt-Winters model or

    model(ets = ETS(value ~ trend("A") + season("A")))
    

    for an additive Holt-Winters model