Holts Method error message

I plotted the Holts forecast useing the code below:
ts_p2 <- ts(datap2, frequency = 12, end = c(2019,11))

fit22 <- holt(ts_p2, h = 12)
frc22 <- forecast(fit22, h = 12)
plot(fit22)
legend("topleft",
c("Holt's method"),
col=c("blue"),
lty=1,)

Then I tried to calculate the Mean Error and Mean Absolute Error:
ME22 <- mean(p2.tst - frc22$mean)
round(ME22,3)
MAE22 <- mean(abs(p2.tst - frc22$mean))
round(ME22,3)

After I run the code I get this message:
Warning message:
In .cbind.ts(list(e1, e2), c(deparse(substitute(e1))[1L], deparse(substitute(e2))[1L]), :
non-intersecting series

Any ideas?

Is p2.tst is a separate time series with data for December 2019 to November 2020? If not, you cannot calculate forecast errors without data on the forecast time period.

If you want ME and MAE, just use the accuracy() function, as shown in my reprex. It has accuracy measures for both the residuals from fitting the model (training set) and the forecast errors (test set)

I think you would greatly benefit by looking at Forecasting Principles and Practice, 2nd edition. It is free at Forecasting: Principles and Practice (2nd ed) . Exponential smoothing is covered in Chapter 7. One of the authors, Rob Hyndman, is the creator of the {forecast} package. He also created a set of new packages, known as the tidyverts, that is the software used in the 3rd edition of the book.

library(forecast)
#> Registered S3 method overwritten by 'quantmod':
#>   method            from
#>   as.zoo.data.frame zoo

AirPass <- structure(c(112, 118, 132, 129, 121, 135, 148, 148, 136, 119, 
            104, 118, 115, 126, 141, 135, 125, 149, 170, 170, 158, 133, 114, 
            140, 145, 150, 178, 163, 172, 178, 199, 199, 184, 162, 146, 166, 
            171, 180, 193, 181, 183, 218, 230, 242, 209, 191, 172, 194, 196, 
            196, 236, 235, 229, 243, 264, 272, 237, 211, 180, 201, 204, 188, 
            235, 227, 234, 264, 302, 293, 259, 229, 203, 229, 242, 233, 267, 
            269, 270, 315, 364, 347, 312, 274, 237, 278, 284, 277, 317, 313, 
            318, 374, 413, 405, 355, 306, 271, 306, 315, 301, 356, 348, 355, 
            422, 465, 467, 404, 347, 305, 336, 340, 318, 362, 348, 363, 435, 
            491, 505, 404, 359, 310, 337, 360, 342, 406, 396, 420, 472, 548, 
            559, 463, 407, 362, 405, 417, 391, 419, 461, 472, 535, 622, 606, 
            508, 461, 390, 432), .Tsp = c(1949, 1960.91666666667, 12), class = "ts")

TrainData <- head(AirPass, 132)      # first 11 years = training set
TestData <- tail(AirPass, 12)        # last 12 months = test set

TrainFit <- holt(TrainData, h = 12)  # fit a model and forecast 12 months
accuracy(TrainFit, TestData)         # accuracy of fitted model and of forecast
#>                       ME     RMSE      MAE        MPE      MAPE     MASE
#> Training set  0.06902756 31.15172 23.82950 -0.5842125  8.965372 0.782578
#> Test set     57.60058186 93.30006 66.95594 10.1437728 12.540598 2.198882
#>                   ACF1 Theil's U
#> Training set 0.2860526        NA
#> Test set     0.6974771  1.621908

Created on 2022-01-20 by the reprex package (v2.0.1)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.