tidyverts / fable

Tidy time series forecasting
https://fable.tidyverts.org
GNU General Public License v3.0
558 stars 65 forks source link

no applicable method for 'report' applied to an object of class "refit" #340

Closed prasenjitdatta closed 3 years ago

prasenjitdatta commented 3 years ago

I am trying to refit my ETS model on the test data but I am getting this warning and error-

lung_deaths_male <- as_tsibble(mdeaths) lung_deaths_female <- as_tsibble(fdeaths)

fit <- lung_deaths_male %>% model(ETS(value))

report(fit)

fit %>% refit(lung_deaths_female, reinitialise = TRUE) %>% report()

Error in UseMethod("report") : no applicable method for 'report' applied to an object of class "refit" In addition: Warning messages: 1: The method is not implemented for the object of the class mdl_df 2: Unknown or uninitialised column: states.

How do I fix that?

Thanks

mitchelloharawild commented 3 years ago

I am unable to reproduce this error. My best guess here is that you have loaded some other package that defines the refit() function. Try using fabletools::refit().

library(fable)
#> Loading required package: fabletools

lung_deaths_male <- as_tsibble(mdeaths)
lung_deaths_female <- as_tsibble(fdeaths)

fit <- lung_deaths_male %>%
  model(ETS(value))

report(fit)
#> 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(lung_deaths_female, reinitialise = TRUE) %>%
  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]
#>  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

Created on 2021-08-26 by the reprex package (v2.0.0)