1

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.

neontapir
  • 4,698
  • 3
  • 37
  • 52
Stosh
  • 11
  • 3
  • Can you provide a bit more information, some example data and images of what you're current plots look like? Correct me if I'm wrong but you're problem is with your plot labels and not with you're ARIMA results? – admccurdy Feb 24 '16 at 14:29
  • yes. I can get the plot to graph the axis in sequential time, but when I transfer the axis to actual time (dates/years) it will not plot the appropriate lines – Stosh Feb 24 '16 at 17:20
  • Do you have additional code that you're using when you try to extend your forecast? If you just use lines with one vector of predictions they have no dates associated with them so they won't get plotted on an x-axis with a factor scale. See this post for how to post a reproducible example: http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example It will improve the number of people who are willing to help you and the quality of help people are able to give. – admccurdy Feb 24 '16 at 18:51
  • my data that i am forecasting is (twentynine$E.coli) and the dates from that data are (twentynine$COLDATE)......I know how to get the arima model to produce a graph with sequential data plotting, but I want the graph to show the forecast over time, so that I can show what it will be in 2020. I can not find the code to plot the forecasting data of arima onto a plot of plot(twentynine$E.coli~twentynine$COLDATE – Stosh Feb 24 '16 at 19:10
  • Minor grammar updates. It would help if you could show the actual output, and perhaps use an image editor or a similar image of a graphic to show the expected output. – neontapir Feb 25 '16 at 21:19

0 Answers0