Created
February 21, 2022 13:58
-
-
Save MJacobs1985/988bf2810bc541f477967bdc9a3bb1d4 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
| soliq_arimax = auto.arima(dfy[,"Eggs"], # specify main trend | |
| xreg = dfexo[,c("TempMIN", | |
| "TempMAX", | |
| "TempACT", | |
| "AnimalACT")], # specify exogenous variables here | |
| trace = TRUE, | |
| seasonal= FALSE, | |
| stepwise=FALSE, | |
| approximation=FALSE) | |
| summary(soliq_arimax);autoplot(soliq_arimax);checkresiduals(soliq_arimax)+theme_bw() | |
| tsdat<-ts.union(Eggs=dfy[,"Eggs"], | |
| TempMIN=dfexo[,"TempMIN"], | |
| TempMAX=dfexo[,"TempMAX"], | |
| TempACT=dfexo[,"TempACT"], | |
| AnimalACT=dfexo[,"AnimalACT"]) | |
| tsdat_train <- window(tsdat, end=2021.4) | |
| tsdat_test <- window(tsdat, start=2021.41) | |
| soliq_arimax = auto.arima(tsdat_train[,"Eggs"], | |
| xreg = tsdat_train[,c("TempMIN", | |
| "TempMAX", | |
| "TempACT", | |
| "AnimalACT")], | |
| seasonal= FALSE, | |
| stepwise=FALSE, | |
| approximation=FALSE, | |
| allowdrift = TRUE, | |
| allowmean = TRUE, | |
| parallel=TRUE, | |
| num.cores=8) | |
| ggfortify::ggtsdiag(soliq_arimax , gof.lag = 14)+theme_bw() | |
| myforecasts <- forecast::forecast(soliq_arimax , | |
| xreg=tsdat_test[,c("TempMIN", | |
| "TempMAX", | |
| "TempACT", | |
| "AnimalACT")], | |
| bootstrap=TRUE, | |
| npaths=1000, | |
| h=100) | |
| autoplot(myforecasts) + | |
| autolayer(tsdat[,"Eggs"]) + | |
| theme_bw() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment