Skip to contents

Applies a conservative switching gate to the first row of res$table. The best candidate must pass residual QS and Ljung-Box thresholds, must not be too far from the incumbent relative to the candidate set, and must retain sufficient seasonal-component correlation when that comparison is available. AICc, revision metrics and engine preference affect the ranking in auto_seasonal_analysis(), but are not directly re-applied by this switching helper.

Usage

sa_should_switch(
  res,
  thresholds = list(min_qs_p = 0.1, max_dist_sa_mult = 1.25, min_corr_seas = 0.9,
    min_lb_p = 0.05)
)

Arguments

res

Result of auto_seasonal_analysis().

thresholds

Named list with decision thresholds:

  • min_qs_p: minimum acceptable QS p-value on SA (overall) for the best model

  • max_dist_sa_mult: allow SA L1 distance up to this multiple of the cross-candidate median

  • min_corr_seas: minimum correlation of seasonal components (vs. incumbent)

  • min_lb_p: minimum acceptable Ljung-Box p-value on residuals

Value

One of "CHANGE_TO_NEW_MODEL" or "KEEP_CURRENT_MODEL".

Examples

# \donttest{
if (requireNamespace("seasonal", quietly = TRUE)) {
  res <- auto_seasonal_analysis(AirPassengers, max_specs = 3)
  sa_should_switch(res)
}
#> Model used in SEATS is different: (1 1 2)(1 0 0)
#> Model used in SEATS is different: (1 1 2)(1 0 0)
#> Model used in SEATS is different: (1 1 2)(1 0 0)
#> [1] "CHANGE_TO_NEW_MODEL"
# }