zesla
zesla

Reputation: 11833

how to show predictions on test data from multiple models in time series forecasting

I split AirPassenger data into train and test, fit three different exponential smoothing models on train, and then made prediction on test. What I need is to plot predicted results from all models on test data, along with the original data. Could anyone help with plotting all of them together on one plot? Thanks a lot in advance.

train <- window(AirPassengers, end=1957)
test <- window(AirPassengers, start=1958)
fc1 <- ses(train, h=5)
fc2 <- holt(train, h=5)
fc3 <- hw(train, seasonal='additive')

autoplot(AirPassengers)+??????

Upvotes: 0

Views: 680

Answers (1)

G. Grothendieck
G. Grothendieck

Reputation: 270160

Try this:

AP <- cbind(AirPassengers, train, test, 
        as.ts(fc1)[, 1], as.ts(fc2)[, 1], as.ts(fc3)[, 1])
autoplot(AP)

screenshot

Upvotes: 1

Related Questions