Applies a fitted TSLM
to a new dataset.
# S3 method for class 'TSLM'
refit(object, new_data, specials = NULL, reestimate = FALSE, ...)
A model for which forecasts are required.
A tsibble containing the time points and exogenous regressors to produce forecasts for.
(passed by fabletools::forecast.mdl_df()
).
If TRUE
, the coefficients for the fitted model will be re-estimated to suit the new data.
Other arguments passed to methods
lung_deaths_male <- as_tsibble(mdeaths)
lung_deaths_female <- as_tsibble(fdeaths)
fit <- lung_deaths_male %>%
model(TSLM(value ~ trend() + season()))
report(fit)
#> Series: value
#> Model: TSLM
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -422.6976 -58.6048 -0.1143 64.2905 644.0310
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 2257.1179 74.8463 30.157 < 2e-16 ***
#> trend() -4.1060 0.9662 -4.250 7.72e-05 ***
#> season()year2 -44.3940 97.0086 -0.458 0.64890
#> season()year3 -151.1214 97.0230 -1.558 0.12468
#> season()year4 -460.1821 97.0471 -4.742 1.38e-05 ***
#> season()year5 -799.2429 97.0807 -8.233 2.21e-11 ***
#> season()year6 -922.4702 97.1240 -9.498 1.71e-13 ***
#> season()year7 -968.5310 97.1768 -9.967 2.91e-14 ***
#> season()year8 -1063.4250 97.2393 -10.936 8.09e-16 ***
#> season()year9 -1075.3190 97.3112 -11.050 5.34e-16 ***
#> season()year10 -851.7131 97.3927 -8.745 3.04e-12 ***
#> season()year11 -711.1071 97.4838 -7.295 8.57e-10 ***
#> season()year12 -288.1679 97.5843 -2.953 0.00451 **
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Residual standard error: 168 on 59 degrees of freedom
#> Multiple R-squared: 0.875, Adjusted R-squared: 0.8495
#> F-statistic: 34.41 on 12 and 59 DF, p-value: < 2.22e-16
fit %>%
refit(lung_deaths_female) %>%
report()
#> Series: value
#> Model: TSLM
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -1515.5 -1123.7 -897.9 -748.7 -505.5
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 2257.118 475.866 4.743 1.38e-05 ***
#> trend() -4.106 6.143 -0.668 0.5065
#> season()year2 -44.394 616.772 -0.072 0.9429
#> season()year3 -151.121 616.864 -0.245 0.8073
#> season()year4 -460.182 617.017 -0.746 0.4587
#> season()year5 -799.243 617.231 -1.295 0.2004
#> season()year6 -922.470 617.506 -1.494 0.1405
#> season()year7 -968.531 617.842 -1.568 0.1223
#> season()year8 -1063.425 618.238 -1.720 0.0907 .
#> season()year9 -1075.319 618.696 -1.738 0.0874 .
#> season()year10 -851.713 619.214 -1.375 0.1742
#> season()year11 -711.107 619.793 -1.147 0.2559
#> season()year12 -288.168 620.432 -0.464 0.6440
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Residual standard error: 1068 on 59 degrees of freedom
#> Multiple R-squared: 0.1476, Adjusted R-squared: -0.0258
#> F-statistic: 0.8512 on 12 and 59 DF, p-value: 0.59898