Skip to content

Instantly share code, notes, and snippets.

@MJacobs1985
Created February 21, 2022 13:54
Show Gist options
  • Select an option

  • Save MJacobs1985/6722cdf62c9394cd38e6f50a42935ae1 to your computer and use it in GitHub Desktop.

Select an option

Save MJacobs1985/6722cdf62c9394cd38e6f50a42935ae1 to your computer and use it in GitHub Desktop.
Eggsdf<-as.data.frame(Eggs)
far1 <- function(x, h){forecast(Arima(x, order=c(1,0,0), seasonal=FALSE), h=h)}
e <- tsCV(Eggsdf$egg_count, far1, h=1)
fc <- c(NA, Eggsdf$egg_count[2:149] - e[1:148])
train <-window(Eggs, end=2021.310)
autoplot(train)+theme_bw()
test <-window(Eggs, start=2021.311)
m1 <- auto.arima(train,
ic="aic",
seasonal=FALSE,
stationary=TRUE,
stepwise=FALSE,
approximation=FALSE)
plot(m1)
summary(m1)
plot(forecast(m1, h=43))
ggtsdiag(m1, gof.lag = 14)+theme_bw()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment