[R] How to concatenate time series?

Gabor Grothendieck ggrothendieck at myway.com
Wed Mar 16 12:23:30 CET 2005


Robert Pollak <robert.pollak <at> scietec.at> writes:

: 
: Hello,
: 
: I have just completed first experiments in using R, especially creating and 
: using ARIMA models, e.g.
: 
: # create a model as in example(arima)
: fit <- arima(USAccDeaths, order = c(1,1,1),seasonal = list(order=c(1,1,1)))
: 
: # use the model to generate a prediction
: dp<-predict(fit, n.ahead = 24)
: 
: plot(dp$pred) # view the prediction
: 
: Now I created a combined chart of the original and predicted values. I tried 
it 
: like this:
: 
: dvs <- c(as.vector(USAccDeaths),as.vector(dp$pred))
: plot(dvs, type="l")
: 
: Here, of course, the x axis does not display time values any more. So I 
manually 
: recontructed a time series from the concatenated vector:
: 
: ds<-ts(dvs, 1973, 1980.91666666667, deltat = 1/12)
: 
: plot(ds) # this is the chart I wanted
: 
: Now my question is:
: Is there some way to directly concatenate the original and the predicted 
time 
: series? Searching the help files and this mailing list's archive gave me no 
hints.

ts.plot(USAccDeaths, dp$pred, col = 1:2)




More information about the R-help mailing list