Skip to contents

Build a colour-coded HTML table of the highest-ranked candidate models, always placing the best model at the top and including the current model (if supplied) even if it is not in the top n. The airline reference model ARIMA (0 1 1)(0 1 1) is also appended if absent.

Usage

sa_top_candidates_table(res, current_model = NULL, y = NULL, n = 5)

Arguments

res

Result of auto_seasonal_analysis().

current_model

Optional fitted seasonal::seas model to mark as "current".

y

Optional original series (needed to compute a few current-model diagnostics).

n

Number of top rows to display (default 5). The airline/current rows may be appended even if not in the top n.

Value

An htmltools tag (<table>) you can insert into reports.

Details

Rows are lightly shaded: best (green), current (blue), airline (red).

Examples

# \donttest{
if (requireNamespace("seasonal", quietly = TRUE)) {
  current_model <- seasonal::seas(AirPassengers)
  res <- auto_seasonal_analysis(
    y = AirPassengers,
    current_model = current_model,
    max_specs = 3
  )
  sa_top_candidates_table(res, current_model = current_model, y = AirPassengers, n = 5)
}
#> 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)
#> <style>.tbl-note { color:#6b7280; margin-top:6px; }
#> .chip { padding:4px 10px; border-radius:999px; font-size:12px; border:1px solid #e5e7eb; }
#> .chip-best { background:#ecfdf5; color:#065f46; border-color:#a7f3d0; }
#> .chip-prev { background:#eff6ff; color:#1e40af; border-color:#bfdbfe; }
#> .tbl-colored .row-airline td { background:#fff1f2; }
#>      .chip-airline{ background:#fee2e2 !important; color:#991b1b !important; border:1px solid #fecaca !important; }
#>      .tbl-colored th, .tbl-colored td { vertical-align: middle; }
#>      .tbl-colored th:nth-child(2), .tbl-colored td:nth-child(2){ min-width:180px; max-width:320px; }
#>      .tbl-colored .model-spec { white-space:normal; overflow-wrap:anywhere; }</style>
#> <table class="tbl tbl-colored">
#>   <thead>
#>     <tr>
#>       <th>Label</th>
#>       <th>ARIMA</th>
#>       <th>Score (0-100)</th>
#>       <th>TD regressor</th>
#>       <th>AICc</th>
#>       <th>LB p</th>
#>       <th>QSori p</th>
#>       <th>QS X-11 p</th>
#>       <th>QS SEATS p</th>
#>       <th>QS min</th>
#>       <th>TD p</th>
#>       <th>Volatility red. %</th>
#>       <th>Seasonal amp %</th>
#>       <th>L1 vs prev SA</th>
#>       <th>Rev. MAE</th>
#>     </tr>
#>   </thead>
#>   <tbody>
#>     <tr class="row-best">
#>       <td>Spec_2</td>
#>       <td>
#>         <span class="model-spec">(1 1 1)(0 1 1)</span>
#>       </td>
#>       <td>100.0</td>
#>       <td>none</td>
#>       <td>987.38</td>
#>       <td>0.147</td>
#>       <td>&lt;0.001</td>
#>       <td>1.000</td>
#>       <td>1.000</td>
#>       <td>1.000</td>
#>       <td>—</td>
#>       <td>75.5</td>
#>       <td>0.18</td>
#>       <td>1.85</td>
#>       <td>0.665</td>
#>     </tr>
#>     <tr class="row-prev">
#>       <td>Spec_3</td>
#>       <td>
#>         <span class="model-spec">(0 1 1)(0 1 1)</span>
#>       </td>
#>       <td>99.2</td>
#>       <td>none</td>
#>       <td>986.18</td>
#>       <td>0.150</td>
#>       <td>&lt;0.001</td>
#>       <td>1.000</td>
#>       <td>1.000</td>
#>       <td>1.000</td>
#>       <td>—</td>
#>       <td>75.5</td>
#>       <td>0.18</td>
#>       <td>1.84</td>
#>       <td>0.672</td>
#>     </tr>
#>     <tr class="">
#>       <td>Spec_1</td>
#>       <td>
#>         <span class="model-spec">(0 1 0)(0 1 1)</span>
#>       </td>
#>       <td>0.0</td>
#>       <td>none</td>
#>       <td>999.92</td>
#>       <td>&lt;0.001</td>
#>       <td>&lt;0.001</td>
#>       <td>1.000</td>
#>       <td>1.000</td>
#>       <td>1.000</td>
#>       <td>—</td>
#>       <td>75.0</td>
#>       <td>0.18</td>
#>       <td>1.94</td>
#>       <td>0.678</td>
#>     </tr>
#>   </tbody>
#> </table>
#> <div class="legend">
#>   <span class="chip chip-best">best</span>
#>   <span class="chip chip-prev">current</span>
#>   <span class="chip chip-airline">Airline model</span>
#> </div>
#> <p class="tbl-note">Overall score is normalized to 0-100; higher is better. Showing top <b>3</b> of <b>3</b> ranked candidates; current and airline reference rows may be added when relevant.</p>
# }