Applies a fitted model to a new dataset. For most methods this can be done with or without re-estimation of the parameters.

# S3 method for class 'mdl_df'
refit(object, new_data, ...)

# S3 method for class 'mdl_ts'
refit(object, new_data, ...)

Arguments

object

A mable.

new_data

A tsibble dataset used to refit the model.

...

Additional optional arguments for refit methods.

Examples

library(fable)

fit <- as_tsibble(mdeaths) %>% 
  model(ETS(value ~ error("M") + trend("A") + season("A")))
fit %>% report()
#> Series: value 
#> Model: ETS(M,A,A) 
#>   Smoothing parameters:
#>     alpha = 0.0002065548 
#>     beta  = 0.0001865257 
#>     gamma = 0.000118306 
#> 
#>   Initial states:
#>      l[0]      b[0]     s[0]     s[-1]     s[-2]     s[-3]     s[-4]     s[-5]
#>  1671.676 -4.334248 373.1746 -121.3157 -246.1697 -484.8581 -476.2192 -370.1939
#>      s[-6]    s[-7]    s[-8]    s[-9]   s[-10]   s[-11]
#>  -303.5806 -207.384 122.0022 483.3319 620.3601 610.8525
#> 
#>   sigma^2:  0.009
#> 
#>      AIC     AICc      BIC 
#> 1033.474 1044.807 1072.177 

fit %>% 
  refit(as_tsibble(fdeaths)) %>% 
  report(reinitialise = TRUE)
#> Series: value 
#> Model: ETS(M,A,A) 
#>   Smoothing parameters:
#>     alpha = 0.0002065548 
#>     beta  = 0.0001865257 
#>     gamma = 0.000118306 
#> 
#>   Initial states:
#>      l[0]       b[0]     s[0]   s[-1]     s[-2]    s[-3]     s[-4]     s[-5]
#>  586.8764 -0.7008449 129.4235 -60.401 -108.8126 -185.465 -189.2346 -149.2135
#>      s[-6]     s[-7]    s[-8]    s[-9]   s[-10]   s[-11]
#>  -134.8698 -70.64105 45.28081 204.0216 279.4489 240.4628
#> 
#>   sigma^2:  0.0118
#> 
#>      AIC     AICc      BIC 
#> 903.5169 910.8854 935.3903