Skip to contents

Hold-out validation forecast: fits SARIMA(p,d,q)(P,D,Q)_12 with stats::arima to the leading training months, forecasts the last h months, and reports MAPE / RMSE.

Usage

morie_tps_sarima_forecast(
  df,
  ds_name = "?",
  h = 12L,
  order = c(1L, 1L, 1L),
  seasonal = c(0L, 1L, 1L, 12L)
)

Arguments

df

A data.frame.

ds_name

Character label.

h

Hold-out horizon in months (default 12).

order

Non-seasonal ARIMA order c(p,d,q).

seasonal

Seasonal order c(P,D,Q,s); the 4th element is the seasonal period.

Value

A morie_rich_result list with aic, bic, mape_pct, rmse, forecast, actual.

Examples

set.seed(1)
df <- data.frame(OCC_YEAR = rep(2014:2023, each = 30),
                 OCC_MONTH = sample(month.name, 300, TRUE),
                 HOOD_158 = sample(sprintf("%03d", 1:20), 300, TRUE),
                 LAT_WGS84 = runif(300, 43.6, 43.8),
                 LONG_WGS84 = runif(300, -79.5, -79.2))
res <- try(morie_tps_sarima_forecast(df, ds_name = "synthetic", h = 4L))
if (!inherits(res, "try-error")) str(res, max.level = 1)
#> List of 5
#>  $ title         : chr "SARIMA -- synthetic"
#>  $ call          : chr "morie_tps_sarima_forecast(df=<300r>, h=4)"
#>  $ summary_lines : list()
#>  $ warnings      : chr "need >=36 timestamps, got 0"
#>  $ interpretation: chr "No analysis: at least 36 timestamps required."
#>  - attr(*, "class")= chr [1:3] "morie_tps_stochastic_result" "morie_rich_result" "list"