| Type: | Package |
| Title: | Multiple Unobserved Sources of Error State Space Models |
| Version: | 0.1.0 |
| Date: | 2026-06-26 |
| URL: | https://github.com/config-i1/muse |
| BugReports: | https://github.com/config-i1/muse/issues |
| Language: | en-GB |
| 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. |
| License: | LGPL-2.1 |
| Depends: | R (≥ 3.0.2), greybox, smooth |
| Imports: | Rcpp (≥ 0.12.3), generics (≥ 0.1.2), zoo |
| LinkingTo: | Rcpp, RcppArmadillo (≥ 0.8.100.0.0) |
| Suggests: | testthat (≥ 3.0.0), knitr, rmarkdown |
| VignetteBuilder: | knitr |
| Config/testthat/edition: | 3 |
| Encoding: | UTF-8 |
| ByteCompile: | true |
| Config/roxygen2/version: | 8.0.0 |
| RoxygenNote: | 8.0.0 |
| NeedsCompilation: | yes |
| Packaged: | 2026-06-25 16:48:33 UTC; config |
| Author: | Diego J. Pedregal |
| Maintainer: | Ivan Svetunkov <ivan@svetunkov.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-06-30 20:30:17 UTC |
muse package
Description
Package contains functions implementing Multiple Source of Error state space models for purposes of time series analysis and forecasting.
Details
| Package: | muse |
| Type: | Package |
| Date: | 2024-10-18 - Inf |
| License: | LGPL-2.1 |
The following functions are included in the package:
Author(s)
Diego J. Pedregal, Diego.Pedregal@uclm.es
Ivan Svetunkov, ivan@svetunkov.com
See Also
Examples
x <- rnorm(100,100,10)
Initial state values for a fitted pts object.
Description
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.
Usage
initials(object, ...)
Arguments
object |
A fitted object of class |
... |
Unused. |
Value
Named numeric vector of initial structural-state values.
pts: Power / Trend / Seasonal state-space model
Description
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.
Usage
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, ...)
Arguments
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:
|
Value
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 (rowsEstimated/Provided; columnsnParamInternal,nParamXreg,nParamOccurrence,nParamScale,nParamAll).nparam()returns the[Estimated, nParamAll]cell. Estimated structural initials (level/slope, cycle, seasonal states) are folded intonParamInternal, exactly assmooth::adamdoesIn-sample fit:
fitted, residuals, statesplus pts-specificcomp*(additive BC-scale decomposition with Error/Fit columns)Cached forecast:
forecast(original scale, ifh > 0) andforecast_args*for cheap re-forecastingLikelihood + diagnostics:
logLik,table*(C++ validation text)Scalars read by
plot.smooth/ diagnostics:distribution = "dnorm",loss = "likelihood",occurrence = NULL,holdoutBookkeeping:
call, timeElapsed
AIC / AICc / BIC / BICc are derived on demand via the methods, not stored on the object. (* = pts-specific extension.)
Author(s)
Diego J. Pedregal, Diego.Pedregal@uclm.es
Ivan Svetunkov, ivan@svetunkov.com
See Also
Examples
# 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)
S3 methods for objects of class pts
Description
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 \lambda 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:
- "prediction" (default)
state propagation + future shocks (the engine's
yForV). Bands the next observation.- "confidence"
conditional-mean variance. In a state-space model
var(E[y_{t+h}\,|\,obs]) = var(y_{t+h}\,|\,obs) - \sigma^2, where\sigma^2is the BC-scale residual variance: we read it straight off the fitted scale, no reforecast needed.- "simulated"
empirical quantiles of
nsimforward paths fromsimulate.pts(). Returns the path matrix in$scenarioswhenscenarios = TRUE.- "none"
no bands;
lower = upper = mean.
level accepts a vector; lower / upper are then
h \times nLevels matrices (or 1 \times nLevels when
cumulative = TRUE). side produces two-sided
/ upper-only / lower-only intervals – the absent side is set to
\mp\infty on the BC scale and back-transformed to the
original-scale support boundary (0 for \lambda > 0, -\infty
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.
Usage
## 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, ...)
Arguments
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: |
Value
The methods return the following:
-
fitted,predict– the in-sample fitted values as ats/ numeric vector on the original (back-transformed) scale. -
residuals– the model residuals as ats/ 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-covariancematrix. -
nobs– an integer, the number of in-sample observations (plus the holdout whenall = 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, withdfandnobsattributes. -
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– alistof 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": alistwith the point forecast$meanand the interval bounds$lower/$upper(original scale), together with the forecast variance, level, and interval metadata. -
printandplotare called for their side effects (console output and a diagnostic plot, respectively) and invisibly return their first argument.
Author(s)
Diego J. Pedregal, Diego.Pedregal@uclm.es
Ivan Svetunkov, ivan@svetunkov.com
References
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
Examples
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)
Objects exported from other packages
Description
These objects are imported from other packages. Follow the links below to see their documentation.
- generics