[R] Updating a Time Series After Forecast()

Lorenzo Isella lorenzo.isella at gmail.com
Thu Jan 14 22:36:00 CET 2016


Dear All,
Perhaps I am drowning in a cup of water, since I am positive that the
answer will be a one-liner.
Consider the following short script


########################################################
library(forecast)

ts2<-structure(c(339130, 356462, 363234, 378179, 367864, 378337, 392157,
402153, 376361, 392204, 403483, 414034, 391967, 406067, 419464,
434913, 410102, 424795, 437073, 448827, 415569, 430561, 444719,
455764, 419892, 444190, 454648, 466312, 439922, 448963, 465153,
475621, 445502, 457198, 473573, 485764, 463895, 470274, 484390,
490678, 478003, 483570, 499141, 509216, 481395, 492345, 511184,
513420, 483757, 490884, 514966, 515457, 497614, 510139, 523467,
526406, 499784, 519033, 532009, 531260, 521539, 532590, 553118,
557725, 548321, 556832, 578087, 578120, 566116, 580571, 587993,
569985, 534326, 539641, 564824, 568445, 558614, 570192, 594584,
598305, 593769, 598278, 620147, 615884, 611033, 609304, 630458,
624325, 614356, 627192, 649324, 645988, 642965, 645125, 669471,
665529, 664248, 669670, 694719), na.action = structure(1:64, class =
"omit"), .Tsp = c(1991,
2015.5, 4), class = "ts")

fit2 <- auto.arima(ts2, approximation=FALSE,trace=FALSE)

pred2 <- forecast(fit2, h=2)

#######################################################

So, I have an original quarterly time series ts2 and a forecast for 2
quarters pred2.

I would like to combine ts2 and pred2 (just the prediction) into a new
time series (in other words, just stretch a bit ts2).
How can I do that?
Many thanks

Lorenzo



More information about the R-help mailing list