I am trying to run ARIMA forecasting, yet I can only get the model to work on a sequenced time series and not in relation to dates or time. How do I get actual time (Years) on the x-axis?
I tried the following:
fish<- arima(log10(twentynine$E.coli),
order=c(6,0,0),
include.mean=F)
plot(log10(twentynine$E.coli), xlim=c(0,140), ylim=c(1,4), ylab="log(E.coli)", xlab="Time", main="Amazon Creek at 29th Avenue", type="o")
fish.pred<- predict(fish, n.ahead=60)
lines(fish.pred$pred, col="blue")
lines(fish.pred$pred+2*fish.pred$se,col="red")
lines(fish.pred$pred-2*fish.pred$se,col="red")
abline(h=log10(406), col="red", lwd=2)
That code works, but the results are in sequence by time. What I want is with years, like:
plot(log10(twentynine$E.coli)~twentynine$COLDATE)
I am using the lubridate
package to transform the "twentynine$COLDATE" from factor to date.
Once I get the plot set with xlim
extended 5 years for forecasting, the forecast lines from ARIMA will not show up.