Produces forecasts using the Naive2 benchmark from the M4 forecasting
competition. The function first applies test_seasonality() at the
specified frequency. If seasonality is not detected, the final observation
is repeated for the complete forecast horizon.
If seasonality is detected, the series is adjusted using classical multiplicative decomposition. A naive forecast is then produced from the seasonally adjusted series and reseasonalized using the estimated seasonal factors.
Examples
x <- as.numeric(AirPassengers)
forecast_naive2(
x = x,
freq = 12,
n_ahead = 18
)
#> [1] 437.4820 424.6949 484.1683 469.0476 471.6776 534.8310 589.5167 586.3231
#> [9] 509.7019 443.0222 385.0685 432.0000 437.4820 424.6949 484.1683 469.0476
#> [17] 471.6776 534.8310
