Created
February 21, 2022 13:46
-
-
Save MJacobs1985/161e9c7f24c2a0bc5e5c5277b161cb59 to your computer and use it in GitHub Desktop.
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
| lagselect<-VARselect(dfy, | |
| lag.max = 14, | |
| type = "both", | |
| season = 7);lagselect$selection | |
| var.model_lev<-vars::VAR(dfy, | |
| p = 14, | |
| type = "both", | |
| season = 7, | |
| exogen=cbind(dfexo)) | |
| mod_vec <- VECM(dfy, lag=7) | |
| preds_roll <- predict_rolling(mod_vec, nroll=10) | |
| ## plot the results: | |
| plot(window(dfy[,"Eggs"],start=2021.021903), type="l", ylab="Eggs") | |
| preds_roll_ts <- ts(preds_roll$pred, start=time(dfy)[nrow(dfy)-10], freq=365.25) | |
| lines(preds_roll_ts[,"Eggs"], col=2, lty=2) | |
| legend("bottomright", lty=c(1,2), col=1:2, leg=c("True", "Fitted")) | |
| title("Comparison of true and rolling 1-ahead forecasts\n") | |
| # } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment