Created
March 27, 2023 21:47
-
-
Save robjhyndman/a11eba538d26ba60454abd600ea6204d to your computer and use it in GitHub Desktop.
Using stretch_tsibble with covariates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(fpp3) | |
# Stretched data | |
stretch_uschange <- us_change |> | |
stretch_tsibble(.init = 5) | |
# Fit models to all folds of data | |
fit <- stretch_uschange |> | |
model(lm = TSLM(Consumption ~ Income)) | |
# Set up covariates for 4 steps ahead | |
future_covariates <- stretch_uschange |> | |
new_data(n = 4) |> | |
left_join(us_change, by = "Quarter") | |
# Forecast 4 steps ahead | |
fc <- fit |> | |
forecast(new_data = future_covariates) | |
# Check accuracy of forecasts | |
accuracy(fc, us_change) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment