| Title: | Multiple Unobserved Sources of Error State Space Models |
|---|---|
| Description: | Implements the Power / Trend / Seasonal (PTS) model, a unified state-space framework based on the Multiple Source of Error (MSOE) model. It brings the trend, seasonal and irregular component models of Harvey (1989) <doi:10.1017/CBO9781107049994>, Durbin and Koopman (2012) <doi:10.1093/acprof:oso/9780199641178.001.0001>, Proietti (2000) <doi:10.1016/S0169-2070(00)00037-6>, Sbrana and Silvestrini (2023) <doi:10.1016/j.ijforecast.2022.03.003> and others together under a single estimation, selection and forecasting interface, with an optional Box-Cox power transformation. Models are estimated by maximum likelihood through the Kalman filter and smoother, with automatic component selection by information criteria. |
| Authors: | Diego J. Pedregal [aut, ctb] (ORCID: <https://orcid.org/0000-0003-4958-0969>), Ivan Svetunkov [aut, cre] (Senior Lecturer at Centre for Marketing Analytics and Forecasting, Lancaster University, UK, ORCID: <https://orcid.org/0000-0001-7826-0281>) |
| Maintainer: | Ivan Svetunkov <[email protected]> |
| License: | LGPL-2.1 |
| Version: | 0.1.0 |
| Built: | 2026-07-01 07:33:43 UTC |
| Source: | https://github.com/cran/muse |
pts object.Returns the smoothed structural states at the first observation, with
the "Error" and "Fit" columns dropped. For deterministic
components – e.g. the slope under the global (G) trend, where
the slope is fixed throughout the horizon – this equals the t = 0
initial value; for stochastic components it is the smoother's
estimate at t = 1, a close proxy to the t = 0 initial.
initials(object, ...)initials(object, ...)
object |
A fitted object of class |
... |
Unused. |
Named numeric vector of initial structural-state values.
Package contains functions implementing Multiple Source of Error state space models for purposes of time series analysis and forecasting.
| Package: | muse |
| Type: | Package |
| Date: | 2024-10-18 - Inf |
| License: | LGPL-2.1 |
The following functions are included in the package:
Diego J. Pedregal, [email protected]
Ivan Svetunkov, [email protected]
x <- rnorm(100,100,10)x <- rnorm(100,100,10)
Estimates a PTS (Power / Trend / Seasonal) state-space model
for a univariate time series. This is the user-facing entry point of the
muse package and mirrors the calling convention used elsewhere in
the smooth family: pts() estimates the model, and
forecast.pts produces forecasts from the fitted object
without re-estimating.
pts(data, model = "ZZZ", lags = stats::frequency(data), orders = list(ar = 0, ma = 0, select = FALSE), formula = NULL, regressors = c("use"), outliers = c("ignore", "use", "select"), level = 0.99, ic = c("AICc", "BICc", "BIC", "AIC"), lambda_estim = c("likelihood", "guerrero", "decomp-guerrero"), biasadj = FALSE, h = 0, holdout = FALSE, verbose = FALSE, ...)pts(data, model = "ZZZ", lags = stats::frequency(data), orders = list(ar = 0, ma = 0, select = FALSE), formula = NULL, regressors = c("use"), outliers = c("ignore", "use", "select"), level = 0.99, ic = c("AICc", "BICc", "BIC", "AIC"), lambda_estim = c("likelihood", "guerrero", "decomp-guerrero"), biasadj = FALSE, h = 0, holdout = FALSE, verbose = FALSE, ...)
data |
response series. Either a univariate |
model |
3-letter PTS specification string. The three positions encode Power / Trend / Seasonal:
|
lags |
seasonal period (default |
orders |
ARMA / SARMA spec for the irregular component. Three forms:
PTS has no differencing – any |
formula |
optional formula |
regressors |
handling of xregs. Currently only |
outliers |
what to do about outliers, mirroring |
level |
confidence level driving the outlier z-score threshold
(default 0.99). Translated to a two-sided z via
|
ic |
information criterion for automatic model selection; one of
|
lambda_estim |
how the Box-Cox power
Ignored when a numeric power is supplied (e.g. |
biasadj |
logical (default |
h |
forecast horizon. If |
holdout |
logical. If |
verbose |
logical: print intermediate optimisation output. |
... |
advanced / undocumented passthroughs. Supported keys:
|
An object of class c("pts", "smooth"). Slot names mirror
smooth::adam()'s return list where the concept is shared; pts-only
extensions are flagged below.
Inputs / spec: y, model, modelUC*, lags, lambda*
Parameters: B (estimated parameter vector), covp*
(parameter covariance), nParam – an adam-style 2 x 5 matrix
(rows Estimated / Provided; columns
nParamInternal, nParamXreg, nParamOccurrence,
nParamScale, nParamAll). nparam() returns the
[Estimated, nParamAll] cell. Estimated structural initials
(level/slope, cycle, seasonal states) are folded into
nParamInternal, exactly as smooth::adam does
In-sample fit: fitted, residuals, states plus
pts-specific comp* (additive BC-scale decomposition with
Error/Fit columns)
Cached forecast: forecast (original scale, if h > 0)
and forecast_args* for cheap re-forecasting
Likelihood + diagnostics: logLik,
table* (C++ validation text)
Scalars read by plot.smooth / diagnostics:
distribution = "dnorm", loss = "likelihood",
occurrence = NULL, holdout
Bookkeeping: call, timeElapsed
AIC / AICc / BIC / BICc are derived on demand via the methods, not stored on the object. (* = pts-specific extension.)
Diego J. Pedregal, [email protected]
Ivan Svetunkov, [email protected]
# Automatic model selection (Power / Trend / Seasonal) on monthly data model <- pts(AirPassengers, model = "ZZZ", h = 12, holdout = TRUE) model # A fixed specification: no transform, local-linear trend, trigonometric # seasonality, with a 12-step forecast fixedModel <- pts(AirPassengers, model = "1LT", h = 12) forecast(fixedModel, h = 12)# Automatic model selection (Power / Trend / Seasonal) on monthly data model <- pts(AirPassengers, model = "ZZZ", h = 12, holdout = TRUE) model # A fixed specification: no transform, local-linear trend, trigonometric # seasonality, with a 12-step forecast fixedModel <- pts(AirPassengers, model = "1LT", h = 12) forecast(fixedModel, h = 12)
pts
Standard accessors and printing for fitted pts
objects. forecast(object, h) generates forecasts from the fitted
parameters without re-running the optimiser; predict(object)
returns the in-sample fitted values.
print.pts mirrors smooth::print.adam
(smooth/R/adam.R:5862) section by section, substituting the
PTS-specific MSOE concepts where ETS-specific ones do not apply:
the "initialisation" line becomes the Box-Cox block, and
the "Persistence vector g" block becomes the MSOE innovation variances
(the same variances are otherwise the structural pieces of the B
parameter vector). The C++ validation diagnostics live on
$cppOutput should the user want them.
forecast.pts uses the C++ forecastOnly entry
point: it skips re-estimation and just propagates the Kalman filter
h steps forward from the fitted state, so changing h is
cheap. interval selects the variance source:
state propagation + future shocks
(the engine's yForV). Bands the next observation.
conditional-mean variance. In a state-space
model ,
where is the BC-scale residual variance: we read it
straight off the fitted scale, no reforecast needed.
empirical quantiles of nsim forward
paths from simulate.pts(). Returns the path matrix in
$scenarios when scenarios = TRUE.
no bands; lower = upper = mean.
level accepts a vector; lower / upper are then
matrices (or when
cumulative = TRUE). side produces two-sided
/ upper-only / lower-only intervals – the absent side is set to
on the BC scale and back-transformed to the
original-scale support boundary (0 for ,
for the identity transform). cumulative = TRUE collapses the
horizon into one total – exact for interval = "simulated"
(sum within each path); the engine does not expose cross-step state
covariance, so the other intervals fall back to simulation totals.
## S3 method for class 'pts' print(x, digits = 4, ...) ## S3 method for class 'pts' plot(x, which = c(1, 2, 4, 6), ...) ## S3 method for class 'pts' fitted(object, ...) ## S3 method for class 'pts' residuals(object, ...) ## S3 method for class 'pts' coef(object, ...) ## S3 method for class 'pts' vcov(object, ...) ## S3 method for class 'pts' nobs(object, all = FALSE, ...) ## S3 method for class 'pts' logLik(object, ...) ## S3 method for class 'pts' predict(object, newdata = NULL, ...) ## S3 method for class 'pts' forecast(object, h = 10, newdata = NULL, interval = c("prediction", "confidence", "simulated", "none"), level = 0.95, side = c("both", "upper", "lower"), cumulative = FALSE, nsim = NULL, scenarios = FALSE, biasadj = NULL, ...) ## S3 method for class 'pts' initials(object, ...)## S3 method for class 'pts' print(x, digits = 4, ...) ## S3 method for class 'pts' plot(x, which = c(1, 2, 4, 6), ...) ## S3 method for class 'pts' fitted(object, ...) ## S3 method for class 'pts' residuals(object, ...) ## S3 method for class 'pts' coef(object, ...) ## S3 method for class 'pts' vcov(object, ...) ## S3 method for class 'pts' nobs(object, all = FALSE, ...) ## S3 method for class 'pts' logLik(object, ...) ## S3 method for class 'pts' predict(object, newdata = NULL, ...) ## S3 method for class 'pts' forecast(object, h = 10, newdata = NULL, interval = c("prediction", "confidence", "simulated", "none"), level = 0.95, side = c("both", "upper", "lower"), cumulative = FALSE, nsim = NULL, scenarios = FALSE, biasadj = NULL, ...) ## S3 method for class 'pts' initials(object, ...)
x, object
|
A fitted object of class |
digits |
number of significant digits used in printed output. |
... |
further arguments passed to underlying generics. |
which |
integer vector of plot panels to draw; passed through to
|
all |
logical; if |
newdata |
unused (reserved for forecast paths with new regressors). |
h |
forecast horizon (steps ahead). |
interval |
interval type; one of |
level |
confidence level for prediction intervals (default 0.95). |
side |
one of |
cumulative |
if |
nsim |
number of simulated paths when
|
scenarios |
if |
biasadj |
point-forecast back-transform: |
The methods return the following:
fitted, predict – the in-sample fitted values as a
ts / numeric vector on the original (back-transformed) scale.
residuals – the model residuals as a ts / numeric
vector on the Box-Cox scale.
coef – a named numeric vector of the estimated parameters
(structural variances plus any ARMA / damping coefficients).
vcov – the parameter variance-covariance matrix.
nobs – an integer, the number of in-sample observations
(plus the holdout when all = TRUE).
nparam – an integer, the number of estimated parameters
(the degrees of freedom used by the information criteria).
logLik – an object of class "logLik": the maximised
log-likelihood, with df and nobs attributes.
sigma, extractSigma – a numeric scalar, the residual
standard deviation; extractScale – the maximum-likelihood scale
of the assumed distribution.
actuals – the original response series.
modelType – a character string with the PTS model code (e.g.
"PTS(0,N,T)"); modelName – a human-readable description;
errorType – the character error type ("A", additive on
the Box-Cox scale).
lags – the integer seasonal period; orders – a
list of the irregular ARMA orders (ar, ma,
lags); initials – a named numeric vector of the estimated
initial structural-state values.
forecast – an object of class "pts.forecast": a
list with the point forecast $mean and the interval bounds
$lower / $upper (original scale), together with the
forecast variance, level, and interval metadata.
print and plot are called for their side effects
(console output and a diagnostic plot, respectively) and invisibly
return their first argument.
Diego J. Pedregal, [email protected]
Ivan Svetunkov, [email protected]
Granger, C. W. J., & Newbold, P. (1976). Forecasting transformed series. Journal of the Royal Statistical Society: Series B (Methodological), 38(2), 189-203. doi:10.1111/j.2517-6161.1976.tb01585.x
Pankratz, A., & Dudley, U. (1987). Forecasts of power-transformed series. Journal of Forecasting, 6(4), 239-248. doi:10.1002/for.3980060403
Guerrero, V. M. (1993). Time-series analysis supported by power transformations. Journal of Forecasting, 12(1), 37-48. doi:10.1002/for.3980120104
model <- pts(AirPassengers, model = "1LT", h = 12, holdout = TRUE) print(model) fitted(model) residuals(model) # forecast 12 steps ahead with 95% prediction intervals forecast(model, h = 12, interval = "prediction", level = 0.95)model <- pts(AirPassengers, model = "1LT", h = 12, holdout = TRUE) print(model) fitted(model) residuals(model) # forecast 12 steps ahead with 95% prediction intervals forecast(model, h = 12, interval = "prediction", level = 0.95)