| Title: | 'JDemetra+' Seasonal Adjustment Models for 'fable' |
|---|---|
| Description: | Provides an interface to JDemetra+ v3 seasonal adjustment algorithms (X-13ARIMA-SEATS and TRAMO-SEATS) for use with the 'fable' forecasting and decomposition framework. It enables seasonal adjustment on 'tsibble' objects using the standard 'model()' and 'components()' workflow. |
| Authors: | Alain Quartier-la-Tente [aut, cre, cph] (ORCID: <https://orcid.org/0000-0001-7890-3857>) |
| Maintainer: | Alain Quartier-la-Tente <[email protected]> |
| License: | EUPL |
| Version: | 0.1.0 |
| Built: | 2026-10-30 08:53:08 UTC |
| Source: | https://github.com/AQLT/fable.rjd3 |
Backcasts the raw series, i.e. predicts the periods preceding its start,
from the pre-adjustment model of a model fitted with X13(), TRAMOSEATS(),
REGARIMA() or TRAMO(). fabletools has no backcast generic, so this function
plays the role of forecast() for the past. The distribution
is built as for forecasts (log-normal for log-transformed series, normal
otherwise; see the Distribution section of forecast.jd3_model).
backcast(object, h, ...) ## S3 method for class 'jd3_model' backcast(object, h, ...) ## S3 method for class 'mdl_ts' backcast(object, h, ...) ## S3 method for class 'mdl_df' backcast(object, h, ...)backcast(object, h, ...) ## S3 method for class 'jd3_model' backcast(object, h, ...) ## S3 method for class 'mdl_ts' backcast(object, h, ...) ## S3 method for class 'mdl_df' backcast(object, h, ...)
object |
A fitted |
h |
Number of periods to backcast, immediately before the start of the series. |
... |
Other arguments passed by |
For a jd3_model or a mdl_ts, a tsibble with the h dates
preceding the series and a distribution column dist (see
distributional). For a mable, a tibble with the key columns, .model,
the dates and dist, one block per model. Use mean() or median() on
dist to get a point backcast; the median equals JDemetra+'s backcast.
forecast.jd3_model, jd3_indicator() for the raw indicators (y_b,
y_eb...).
y <- tsibble::as_tsibble(AirPassengers) mb <- model(y, x13 = X13(value)) bc <- backcast(mb, h = 12) bc # A single model bc1 <- backcast(mb$x13[[1]], h = 12) median(bc1$dist)y <- tsibble::as_tsibble(AirPassengers) mb <- model(y, x13 = X13(value)) bc <- backcast(mb, h = 12) bc # A single model bc1 <- backcast(mb$x13[[1]], h = 12) median(bc1$dist)
Writes a new workspace readable by the JDemetra+ graphical interface, with one
SA-item per model: raw series, estimation specification, reference
specification, and the modelling context (calendars and regressors). A workspace
has a single context: regressors of different models that share the same name
but have different values (e.g. xreg(col) in several series) are renamed
<name>_<sap>_<series>, in the context and in the specifications. Results, comments, priorities and links to data
providers are not exported; the series are stored as static data.
export_jws(mb, file, replace = FALSE, sap = "sap", series = "series")export_jws(mb, file, replace = FALSE, sap = "sap", series = "series")
mb |
A mable of models fitted with |
file |
Path of the workspace (xml master file) to create. |
replace |
Replace the workspace if |
sap, series
|
Names of the key columns giving the SA-processing and the SA-item. Without them, a single SA-processing is created and the SA-item names are built from the other keys. |
file, invisibly.
mb <- model(as_tsibble(AirPassengers), sa = X13(value)) export_jws(mb, tempfile(fileext = ".xml"))mb <- model(as_tsibble(AirPassengers), sa = X13(value)) export_jws(mb, tempfile(fileext = ".xml"))
Forecasts the raw series from the pre-adjustment model (RegARIMA / TRAMO)
of a model fitted with X13(), TRAMOSEATS(), REGARIMA() or TRAMO(). The values are read from
the stored JDemetra+ result, so the seasonal adjustment itself is not
affected. For the past, see backcast().
## S3 method for class 'jd3_model' forecast(object, new_data = NULL, ...)## S3 method for class 'jd3_model' forecast(object, new_data = NULL, ...)
object |
A fitted |
new_data |
A tsibble of future dates, built by fabletools from the
horizon |
... |
Other arguments passed by |
A distribution vector (see distributional) with one element per
row of new_data: log-normal if the series is log-transformed, normal
otherwise. Called through forecast() on a mable, the result is a fable.
For log-transformed series, the forecast distribution is log-normal, with a median equal to JDemetra+'s forecast (a plain back-transformation of the forecast of the log). Its mean is therefore the bias-corrected forecast, and the difference grows with the horizon. For other series, the distribution is normal and its mean equals the median.
The default point forecast .mean of the resulting fable is the mean of the
distribution. Use the point_forecast argument of forecast() to choose
another summary, e.g. point_forecast = list(.median = median) to obtain
JDemetra+'s forecast.
backcast(), X13(), TRAMOSEATS(), jd3_indicator() to
extract the raw indicators (y_f, y_ef...).
y <- tsibble::as_tsibble(AirPassengers) mb <- model(y, x13 = X13(value)) # The mean is the bias-corrected forecast forecast(mb, h = 12) # JDemetra+'s own forecast (median of the distribution) forecast(mb, h = 12, point_forecast = list(.median = median))y <- tsibble::as_tsibble(AirPassengers) mb <- model(y, x13 = X13(value)) # The mean is the bias-corrected forecast forecast(mb, h = 12) # JDemetra+'s own forecast (median of the distribution) forecast(mb, h = 12, point_forecast = list(.median = median))
Standard fabletools / generics verbs for models fitted with X13(),
TRAMOSEATS(), REGARIMA() and TRAMO(). They can be applied directly on a
mable. components() is only available for the seasonal adjustment models
(X13() and TRAMOSEATS()).
## S3 method for class 'jd3_model' glance(x, ids = NULL, ...) ## S3 method for class 'jd3_sa_model' components(object, ...) ## S3 method for class 'jd3_model' model_sum(x) ## S3 method for class 'jd3_model' tidy(x, ...) ## S3 method for class 'jd3_model' report( object, digits = max(3L, getOption("digits") - 3L), signif.stars = getOption("show.signif.stars"), thresholds_pval = getOption("fable.rjd3.thresholds_pval"), ... )## S3 method for class 'jd3_model' glance(x, ids = NULL, ...) ## S3 method for class 'jd3_sa_model' components(object, ...) ## S3 method for class 'jd3_model' model_sum(x) ## S3 method for class 'jd3_model' tidy(x, ...) ## S3 method for class 'jd3_model' report( object, digits = max(3L, getOption("digits") - 3L), signif.stars = getOption("show.signif.stars"), thresholds_pval = getOption("fable.rjd3.thresholds_pval"), ... )
ids |
For |
... |
Currently unused. |
object, x
|
A |
digits |
minimum number of significant digits to be used for most numbers. |
signif.stars |
logical; if |
thresholds_pval |
Threshold used to interpret p-values statistic test.
By default |
components(): a dable with the response and the columns trend,
seasonal, irregular and season_adjust.
glance(): a one-row tibble of diagnostics.
tidy(): a tibble with one row per coefficient (ARIMA parameters,
regression variables, outliers, calendar effects) and the columns term,
estimate, std.error, statistic and p.value. Coefficients fixed in
the specification are included, with missing standard errors and tests.
report(): invisibly, the model; prints the decomposition mode or the
transformation, the number of observations, the coefficients, the tests on
the residuals and, for seasonal adjustment models, the quality diagnostics
(M and Q statistics, residual seasonality tests on the adjusted series).
model_sum(): a short string describing the model.
mb <- model(tsibble::as_tsibble(AirPassengers), x13 = X13(value)) components(mb) glance(mb) tidy(mb) report(mb)mb <- model(tsibble::as_tsibble(AirPassengers), x13 = X13(value)) components(mb) glance(mb) tidy(mb) report(mb)
Reads all the SA-items of a workspace and fits them with X13() or
TRAMOSEATS() using the specifications stored in the workspace: the
estimation specification is the model specification, the reference
specification is kept for the refresh policies (see jd3_model_methods_extra).
import_jws(file, compute = TRUE)import_jws(file, compute = TRUE)
file |
Path to the master xml file of the workspace. |
compute |
Compute the workspace before reading it (required to access the SA-items). |
A mable with the key columns sap (SA-processing) and series
(SA-item), and a model column sa holding X13 and TRAMOSEATS models.
SA-items with another type of specification (e.g. RegARIMA only) are
skipped with a warning.
file <- system.file("workspaces", "workspace_test.xml", package = "rjd3workspace") mb <- import_jws(file) mbfile <- system.file("workspaces", "workspace_test.xml", package = "rjd3workspace") mb <- import_jws(file) mb
Wraps rjd3toolkit::dictionary() on the Java result of the model. The
returned ids can be passed to jd3_indicator().
jd3_dictionary(object, ...) ## S3 method for class 'jd3_model' jd3_dictionary(object, ...) ## S3 method for class 'mdl_ts' jd3_dictionary(object, ...) ## S3 method for class 'mdl_df' jd3_dictionary(object, ...)jd3_dictionary(object, ...) ## S3 method for class 'jd3_model' jd3_dictionary(object, ...) ## S3 method for class 'mdl_ts' jd3_dictionary(object, ...) ## S3 method for class 'mdl_df' jd3_dictionary(object, ...)
object |
A fitted mable ( |
... |
Currently unused. |
A data frame (class JD3_FULL_DICTIONARY) with one row per
indicator: its id (name), description and output type. For a mable, the
dictionary of the first model is returned.
mb <- model(tsibble::as_tsibble(AirPassengers), x13 = X13(value)) head(jd3_dictionary(mb))mb <- model(tsibble::as_tsibble(AirPassengers), x13 = X13(value)) head(jd3_dictionary(mb))
Wraps rjd3toolkit::result() on the Java result of the model. If the Java
pointer is no longer valid (e.g. after saveRDS()/readRDS()), the model is
transparently re-estimated (once per loaded object). The ids available are
listed by jd3_dictionary().
jd3_indicator(object, id, ...) ## S3 method for class 'jd3_model' jd3_indicator(object, id, drop = TRUE, ...) ## S3 method for class 'mdl_ts' jd3_indicator(object, id, drop = TRUE, ...) ## S3 method for class 'mdl_df' jd3_indicator(object, id, simplify = TRUE, drop = TRUE, ...)jd3_indicator(object, id, ...) ## S3 method for class 'jd3_model' jd3_indicator(object, id, drop = TRUE, ...) ## S3 method for class 'mdl_ts' jd3_indicator(object, id, drop = TRUE, ...) ## S3 method for class 'mdl_df' jd3_indicator(object, id, simplify = TRUE, drop = TRUE, ...)
object |
A fitted mable ( |
id |
Indicator id (see |
... |
Currently unused. |
drop |
If |
simplify |
For a mable only: simplify the result according to the type
of the indicator (see Value). |
For a mdl_ts or jd3_model, the indicator as returned by
rjd3toolkit::result(): a number, a string, a ts, a matrix, a
JD3_TEST...
For a mable, a tibble with the key columns, .model, id and:
numbers or strings: a column value;
ts series: one row per date, with columns index and value;
tests: columns statistic, p.value and distribution;
anything else (or simplify = FALSE): a list-column value with one
element per model.
With several ids (or drop = FALSE), a named list of such tibbles, one per id.
mb <- model(as_tsibble(AirPassengers), x13 = X13(value), ts = TRAMOSEATS(value)) jd3_indicator(mb, "likelihood.aic") # one number per model jd3_indicator(mb, "sa") # seasonally adjusted series, long format jd3_indicator(mb, "residuals.kurtosis") # test: statistic and p-value # The raw object of a single model jd3_indicator(mb$x13[[1]], "sa")mb <- model(as_tsibble(AirPassengers), x13 = X13(value), ts = TRAMOSEATS(value)) jd3_indicator(mb, "likelihood.aic") # one number per model jd3_indicator(mb, "sa") # seasonally adjusted series, long format jd3_indicator(mb, "residuals.kurtosis") # test: statistic and p-value # The raw object of a single model jd3_indicator(mb$x13[[1]], "sa")
Returns the jd3_model object stored in a fitted model. It is mostly useful
for programming; jd3_indicator() and jd3_dictionary() call it
internally.
jd3_model(x)jd3_model(x)
x |
A |
A jd3_model object: a list holding the data (a tsibble), the
series (ts), the final specification (spec), the reference
specification (ref_spec), the modelling context, the engine, the name of
the response and a cache for the Java result.
mb <- model(tsibble::as_tsibble(AirPassengers), x13 = X13(value)) m <- jd3_model(mb$x13[[1]]) class(m)mb <- model(tsibble::as_tsibble(AirPassengers), x13 = X13(value)) m <- jd3_model(mb$x13[[1]]) class(m)
Methods for models fitted with X13(), TRAMOSEATS(), REGARIMA() or
TRAMO(). They can be applied directly on a mable.
## S3 method for class 'jd3_model' fitted(object, ...) ## S3 method for class 'jd3_model' residuals(object, type = c("innovation", "regression"), ...) ## S3 method for class 'jd3_model' interpolate(object, new_data = NULL, specials = NULL, ...) ## S3 method for class 'jd3_model' refit( object, new_data, specials = NULL, policy = c("Fixed", "FreeParameters", "Complete", "Outliers_StochasticComponent", "Outliers", "FixedParameters", "FixedAutoRegressiveParameters", "Current"), period = 0, start = NULL, end = NULL, ... ) ## S3 method for class 'jd3_model' stream( object, new_data, specials = NULL, policy = c("Fixed", "FreeParameters", "Complete", "Outliers_StochasticComponent", "Outliers", "FixedParameters", "FixedAutoRegressiveParameters", "Current"), period = 0, start = NULL, end = NULL, ... )## S3 method for class 'jd3_model' fitted(object, ...) ## S3 method for class 'jd3_model' residuals(object, type = c("innovation", "regression"), ...) ## S3 method for class 'jd3_model' interpolate(object, new_data = NULL, specials = NULL, ...) ## S3 method for class 'jd3_model' refit( object, new_data, specials = NULL, policy = c("Fixed", "FreeParameters", "Complete", "Outliers_StochasticComponent", "Outliers", "FixedParameters", "FixedAutoRegressiveParameters", "Current"), period = 0, start = NULL, end = NULL, ... ) ## S3 method for class 'jd3_model' stream( object, new_data, specials = NULL, policy = c("Fixed", "FreeParameters", "Complete", "Outliers_StochasticComponent", "Outliers", "FixedParameters", "FixedAutoRegressiveParameters", "Current"), period = 0, start = NULL, end = NULL, ... )
object |
A fitted |
... |
Currently unused. |
type |
Residual type: |
new_data |
A tsibble. For |
specials |
Currently unused. |
policy |
Refresh policy, a character string (see the functions above for
the available policies; default |
period, start, end
|
additional parameters used to specify the span
when |
fitted() returns the one-step-ahead fitted values of the pre-adjustment
model, on the scale of the series. Together with residuals(), it makes
augment() and accuracy() work.
residuals() returns the innovation residuals of the pre-adjustment model
(type = "innovation") or the linearized series the ARIMA part is applied
to (type = "regression"). Dates for which a residual is not defined
(e.g. lost to differencing) are NA.
interpolate() replaces the missing values of the series by the
estimates of the model. new_data must cover the same dates as the data
used to fit the model.
refit() applies the model to new data, using a JDemetra+ refresh policy
(see rjd3x13::x13_refresh() and rjd3tramoseats::tramoseats_refresh()):
the specification is refreshed from the estimated model and the
reference specification stored in the model (see the ref_spec argument
of X13()).
stream() appends new observations to the data of the model and refreshes
it in the same way. new_data contains the new observations only.
fitted(), residuals(): a numeric vector with one value per observation
(NA where undefined). Called on a mable, a tibble with the index and the
.fitted or .resid column.
interpolate(): new_data with the missing values filled in.
refit(), stream(): a jd3_model fitted on the new data. Called on a
mable, a mable.
X13(), TRAMOSEATS(), forecast.jd3_model(), jd3_model_methods
y <- as_tsibble(AirPassengers) mb <- model(y, x13 = X13(value)) # Fitted values and residuals (also used by augment() and accuracy()) fitted(mb) residuals(mb) # innovation residuals residuals(mb, type = "regression") # linearized series augment(mb) accuracy(mb) # Interpolation of missing values y_na <- y y_na$value[c(20, 21)] <- NA mb_na <- model(y_na, x13 = X13(value)) interpolate(mb_na, y_na) # Updating a model when new observations arrive start_new <- yearmonth("1960 Jan") y_old <- y[y$index < start_new, ] y_new <- y[y$index >= start_new, ] mb_old <- model(y_old, x13 = X13(value)) # stream(): append the new observations, estimated parameters kept mb_ext <- stream(mb_old, y_new) components(mb_ext) # refit(): apply the model to the full data refit(mb_old, y) # refresh policy "Fixed" (default)y <- as_tsibble(AirPassengers) mb <- model(y, x13 = X13(value)) # Fitted values and residuals (also used by augment() and accuracy()) fitted(mb) residuals(mb) # innovation residuals residuals(mb, type = "regression") # linearized series augment(mb) accuracy(mb) # Interpolation of missing values y_na <- y y_na$value[c(20, 21)] <- NA mb_na <- model(y_na, x13 = X13(value)) interpolate(mb_na, y_na) # Updating a model when new observations arrive start_new <- yearmonth("1960 Jan") y_old <- y[y$index < start_new, ] y_new <- y[y$index >= start_new, ] mb_old <- model(y_old, x13 = X13(value)) # stream(): append the new observations, estimated parameters kept mb_ext <- stream(mb_old, y_new) components(mb_ext) # refit(): apply the model to the full data refit(mb_old, y) # refresh policy "Fixed" (default)
Specials are used on the right-hand side of the formula of X13(),
TRAMOSEATS(), REGARIMA() or TRAMO(),
e.g. X13(y ~ transform(fun = "Log") + xreg(strike)).
Each one records a call to a function of rjd3toolkit that is applied to
the base specification (the spec argument).
spec(x): base specification (name or specification object); equivalent
to the spec argument of X13(), TRAMOSEATS(), REGARIMA() or TRAMO().
basic(...): arguments passed to rjd3toolkit::set_basic().
transform(...): arguments passed to rjd3toolkit::set_transform().
estimate(...): arguments passed to rjd3toolkit::set_estimate().
automodel(...): arguments passed to rjd3toolkit::set_automodel().
outlier(...): arguments passed to rjd3toolkit::set_outlier().
add_outlier(...): arguments passed to rjd3toolkit::add_outlier()
(e.g. type = "AO", date = "2020-04-01").
easter(...): arguments passed to rjd3toolkit::set_easter().
tradingdays(...): arguments passed to rjd3toolkit::set_tradingdays().
arima(...): arguments passed to rjd3toolkit::set_arima().
ramp(...): arguments passed to rjd3toolkit::add_ramp().
usrdefvar(...): arguments passed to rjd3toolkit::add_usrdefvar().
x11(...): arguments passed to rjd3x13::set_x11() (X-11 decomposition
parameters; use with X13() only).
seats(...): arguments passed to rjd3tramoseats::set_seats() (SEATS
decomposition parameters; use with TRAMOSEATS() only).
benchmarking(...): arguments passed to rjd3toolkit::set_benchmarking()
(use with X13() or TRAMOSEATS() only).
xreg(..., regeffect = NULL, group = "r", lag = 0, coef = NULL): user-defined regressors taken from
columns of the tsibble and added to the context.
By default (regeffect = NULL), the regressors are only added to the
context (with the group="r").
If regeffect is equals to "Undefined", "Trend", "Seasonal", "Irregular",
"Series" or "SeasonallyAdjusted" then variable is also added to the specification
using the rjd3toolkit::add_usrdefvar() function with the parameters lag and coeff.
If regeffect = "Calendar", then the variable is added to the specification using the
rjd3toolkit::set_tradingdays() function.
The base spec is applied first, then the specials in a fixed order (basic,
transform, estimate, automodel, outlier, add_outlier, easter, tradingdays,
arima, ramp, usrdefvar, benchmarking, x11, seats), then xreg(). Later
settings override earlier ones. A special that does not apply to the method
(e.g. x11() in TRAMOSEATS()) is ignored with a warning.
Returns the outlying observations detected (or specified) in the
pre-adjustment model of a model fitted with X13(), TRAMOSEATS(),
REGARIMA() or TRAMO():
additive outliers (AO), level shifts (LS), transitory changes (TC) and
seasonal outliers (SO). An outlier is dated at one observation, even when
its effect (e.g. a level shift) lasts longer.
## S3 method for class 'jd3_model' outliers(object, type = NULL, ...)## S3 method for class 'jd3_model' outliers(object, type = NULL, ...)
object |
A fitted |
type |
Optional character vector of outlier types to keep, e.g.
|
... |
Currently unused. |
For a jd3_model, an integer vector with the row positions of the
outliers in the data of the model (the contract of
fabletools::outliers()). Called on a mable, outliers() returns the
corresponding rows of the data, with the key columns and .model. The
type, estimate and test statistics of the outliers are available in
tidy().
X13(), TRAMOSEATS(), jd3_model_methods
mb <- model(tsibble::as_tsibble(AirPassengers), x13 = X13(value)) # Rows of the data that are outliers outliers(mb) # Additive outliers only outliers(mb, type = "AO")mb <- model(tsibble::as_tsibble(AirPassengers), x13 = X13(value)) # Rows of the data that are outliers outliers(mb) # Additive outliers only outliers(mb, type = "AO")
Defines a Reg-ARIMA model (the pre-adjustment model used in X-13), without
seasonal adjustment, to be used inside fabletools::model(). The model is
estimated with rjd3x13::jregarima() and the Java result is kept in the
fitted model. Arguments and specials are the same as for X13(), except
x11(), seats() and benchmarking(), which do not apply and are ignored
with a warning.
REGARIMA( formula, spec = c("rg4", "rg0", "rg1", "rg2c", "rg3", "rg5c"), context = NULL, ref_spec = spec, ... )REGARIMA( formula, spec = c("rg4", "rg0", "rg1", "rg2c", "rg3", "rg5c"), context = NULL, ref_spec = spec, ... )
formula |
Model formula: the name of the variable to adjust ( |
spec |
Base specification: a character name (see
|
context |
A modelling context created with
|
ref_spec |
Reference specification stored in the model: it is the
reference of the refresh policies used by |
... |
Currently unused. |
There is no decomposition, so components() is not available. The other
methods are: fitted(), residuals(), forecast(), backcast(),
outliers(), tidy(), glance() and report().
A model definition that can be passed to fabletools::model(). Once
fitted, the mable column contains a jd3_model object.
X13(), TRAMO(), jd3_specials, jd3_model_methods
y <- tsibble::as_tsibble(AirPassengers) mb <- model(y, regarima = REGARIMA(value)) tidy(mb) report(mb) # Forecasts of the raw series forecast(mb, h = 12)y <- tsibble::as_tsibble(AirPassengers) mb <- model(y, regarima = REGARIMA(value)) tidy(mb) report(mb) # Forecasts of the raw series forecast(mb, h = 12)
Defines a TRAMO model (the pre-adjustment model used in TRAMO-SEATS), without
seasonal adjustment, to be used inside fabletools::model(). The model is
estimated with rjd3tramoseats::jtramo() and the Java result is kept in the
fitted model. Arguments and specials are the same as for TRAMOSEATS(),
except x11(), seats() and benchmarking(), which do not apply and are
ignored with a warning.
TRAMO( formula, spec = c("trfull", "tr0", "tr1", "tr2", "tr3", "tr4", "tr5"), context = NULL, ref_spec = spec, ... )TRAMO( formula, spec = c("trfull", "tr0", "tr1", "tr2", "tr3", "tr4", "tr5"), context = NULL, ref_spec = spec, ... )
formula |
Model formula: the name of the variable to adjust ( |
spec |
Base specification: a character name (see
|
context |
A modelling context created with
|
ref_spec |
Reference specification stored in the model: it is the
reference of the refresh policies used by |
... |
Currently unused. |
There is no decomposition, so components() is not available. The other
methods are: fitted(), residuals(), forecast(), backcast(),
outliers(), tidy(), glance() and report().
A model definition that can be passed to fabletools::model(). Once
fitted, the mable column contains a jd3_model object.
TRAMOSEATS(), REGARIMA(), jd3_specials, jd3_model_methods
y <- tsibble::as_tsibble(AirPassengers) mb <- model(y, tramo = TRAMO(value)) tidy(mb) report(mb) # Forecasts of the raw series forecast(mb, h = 12)y <- tsibble::as_tsibble(AirPassengers) mb <- model(y, tramo = TRAMO(value)) tidy(mb) report(mb) # Forecasts of the raw series forecast(mb, h = 12)
Defines a TRAMO-SEATS model to be used inside fabletools::model(). The
model is estimated with rjd3tramoseats::jtramoseats() and the Java result
is kept in the fitted model. Arguments and specials are the same as for
X13().
TRAMOSEATS( formula, spec = c("rsafull", "rsa0", "rsa1", "rsa2", "rsa3", "rsa4", "rsa5"), context = NULL, ref_spec = spec, ... )TRAMOSEATS( formula, spec = c("rsafull", "rsa0", "rsa1", "rsa2", "rsa3", "rsa4", "rsa5"), context = NULL, ref_spec = spec, ... )
formula |
Model formula: the name of the variable to adjust ( |
spec |
Base specification: a character name or a
specification object from |
context |
A modelling context created with
|
ref_spec |
Reference specification stored in the model: it is the
reference of the refresh policies used by |
... |
Currently unused. |
A model definition that can be passed to fabletools::model(). Once
fitted, the mable column contains a jd3_model object. Use
components() to get the decomposition as a dable
(columns trend, seasonal, irregular and season_adjust).
X13(), TRAMO(), jd3_specials, jd3_model_methods
y <- tsibble::as_tsibble(AirPassengers) mb <- model(y, ts = TRAMOSEATS(value)) components(mb) # Fit both methods side by side and plot the seasonally adjusted series mb <- model(y, x13 = X13(value), ts = TRAMOSEATS(value)) if (requireNamespace("ggtime", quietly = TRUE) && requireNamespace("ggplot2", quietly = TRUE)) { ggplot2::autoplot(components(mb)) }y <- tsibble::as_tsibble(AirPassengers) mb <- model(y, ts = TRAMOSEATS(value)) components(mb) # Fit both methods side by side and plot the seasonally adjusted series mb <- model(y, x13 = X13(value), ts = TRAMOSEATS(value)) if (requireNamespace("ggtime", quietly = TRUE) && requireNamespace("ggplot2", quietly = TRUE)) { ggplot2::autoplot(components(mb)) }
Defines an X-13ARIMA model to be used inside fabletools::model().
The model is estimated with rjd3x13::jx13() and the Java result is kept in
the fitted model, so that all JDemetra+ indicators can be extracted
afterwards (see jd3_indicator()).
X13( formula, spec = c("rsa4", "rsa0", "rsa1", "rsa2c", "rsa3", "rsa5c"), context = NULL, ref_spec = spec, ... )X13( formula, spec = c("rsa4", "rsa0", "rsa1", "rsa2c", "rsa3", "rsa5c"), context = NULL, ref_spec = spec, ... )
formula |
Model formula: the name of the variable to adjust ( |
spec |
Base specification: a character name (see |
context |
A modelling context created with
|
ref_spec |
Reference specification stored in the model: it is the
reference of the refresh policies used by |
... |
Currently unused. |
The specification can be set in two (combinable) ways:
Ex ante, with the spec argument: a name or a
specification object created with rjd3x13::x13_spec() and modified with
the set_*() functions of rjd3toolkit.
In the formula, with specials such as transform() or xreg()
(see jd3_specials). This is the only way to use regressors that are
columns of the tsibble.
Specials override the base spec.
A model definition that can be passed to fabletools::model(). Once
fitted, the mable column contains a jd3_model object. Use
components() to get the decomposition as a dable
(columns trend, seasonal, irregular and season_adjust).
TRAMOSEATS(), REGARIMA(), jd3_specials, jd3_model_methods,
jd3_indicator(), jd3_dictionary()
y <- tsibble::as_tsibble(AirPassengers) # Default specification mb <- model(y, x13 = X13(value)) components(mb) # Specification created ex ante with rjd3toolkit my_spec <- rjd3x13::x13_spec("rsa3") my_spec <- rjd3toolkit::set_transform(my_spec, fun = "Log") mb <- model(y, x13 = X13(value, spec = my_spec)) # Specification set in the formula with specials mb <- model( y, x13 = X13(value ~ transform(fun = "Log") + outlier(outliers.type = c("AO", "LS"))) ) # Regressor taken from a column of the tsibble y$shock <- as.numeric(y$index == tsibble::yearmonth("1955 Jan")) mb <- model(y, x13 = X13(value ~ xreg(shock, regeffect = "Series")))y <- tsibble::as_tsibble(AirPassengers) # Default specification mb <- model(y, x13 = X13(value)) components(mb) # Specification created ex ante with rjd3toolkit my_spec <- rjd3x13::x13_spec("rsa3") my_spec <- rjd3toolkit::set_transform(my_spec, fun = "Log") mb <- model(y, x13 = X13(value, spec = my_spec)) # Specification set in the formula with specials mb <- model( y, x13 = X13(value ~ transform(fun = "Log") + outlier(outliers.type = c("AO", "LS"))) ) # Regressor taken from a column of the tsibble y$shock <- as.numeric(y$index == tsibble::yearmonth("1955 Jan")) mb <- model(y, x13 = X13(value ~ xreg(shock, regeffect = "Series")))