User-facing wrapper that runs the automatic seasonal analysis and writes a
human-readable HTML report with plots, tables, diagnostics, and
copy-pasteable seas() calls.
The report fits the same candidate grid as auto_seasonal_analysis() and
can therefore take noticeable time on broad grids. Use max_specs for quick
exploratory reports.
Usage
sa_report_html(
y,
current_model = NULL,
td_usertype = "td",
td_candidates = NULL,
use_fivebest = TRUE,
max_specs = NULL,
seasonal_only = TRUE,
title = "Seasonal Adjustment Report",
outfile = "sa_report.html",
file = NULL,
png_width = 1400,
png_height = 900,
print_to_console = FALSE,
print_which = c("new", "current", "both"),
include_easter = c("auto", "always", "off"),
easter_len = 15L,
engine = c("seats", "x11", "auto"),
w_engine = 1,
outlier_types = c("AO", "LS", "TC"),
outlier_method = "AddOne",
outlier_critical = 4,
outlier_alpha = NULL
)Arguments
- y
Time series to be analysed. Can be a
tsobject or anything thattsbox::ts_ts()can convert tots.- current_model
Optional incumbent
seasonal::seas()model to compare against the newly selected specification.- td_usertype
Character string passed as
regression.usertypewhen trading-day regressors are used (default"td").- td_candidates
Optional named list of trading-day candidate regressors (e.g.
list(wd = wd.m, wd1 = wd1.m)), each aligned withy.- use_fivebest
Logical. If
TRUE, include the "five best" automatic specs in the candidate grid.- max_specs
Optional positive integer limiting the number of candidate ARIMA specifications fitted.
- seasonal_only
Logical. If
TRUE(default), filter candidate ARIMA specifications to seasonal models before fitting.- title
Title of the report shown in the HTML page.
- outfile
Path to the HTML file to be written.
- file
Optional alias for
outfile, for compatibility with callers that use file-oriented naming.- png_width, png_height
Width and height (in pixels) of PNG plots embedded in the report.
- print_to_console
Logical. If
TRUE, do not create an HTML file but print the copy-pasteable model code to the console and return it.- print_which
Which code blocks to print when
print_to_console = TRUE. One of"new","current"or"both".- include_easter
Controls inclusion of Easter regressors:
"auto"(default) lets the selector decide,"always"always includes Easter,"off"never includes Easter. A logical value is also accepted and mapped to"auto"/"off".- easter_len
Integer, length (in days) of the Easter effect when included.
- engine
Preferred decomposition engine for candidate models. One of
"seats","x11"or"auto".- w_engine
Numeric weight for the engine choice component in the composite ranking score.
- outlier_types
Character vector of outlier types to detect, typically a subset of
c("AO", "LS", "TC").- outlier_method
Character scalar giving the outlier detection method passed to
seasonal::seas()(e.g."AddOne").- outlier_critical
Numeric critical value for outlier detection (e.g. a t-/z-threshold).
- outlier_alpha
Optional numeric significance level; if supplied, it is converted to a two-sided normal cutoff for
outlier_critical.
Value
Invisibly, a list with elements report (path to the HTML file) and
res (the corresponding auto_seasonal_analysis() result).
Details
Notes:
If the provided current specification equals the selected best model, the report omits the "Alternative model" comparison section.
The "Top candidates" table starts with the best model and always includes the current model (flagged as current) when one is supplied.
Examples
# \donttest{
if (requireNamespace("seasonal", quietly = TRUE)) {
sa_report_html(
y = AirPassengers,
outfile = tempfile(fileext = ".html"),
max_specs = 3
)
}
#> 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)
#> seas(
#> x = 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"),
#> seats.noadmiss = "no",
#> transform.function = "log",
#> arima.model = "(1 1 1)(0 1 1)",
#> regression.variables = "easter[15]",
#> seats = "",
#> regression.aictest = NULL,
#> outlier = NULL
#> )
#> seas(
#> x = 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"),
#> seats.noadmiss = "no",
#> transform.function = "log",
#> arima.model = "(1 1 1)(0 1 1)",
#> regression.variables = "easter[15]",
#> seats = "",
#> regression.aictest = NULL,
#> outlier = NULL
#> )
#> Report written: /tmp/RtmpINKQrg/file1b33deea625.html
# }
