title: Is there an easy way to revert a forecast back into a time series for plotting?
body: <p>I am new to R and have found this site extremely helpful, so this covers the second half of my question (one issue per post).  Thank you for your assistance ahead of time.</p>
  
  <p><strong>Background:</strong>  I was plotting historical data with multiple forecasts overlaid for visual accuracy checks.  This worked great when displayed on an x axis of 'observations'.  However, the data is more understandable when plotted with dates on the x axis, so I made it a time series using ts() and it plotted the time series data as expected.  However, (A) it did not plot the forecast data on the time scale because they are not a time series; and (B) I was unsure how to force the x axis to plus 1 year to permit the forecast to display.  </p>
  
  <p><strong>Question:</strong> (A) How do I restore the original time stamps to the forecast data?  I know that I could manually recreate the time series, but this would be required in every iteration of the forecast.  I have considered using forecast() instead of predict(), but the additional forecast iterations still have the same issue of not being a time series.  <strong>Is there a simple way to restore the original time stamp to the forecast data?</strong>  </p>
  
  <pre><code>  require(forecast)  [EDITED for clarity]
  
    data &lt;- rep(cos(1:52*(3.1416/26)),5)*100+1000
  
    arima.ts &lt;- ts(data,start=c(2009,1),frequency=52) #not plotted as time series
  
    # Create the current fit on data and predict one year out
    plot(arima.ts, type="l", xlab="weeks", ylab="counts",
    main="Overlay forecasts &amp; actuals",
         sub="green=FIT(1-105,by 16) wks back &amp; PREDICT(26) wks, blue=52 wks")
    ############## This plotted correctly as "Arima(data),..."
    arima.fit &lt;- auto.arima(tail(arima.ts,156)) 
    arima.pred &lt;- predict(arima.fit, n.ahead=52)
    lines(arima.pred$pred, col="blue")
    lines(arima.pred$pred+2*arima.pred$se, col="red")
    lines(arima.pred$pred-2*arima.pred$se, col="red")
  
    # Loop back and perform comparison plotting of forecast to actuals
    for (j in seq(1,105,by=16)) { 
      result &lt;- tryCatch({
        ############## This plotted correctly as "Arima(head(data,-j),..."
        arima1.fit &lt;- auto.arima(head(tail(arima.ts,-j),156))
        arima1.pred &lt;- predict(arima1.fit, n.ahead=52)
        lines(arima1.pred$pred, col="green", lty=(numtests %% 6) + 1 )
      }, error = function(e) {return(e$message)}) ## Trap errors
    }
  </code></pre>