| Title: | Automatic Univariate Time Series Modelling of many Kinds |
|---|---|
| Description: | Comprehensive analysis and forecasting of univariate time series using automatic time series models of many kinds. Harvey AC (1989) <doi:10.1017/CBO9781107049994>. Pedregal DJ and Young PC (2002) <doi:10.1002/9780470996430>. Durbin J and Koopman SJ (2012) <doi:10.1093/acprof:oso/9780199641178.001.0001>. Hyndman RJ, Koehler AB, Ord JK, and Snyder RD (2008) <doi:10.1007/978-3-540-71918-2>. Gómez V, Maravall A (2000) <doi:10.1002/9781118032978>. Pedregal DJ, Trapero JR and Holgado E (2024) <doi:10.1016/j.ijforecast.2023.09.004>. |
| Authors: | Diego J. Pedregal [aut, cre] (ORCID: <https://orcid.org/0000-0003-4958-0969>) |
| Maintainer: | Diego J. Pedregal <[email protected]> |
| License: | GPL-3 |
| Version: | 5.3.1 |
| Built: | 2026-06-03 07:13:25 UTC |
| Source: | https://github.com/cran/UComp |
Accuracy for 1 time series y and several forecasting methods py and h steps ahead py is h x nMethods x nSeries
Accuracy(py, y, s = frequency(y), collectFun = mean)Accuracy(py, y, s = frequency(y), collectFun = mean)
py |
matrix of forecasts (h x nMethods x nForecasts) |
y |
a matrix of actual values (n x nForecasts) |
s |
seasonal period, number of observations per year |
collectFun |
aggregation function (mean, median, etc.) |
Table of accuracy results
Diego J. Pedregal
colMedians, rowMedians, tests,
sumStats, gaussTest, ident,
cusum, varTest, conv,
armaFilter, dif, roots,
zplane, acft, slide,
plotSlide, tsDisplay,
size
## Not run: Accuracy(py, y, 12)## Not run: Accuracy(py, y, 12)
Theoretical autocorrelation functions of ARMA models
acft(MApoly = 1, ARpoly = 1, ncoef = 38, s = 1)acft(MApoly = 1, ARpoly = 1, ncoef = 38, s = 1)
MApoly |
coefficients of numerator polynomial in descending order |
ARpoly |
coefficients of denominator polynomial in descending order |
ncoef |
number of coefficients |
s |
seasonal period, number of observations per year |
Theoretical autocorrelation functions
Diego J. Pedregal
colMedians, rowMedians, tests,
sumStats, gaussTest, ident,
cusum, varTest, conv,
armaFilter, dif, roots,
zplane, slide,
plotSlide, Accuracy, tsDisplay,
size
acft(c(1, -0.8), c(1, 0.8))acft(c(1, -0.8), c(1, 0.8))
Extract AIC value of UComp object
## S3 method for class 'UComp' AIC(object, ..., k = 2)## S3 method for class 'UComp' AIC(object, ..., k = 2)
object |
Object of class “UComp”. |
... |
Additional inputs to function. |
k |
The penalty per parameter to be used. |
Selection criteria for models with different number of
parameters, the smaller AIC the better. The formula used here is
, where is the log-likelihood
at the optimum, is the number of parameters plus
non-stationary states and is the number of observations.
Mind that this formulation differs from the usual definition that
does not divide by . This makes that AIC(m) and AIC(logLik(m))
give different results, being m an UComp object.
AIC value of a UC model
Diego J. Pedregal
UC, UCforecast, UCvalidate, UCfilter, UCsmooth,
UCdisturb, UCcomponents
y <- log(AirPassengers) m1 <- UCforecast(y, model = "llt/equal/arma(0,0)") AIC(m1)y <- log(AirPassengers) m1 <- UCforecast(y, model = "llt/equal/arma(0,0)") AIC(m1)
Foreign arrivals by air in Spain in thousands of passengers (airpas).
airpasairpas
Time series objects.
Monthly data from 1969
https://portal.mineco.gob.es/es-es/economiayempresa/EconomiaInformesMacro/Paginas/bdsice.aspx
No return value, called for side effects
airpasairpas
Runs all relevant functions for ARIMA modelling
ARIMA( y, u = NULL, model = NULL, cnst = NULL, s = frequency(y), criterion = "bic", h = 2 * s, verbose = FALSE, lambda = 1, maxOrders = c(3, 2, 3, 2, 1, 2), bootstrap = FALSE, nSimul = 5000, fast = FALSE )ARIMA( y, u = NULL, model = NULL, cnst = NULL, s = frequency(y), criterion = "bic", h = 2 * s, verbose = FALSE, lambda = 1, maxOrders = c(3, 2, 3, 2, 1, 2), bootstrap = FALSE, nSimul = 5000, fast = FALSE )
y |
a time series to forecast (it may be either a numerical vector or
a time series object). This is the only input required. If a vector, the additional
input |
u |
a matrix of input time series. If
the output wanted to be forecast, matrix |
model |
the model to estimate. A vector c(p,d,q,P,D,Q) containing the model orders of an ARIMA(p,d,q)x(P,D,Q)_s model. A constant may be estimated with the cnst input. Use a NULL to automatically identify the ARIMA model. |
cnst |
flag to include a constant in the model (TRUE/FALSE/NULL). Use NULL to estimate |
s |
seasonal period of time series (1 for annual, 4 for quarterly, ...) |
criterion |
information criterion for identification stage ("aic", "bic", "aicc") |
h |
forecast horizon. If the model includes inputs h is not used, the lenght of u is used instead. |
verbose |
intermediate estimation output (TRUE / FALSE) |
lambda |
Box-Cox lambda parameter (NULL: estimate) |
maxOrders |
a vector c(p,d,q,P,D,Q) containing the maximum orders of model orders to search for in the automatic identification |
bootstrap |
use bootstrap simulation for predictive distributions |
nSimul |
number of simulation runs for bootstrap simulation of predictive distributions |
fast |
fast identification (avoids post-identification checks) |
See help of ARIMAforecast.
An object of class ARIMA. It is a list with fields including all the inputs and
the fields listed below as outputs. All the functions in this package fill in
part of the fields of any ARIMA object as specified in what follows (function
ARIMA fills in all of them at once):
After running ARIMAforecast or ARIMA:
p |
Estimated parameters |
yFor |
Forecasted values of output |
yForV |
Variance of forecasted values of output |
ySimul |
Bootstrap simulations for forecasting distribution evaluation |
After running ARIMAvalidate:
table |
Estimation and validation table |
Diego J. Pedregal
y <- log(AirPassengers) m1 <- ARIMA(y) m1 <- ARIMA(y, lambda = NULL)y <- log(AirPassengers) m1 <- ARIMA(y) m1 <- ARIMA(y, lambda = NULL)
Estimates and forecasts ARIMA models
ARIMAestim(m)ARIMAestim(m)
m |
an object of type |
ARIMAestim estimates and forecasts a time series using
an ARIMA model
The same input object with the appropriate fields filled in, in particular:
p |
Estimated parameters |
yFor |
Forecasted values of output |
yForV |
Variance of forecasted values of output |
ySimul |
Bootstrap simulations for forecasting distribution evaluation |
Estimates and forecasts ARIMA general univariate models
ARIMAforecast( y, u = NULL, model = NULL, cnst = NULL, s = frequency(y), criterion = "bic", h = 2 * s, verbose = FALSE, lambda = 1, maxOrders = c(3, 2, 3, 2, 1, 2), bootstrap = FALSE, nSimul = 5000, fast = FALSE )ARIMAforecast( y, u = NULL, model = NULL, cnst = NULL, s = frequency(y), criterion = "bic", h = 2 * s, verbose = FALSE, lambda = 1, maxOrders = c(3, 2, 3, 2, 1, 2), bootstrap = FALSE, nSimul = 5000, fast = FALSE )
y |
a time series to forecast (it may be either a numerical vector or
a time series object). This is the only input required. If a vector, the additional
input |
u |
a matrix of input time series. If
the output wanted to be forecast, matrix |
model |
the model to estimate. A vector c(p,d,q,P,D,Q) containing the model orders of an ARIMA(p,d,q)x(P,D,Q)_s model. A constant may be estimated with the cnst input. Use a NULL to automatically identify the ARIMA model. |
cnst |
flag to include a constant in the model (TRUE/FALSE/NULL). Use NULL to estimate |
s |
seasonal period of time series (1 for annual, 4 for quarterly, ...) |
criterion |
information criterion for identification stage ("aic", "bic", "aicc") |
h |
forecast horizon. If the model includes inputs h is not used, the lenght of u is used instead. |
verbose |
intermediate estimation output (TRUE / FALSE) |
lambda |
Box-Cox lambda parameter (NULL: estimate) |
maxOrders |
a vector c(p,d,q,P,D,Q) containing the maximum orders of model orders to search for in the automatic identification |
bootstrap |
use bootstrap simulation for predictive distributions |
nSimul |
number of simulation runs for bootstrap simulation of predictive distributions |
fast |
fast identification (avoids post-identification checks) |
ARIMAforecast is a function for modelling and forecasting univariate
time series with Autoregressive Integrated Moving Average (ARIMA) time series models.
It sets up the model with a number of control variables that
govern the way the rest of functions in the package will work. It also estimates
the model parameters by Maximum Likelihood and forecasts the data.
An object of class ARIMA. It is a list with fields including all the inputs and
the fields listed below as outputs. All the functions in this package fill in
part of the fields of any ARIMA object as specified in what follows (function
ARIMA fills in all of them at once):
After running ARIMAforecast or ARIMA:
p |
Estimated parameters |
yFor |
Forecasted values of output |
yForV |
Variance of forecasted values of output |
ySimul |
Bootstrap simulations for forecasting distribution evaluation |
After running ARIMAvalidate:
table |
Estimation and validation table |
Diego J. Pedregal
y <- log(AirPassengers) m1 <- ARIMAforecast(y) m1 <- ARIMAforecast(y, lambda = NULL)y <- log(AirPassengers) m1 <- ARIMAforecast(y) m1 <- ARIMAforecast(y, lambda = NULL)
Sets up ARIMA general models
ARIMAsetup( y, u = NULL, model = NULL, cnst = NULL, s = frequency(y), criterion = "bic", h = 2 * s, verbose = FALSE, lambda = 1, maxOrders = c(3, 2, 3, 2, 1, 2), bootstrap = FALSE, nSimul = 5000, fast = FALSE )ARIMAsetup( y, u = NULL, model = NULL, cnst = NULL, s = frequency(y), criterion = "bic", h = 2 * s, verbose = FALSE, lambda = 1, maxOrders = c(3, 2, 3, 2, 1, 2), bootstrap = FALSE, nSimul = 5000, fast = FALSE )
y |
a time series to forecast (it may be either a numerical vector or
a time series object). This is the only input required. If a vector, the additional
input |
u |
a matrix of input time series. If
the output wanted to be forecast, matrix |
model |
the model to estimate. A vector c(p,d,q,P,D,Q) containing the model orders of an ARIMA(p,d,q)x(P,D,Q)_s model. A constant may be estimated with the cnst input. Use a NULL to automatically identify the ARIMA model. |
cnst |
flag to include a constant in the model (TRUE/FALSE/NULL). Use NULL to estimate |
s |
seasonal period of time series (1 for annual, 4 for quarterly, ...) |
criterion |
information criterion for identification stage ("aic", "bic", "aicc") |
h |
forecast horizon. If the model includes inputs h is not used, the lenght of u is used instead. |
verbose |
intermediate estimation output (TRUE / FALSE) |
lambda |
Box-Cox lambda parameter (NULL: estimate) |
maxOrders |
a vector c(p,d,q,P,D,Q) containing the maximum orders of model orders to search for in the automatic identification |
bootstrap |
use bootstrap simulation for predictive distributions |
nSimul |
number of simulation runs for bootstrap simulation of predictive distributions |
fast |
fast identification (avoids post-identification checks) |
See help of ARIMAforecast.
An object of class ARIMA. It is a list with fields including all the inputs and
the fields listed below as outputs. All the functions in this package fill in
part of the fields of any ARIMA object as specified in what follows (function
ARIMA fills in all of them at once):
After running ARIMAforecast or ARIMA:
p |
Estimated parameters |
yFor |
Forecasted values of output |
yForV |
Variance of forecasted values of output |
ySimul |
Bootstrap simulations for forecasting distribution evaluation |
After running ARIMAvalidate:
table |
Estimation and validation table |
Diego J. Pedregal
ARIMA, ARIMAforecast, ARIMAvalidate,
y <- log(AirPassengers) m1 <- ARIMAsetup(y) m1 <- ARIMAsetup(y, lambda = NULL)y <- log(AirPassengers) m1 <- ARIMAsetup(y) m1 <- ARIMAsetup(y, lambda = NULL)
Shows a table of estimation and diagnostics results for ARIMA models
ARIMAvalidate(m)ARIMAvalidate(m)
m |
an object of type |
The same input object with the appropriate fields filled in, in particular:
table |
Estimation and validation table |
Diego J. Pedregal
ARIMA, ARIMAforecast, ARIMAvalidate,
m1 <- ARIMAforecast(log(gdp)) m1 <- ARIMAvalidate(m1)m1 <- ARIMAforecast(log(gdp)) m1 <- ARIMAvalidate(m1)
AR polynomial coefficients of ARMA model
arma2tsi(MApoly, ARpoly, n = 100)arma2tsi(MApoly, ARpoly, n = 100)
MApoly |
coefficients of numerator polynomial in descending order |
ARpoly |
coefficients of denominator polynomial in descending order |
n |
number of coefficients |
Tsi (MA form) coefficients of equivalent ARMA model
Diego J. Pedregal
Filter of time series
armaFilter(MA = 1, AR = 1, y)armaFilter(MA = 1, AR = 1, y)
MA |
numerator polynomial |
AR |
denominator polynomial |
y |
a vector, ts or tsibble object |
Filtered time series
Diego J. Pedregal
colMedians, rowMedians, tests,
sumStats, gaussTest, ident,
cusum, varTest, conv,
dif, roots,
zplane, acft, slide,
plotSlide, Accuracy, tsDisplay,
size
y <- armaFilter(1, c(1 , -0.8), rnorm(200))y <- armaFilter(1, c(1 , -0.8), rnorm(200))
Inverse of Box-Cox transformation
auxInvBoxCox(y, lambda)auxInvBoxCox(y, lambda)
y |
matrix, array or vector |
lambda |
lambda parameter of Box-Cox transformation |
Inverse of Box-Cox heteroskedasticity transformation
Diego J. Pedregal
Extract BIC (or SBC) value of UComp object
## S3 method for class 'UComp' BIC(object, ...)## S3 method for class 'UComp' BIC(object, ...)
object |
Object of class “UComp”. |
... |
Additional inputs to function. |
Selection criteria for models with different number of
parameters, the smaller BIC the better. The formula used here is
, where is the log-likelihood
at the optimum, is the number of parameters plus
non-stationary states and is the number of observations.
Mind that this formulation differs from the usual definition that
does not divide by . This makes that BIC(m) and BIC(logLik(m))
give different results, being m an UComp object.
BIC value of a UC model
Diego J. Pedregal
UC, UCforecast, UCvalidate, UCfilter, UCsmooth,
UCdisturb, UCcomponents
y <- log(AirPassengers) m1 <- UCforecast(y, model = "llt/equal/arma(0,0)") BIC(m1)y <- log(AirPassengers) m1 <- UCforecast(y, model = "llt/equal/arma(0,0)") BIC(m1)
Runs Box-Cox transform of a time series
box.cox(x, lambda)box.cox(x, lambda)
x |
Time series object. |
lambda |
Lambda parameter for Box-Cox transform. |
Box-Cox transformed time series
Diego J. Pedregal
inv.box.cox, UC, UCforecast, UCvalidate, UCfilter, UCsmooth,
UCdisturb, UCcomponents
y <- box.cox(AirPassengers, 0.5) plot(y)y <- box.cox(AirPassengers, 0.5) plot(y)
Methane concentration at Cape Grim in Australia (ch4).
ch4ch4
Time series objects.
Monthly data from January 1992 to December 2019
No return value, called for side effects
ch4ch4
Medians of matrix by columns
colMedians(x, na.rm = TRUE, ...)colMedians(x, na.rm = TRUE, ...)
x |
a matrix |
na.rm |
boolean indicating whether to remove nans |
... |
rest of inputs |
A vector with all the medians in columns
Diego J. Pedregal
rowMedians, tests,
sumStats, gaussTest, ident,
cusum, varTest, conv,
armaFilter, dif, roots,
zplane, acft, slide,
plotSlide, Accuracy, tsDisplay,
size
s <- colMedians(matrix(4, 3, 2))s <- colMedians(matrix(4, 3, 2))
1D convolution: filtering or polynomial multiplication
conv(...)conv(...)
... |
list of vectors to convolute |
Convolution of all input vectors
Diego J. Pedregal
colMedians, rowMedians, tests,
sumStats, gaussTest, ident,
cusum, varTest,
armaFilter, dif, roots,
zplane, acft, slide,
plotSlide, Accuracy, tsDisplay,
size
conv(c(1, -1), c(1, -2, 1)) conv(c(1, -1), c(1, 0.8))conv(c(1, -1), c(1, -2, 1)) conv(c(1, -1), c(1, 0.8))
Cusum and cusumsq tests
cusum(y, runFromTest = FALSE)cusum(y, runFromTest = FALSE)
y |
a vector, ts or tsibble object |
runFromTest |
internal check variable |
No return value, called for side effects
Diego J. Pedregal
colMedians, rowMedians, tests,
sumStats, gaussTest, ident,
varTest, conv,
armaFilter, dif, roots,
zplane, acft, slide,
plotSlide, Accuracy, tsDisplay,
size
cusum(AirPassengers)cusum(AirPassengers)
Estimates and forecasts daily time series with weekly and monthly seasonal patterns
DAYforecast( y, u = NULL, initial_date, h = 24, lambda = 1, criterion = "aic", p0 = -9999.9, verbose = FALSE )DAYforecast( y, u = NULL, initial_date, h = 24, lambda = 1, criterion = "aic", p0 = -9999.9, verbose = FALSE )
y |
A numeric vector, |
u |
Optional matrix or vector of exogenous regressors. If provided, it must cover both the estimation and forecast periods. |
initial_date |
A character or |
h |
Integer indicating the forecast horizon (number of days ahead). |
lambda |
Box–Cox transformation parameter (NULL for automatic identification). |
criterion |
Information criterion used for model selection (AIC, BIC, AICc). |
p0 |
Initial parameter vector for Maximum Likelihood estimation. |
verbose |
if |
DAYforecast estimates and forecasts daily univariate time series using
Dynamic Harmonic Regression (DHR).
The function is tailored for daily data and explicitly accounts for:
Monthly seasonality through sinusoidal terms based on calendar months
Weekly seasonality through sinusoidal terms with periods of 7 days
Standard methods applicable to UComp objects are available.
An object of class UComp. It is a list containing the model specification,
estimated parameters, and forecasting results.
Diego J. Pedregal
UC, UCforecast, UCfilter,
UCsmooth, UCdisturb,
UCcomponents
y <- rnorm(400) m <- DAYforecast(y, initial_date = "2015-01-01", h = 30)y <- rnorm(400) m <- DAYforecast(y, initial_date = "2015-01-01", h = 30)
Discrete differencing of time series
dif(y, difs = 1, seas = 1)dif(y, difs = 1, seas = 1)
y |
a vector, ts or tsibble object |
difs |
vector with differencing orders |
seas |
vector of seasonal periods |
Differenced time series
Diego J. Pedregal
colMedians, rowMedians, tests,
sumStats, gaussTest, ident,
cusum, varTest, conv,
armaFilter, roots,
zplane, acft, slide,
plotSlide, Accuracy, tsDisplay,
size
dif(AirPassengers) dif(AirPassengers, 2) dif(AirPassengers, c(1, 1), c(1, 12))dif(AirPassengers) dif(AirPassengers, 2) dif(AirPassengers, c(1, 1), c(1, 12))
Runs all relevant functions for ETS modelling
ETS( y, u = NULL, model = "???", s = frequency(y), h = 2 * s, criterion = "aicc", lambda = 1, armaIdent = FALSE, identAll = FALSE, forIntervals = FALSE, bootstrap = FALSE, nSimul = 5000, verbose = FALSE, alphaL = c(1e-08, 1 - 1e-08), betaL = alphaL, gammaL = alphaL, phiL = c(0.8, 0.98), p0 = -99999 )ETS( y, u = NULL, model = "???", s = frequency(y), h = 2 * s, criterion = "aicc", lambda = 1, armaIdent = FALSE, identAll = FALSE, forIntervals = FALSE, bootstrap = FALSE, nSimul = 5000, verbose = FALSE, alphaL = c(1e-08, 1 - 1e-08), betaL = alphaL, gammaL = alphaL, phiL = c(0.8, 0.98), p0 = -99999 )
y |
a time series to forecast (it may be either a numerical vector or
a time series object). This is the only input required. If a vector, the additional
input |
u |
a matrix of input time series. If
the output wanted to be forecast, matrix |
model |
the model to estimate. It is a single string indicating the type of model for each component with one or two letters:
|
s |
seasonal period of time series (1 for annual, 4 for quarterly, ...) |
h |
forecast horizon. If the model includes inputs h is not used, the lenght of u is used instead. |
criterion |
information criterion for identification ("aic", "bic" or "aicc"). |
lambda |
Box-Cox lambda parameter (NULL: estimate) |
armaIdent |
check for arma models for error component (TRUE / FALSE). |
identAll |
run all models to identify the best one (TRUE / FALSE) |
forIntervals |
estimate forecasting intervals (TRUE / FALSE) |
bootstrap |
use bootstrap simulation for predictive distributions |
nSimul |
number of simulation runs for bootstrap simulation of predictive distributions |
verbose |
intermediate estimation output (TRUE / FALSE) |
alphaL |
constraints limits for alpha parameter |
betaL |
constraints limits for beta parameter |
gammaL |
constraints limits for gamma parameter |
phiL |
constraints limits for phi parameter |
p0 |
initial values for parameter search (alpha, beta, phi, gamma) with consraints:
|
See help of ETSforecast.
An object of class ETS. It is a list with fields including all the inputs and
the fields listed below as outputs. All the functions in this package fill in
part of the fields of any ETS object as specified in what follows (function
ETS fills in all of them at once):
After running ETSforecast:
p |
Estimated parameters |
criteria |
Values for estimation criteria (LogLik, AIC, BIC, AICc) |
yFor |
Forecasted values of output |
yForV |
Variance of forecasted values of output |
ySimul |
Bootstrap simulations for forecasting distribution evaluation |
After running ETSvalidate:
table |
Estimation and validation table |
comp |
Estimated components in matrix form |
After running ETScomponents:
comp |
Estimated components in matrix form |
An object of class ETS. See ETSforecast.
Diego J. Pedregal
ETSforecast, ETSvalidate,
ETScomponents
y <- log(AirPassengers) m1 <- ETS(y) m1 <- ETS(y, model = "MAM")y <- log(AirPassengers) m1 <- ETS(y) m1 <- ETS(y, model = "MAM")
Estimates components of ETS models
ETScomponents(m)ETScomponents(m)
m |
an object of type |
The same input object with the appropriate fields filled in, in particular:
comp |
Estimated components in matrix form |
Diego J. Pedregal
m1 <- ETS(log(gdp)) m1 <- ETScomponents(m1)m1 <- ETS(log(gdp)) m1 <- ETScomponents(m1)
Estimates and forecasts ETS models
ETSestim(m)ETSestim(m)
m |
an object of type |
ETSestim estimates and forecasts a time series using an
an ETS model
The same input object with the appropriate fields filled in, in particular:
p |
Estimated parameters |
yFor |
Forecasted values of output |
yForV |
Variance of forecasted values of output |
ySimul |
Bootstrap simulations for forecasting distribution evaluation |
Diego J. Pedregal
ETS, ETSforecast, ETSvalidate,
ETScomponents
m1 <- ETSsetup(log(gdp)) m1 <- ETSestim(m1)m1 <- ETSsetup(log(gdp)) m1 <- ETSestim(m1)
Estimates and forecasts ETS general univariate models
ETSforecast( y, u = NULL, model = "???", s = frequency(y), h = max(2 * s, 6), criterion = "aicc", lambda = 1, armaIdent = FALSE, identAll = FALSE, forIntervals = FALSE, bootstrap = FALSE, nSimul = 5000, verbose = FALSE, alphaL = c(1e-08, 1 - 1e-08), betaL = alphaL, gammaL = alphaL, phiL = c(0.8, 0.98), p0 = -99999 )ETSforecast( y, u = NULL, model = "???", s = frequency(y), h = max(2 * s, 6), criterion = "aicc", lambda = 1, armaIdent = FALSE, identAll = FALSE, forIntervals = FALSE, bootstrap = FALSE, nSimul = 5000, verbose = FALSE, alphaL = c(1e-08, 1 - 1e-08), betaL = alphaL, gammaL = alphaL, phiL = c(0.8, 0.98), p0 = -99999 )
y |
a time series to forecast (it may be either a numerical vector or
a time series object). This is the only input required. If a vector, the additional
input |
u |
a matrix of input time series. If
the output wanted to be forecast, matrix |
model |
the model to estimate. It is a single string indicating the type of model for each component with one or two letters:
|
s |
seasonal period of time series (1 for annual, 4 for quarterly, ...) |
h |
forecast horizon. If the model includes inputs h is not used, the lenght of u is used instead. |
criterion |
information criterion for identification ("aic", "bic" or "aicc"). |
lambda |
Box-Cox lambda parameter (NULL: estimate) |
armaIdent |
check for arma models for error component (TRUE / FALSE). |
identAll |
run all models to identify the best one (TRUE / FALSE) |
forIntervals |
estimate forecasting intervals (TRUE / FALSE) |
bootstrap |
use bootstrap simulation for predictive distributions |
nSimul |
number of simulation runs for bootstrap simulation of predictive distributions |
verbose |
intermediate estimation output (TRUE / FALSE) |
alphaL |
constraints limits for alpha parameter |
betaL |
constraints limits for beta parameter |
gammaL |
constraints limits for gamma parameter |
phiL |
constraints limits for phi parameter |
p0 |
initial values for parameter search (alpha, beta, phi, gamma) with consraints:
|
ETSforecast is a function for modelling and forecasting univariate
time series with ExponenTial Smoothing (ETS) time series models.
It sets up the model with a number of control variables that
govern the way the rest of functions in the package will work. It also estimates
the model parameters by Maximum Likelihood and forecasts the data.
An object of class ETS. It is a list with fields including all the inputs and
the fields listed below as outputs. All the functions in this package fill in
part of the fields of any ETS object as specified in what follows (function
ETS fills in all of them at once):
After running ETSforecast:
p |
Estimated parameters |
criteria |
Values for estimation criteria (LogLik, AIC, BIC, AICc) |
yFor |
Forecasted values of output |
yForV |
Variance of forecasted values of output |
ySimul |
Bootstrap simulations for forecasting distribution evaluation |
After running ETSvalidate:
table |
Estimation and validation table |
comp |
Estimated components in matrix form |
After running ETScomponents:
comp |
Estimated components in matrix form |
Diego J. Pedregal
ETS, ETSvalidate,
ETScomponents
y <- log(AirPassengers) m1 <- ETSforecast(y) m1 <- ETSforecast(y, model = "A?A")y <- log(AirPassengers) m1 <- ETSforecast(y) m1 <- ETSforecast(y, model = "A?A")
Sets up ETS general univariate models
ETSsetup( y, u = NULL, model = "???", s = frequency(y), h = 2 * s, criterion = "aicc", lambda = 1, armaIdent = FALSE, identAll = FALSE, forIntervals = FALSE, bootstrap = FALSE, nSimul = 5000, verbose = FALSE, alphaL = c(1e-08, 1 - 1e-08), betaL = alphaL, gammaL = alphaL, phiL = c(0.8, 0.98), p0 = -99999 )ETSsetup( y, u = NULL, model = "???", s = frequency(y), h = 2 * s, criterion = "aicc", lambda = 1, armaIdent = FALSE, identAll = FALSE, forIntervals = FALSE, bootstrap = FALSE, nSimul = 5000, verbose = FALSE, alphaL = c(1e-08, 1 - 1e-08), betaL = alphaL, gammaL = alphaL, phiL = c(0.8, 0.98), p0 = -99999 )
y |
a time series to forecast (it may be either a numerical vector or
a time series object). This is the only input required. If a vector, the additional
input |
u |
a matrix of input time series. If
the output wanted to be forecast, matrix |
model |
the model to estimate. It is a single string indicating the type of model for each component with one or two letters:
|
s |
seasonal period of time series (1 for annual, 4 for quarterly, ...) |
h |
forecast horizon. If the model includes inputs h is not used, the lenght of u is used instead. |
criterion |
information criterion for identification ("aic", "bic" or "aicc"). |
lambda |
Box-Cox lambda parameter (NULL: estimate) |
armaIdent |
check for arma models for error component (TRUE / FALSE). |
identAll |
run all models to identify the best one (TRUE / FALSE) |
forIntervals |
estimate forecasting intervals (TRUE / FALSE) |
bootstrap |
use bootstrap simulation for predictive distributions |
nSimul |
number of simulation runs for bootstrap simulation of predictive distributions |
verbose |
intermediate estimation output (TRUE / FALSE) |
alphaL |
constraints limits for alpha parameter |
betaL |
constraints limits for beta parameter |
gammaL |
constraints limits for gamma parameter |
phiL |
constraints limits for phi parameter |
p0 |
initial values for parameter search (alpha, beta, phi, gamma) with consraints:
|
See help of ETSforecast.
An object of class ETS. It is a list with fields including all the inputs and
the fields listed below as outputs. All the functions in this package fill in
part of the fields of any ETS object as specified in what follows (function
ETS fills in all of them at once):
After running ETSforecast:
p |
Estimated parameters |
criteria |
Values for estimation criteria (LogLik, AIC, BIC, AICc) |
yFor |
Forecasted values of output |
yForV |
Variance of forecasted values of output |
ySimul |
Bootstrap simulations for forecasting distribution evaluation |
After running ETSvalidate:
table |
Estimation and validation table |
comp |
Estimated components in matrix form |
After running ETScomponents:
comp |
Estimated components in matrix form |
An object of class ETS. See ETSforecast.
Diego J. Pedregal
ETS, ETSforecast, ETSvalidate,
ETScomponents
y <- log(AirPassengers) m1 <- ETSsetup(y) m1 <- ETSsetup(y, model = "???") m1 <- ETSsetup(y, model = "?AA")y <- log(AirPassengers) m1 <- ETSsetup(y) m1 <- ETSsetup(y, model = "???") m1 <- ETSsetup(y, model = "?AA")
Shows a table of estimation and diagnostics results for ETS models
ETSvalidate(m)ETSvalidate(m)
m |
an object of type |
The same input object with the appropriate fields filled in, in particular:
table |
Estimation and validation table |
Diego J. Pedregal
ETS, ETSforecast, ETSvalidate,
ETScomponents
m1 <- ETSforecast(log(gdp)) m1 <- ETSvalidate(m1)m1 <- ETSforecast(log(gdp)) m1 <- ETSvalidate(m1)
Reorder data frame returning column col reordered according to the values in column accordingTo
extract(x, col, accordingTo = 1)extract(x, col, accordingTo = 1)
x |
a data frame |
col |
column to be ordered |
accordingTo |
column to take as the pattern |
Data frame reordered accoring to a given column data
Diego J. Pedregal
Gaussianity tests
gaussTest(y, runFromTests = FALSE)gaussTest(y, runFromTests = FALSE)
y |
a vector, ts or tsibble object |
runFromTests |
internal check |
No return value, called for side effects
Diego J. Pedregal
colMedians, rowMedians, tests,
sumStats, ident,
cusum, varTest, conv,
armaFilter, dif, roots,
zplane, acft, slide,
plotSlide, Accuracy, tsDisplay,
size
gaussTest(AirPassengers)gaussTest(AirPassengers)
Quarterly real Spanish Gross Domestic Product (gdp)
gdpgdp
Time series objects.
Quarterly since 1995
https://portal.mineco.gob.es/es-es/economiayempresa/EconomiaInformesMacro/Paginas/bdsice.aspx
No return value, called for side effects
gdpgdp
Get initial conditions for parameters of UComp object
getp0(y, model = "llt/equal/arma(0,0)", periods = NA)getp0(y, model = "llt/equal/arma(0,0)", periods = NA)
y |
a time series to forecast. |
model |
any valid |
periods |
vector of fundamental period and harmonics required. |
Provides initial parameters of a given model for the time series.
They may be changed arbitrarily by the user to include as an input p0 to
UC or UCforecast functions (see example below).
There is no guarantee that the model will converge and selecting initial conditions
should be used with care.
A set of parameters p0 of an object of class UComp
to use as input to UC, UCforecast.
Diego J. Pedregal
UC, UCvalidate, UCfilter, UCsmooth,
UCdisturb, UCcomponents,
UChp
## Not run: p0 <- getp0(log(AirPassengers), model = "llt/equal/arma(0,0)") p0[1] <- 0 # p0[1] <- NA m <- UCforecast(log(AirPassengers), model = "llt/equal/arma(0,0)", p0 = p0) ## End(Not run)## Not run: p0 <- getp0(log(AirPassengers), model = "llt/equal/arma(0,0)") p0[1] <- 0 # p0[1] <- NA m <- UCforecast(log(AirPassengers), model = "llt/equal/arma(0,0)", p0 = p0) ## End(Not run)
Autocorrelation functions of a time series
ident(y, nCoef = min(37, floor(length(y)/4)), nPar = 0, runFromTests = FALSE)ident(y, nCoef = min(37, floor(length(y)/4)), nPar = 0, runFromTests = FALSE)
y |
a vector, ts or tsibble object |
nCoef |
number of autocorrelation coefficients to estimate |
nPar |
number of parameters in a model if y is a residual |
runFromTests |
internal check |
A vector with output table including ACF, etc.
Diego J. Pedregal
colMedians, rowMedians, tests,
sumStats, gaussTest,
cusum, varTest, conv,
armaFilter, dif, roots,
zplane, acft, slide,
plotSlide, Accuracy, tsDisplay,
size
ident(AirPassengers)ident(AirPassengers)
Runs inverse of Box-Cox transform of a time series
inv.box.cox(x, lambda)inv.box.cox(x, lambda)
x |
Transformed time series object. |
lambda |
Lambda parameter used for Box-Cox transform. |
Inverse Box-Cox transformed time series
Diego J. Pedregal
box.cox, UC, UCforecast, UCvalidate, UCfilter, UCsmooth,
UCdisturb, UCcomponents
y <- inv.box.cox(box.cox(AirPassengers, 0.5), 0.5) plot(y)y <- inv.box.cox(box.cox(AirPassengers, 0.5), 0.5) plot(y)
Calculates inverse of Box-Cox transformation with confidence bands, calculated as const time the standard error
invBoxCox(y, yVar, lambda, const = 2)invBoxCox(y, yVar, lambda, const = 2)
y |
matrix, array or vector |
yVar |
matrix, array or vector of variances of y |
lambda |
lambda parameter of Box-Cox transformation |
const |
number of standard error for confidence band |
Inverse of Box-Cox heteroskedasticity transformation with confidence bands
Diego J. Pedregal
Spanish Industrial Production Index (ipi).
ipiipi
Objeto time series.
Monthly since 1975
https://portal.mineco.gob.es/es-es/economiayempresa/EconomiaInformesMacro/Paginas/bdsice.aspx
No return value, called for side effects
ipiipi
Seasonally adjusted quarterly OECD real gross domestic product (OECDgdp).
OECDgdpOECDgdp
Time series objects.
Quarterly data from 1962 to 2019
https://portal.mineco.gob.es/es-es/economiayempresa/EconomiaInformesMacro/Paginas/bdsice.aspx
No return value, called for side effects
OECDgdpOECDgdp
Plot of ACF and PACF
plotAcfPacf(ACF, PACF, s = 1, n = NA, runFromTest = FALSE)plotAcfPacf(ACF, PACF, s = 1, n = NA, runFromTest = FALSE)
ACF |
variable to plot |
PACF |
second variable to plot |
s |
seasonal period |
n |
number of coefficients |
runFromTest |
internal check variable |
No return value, called for side effects
Diego J. Pedregal
Plot variable in bars
plotBar(ACF, s = 1, n = NA, label = "ACF")plotBar(ACF, s = 1, n = NA, label = "ACF")
ACF |
variable to plot |
s |
seasonal period |
n |
number of coefficients |
label |
label for plot |
Handle of plot
Diego J. Pedregal
Plot summarised results from slide
plotSlide(py1, y, orig, step = 1, errorFun, collectFun = mean)plotSlide(py1, y, orig, step = 1, errorFun, collectFun = mean)
py1 |
output from slide function |
y |
a vector, matrix or list of time series (the same used in slide call) |
orig |
starting forecasting origin (the same used in slide call) |
step |
observations ahead to move the forecasting origin (the same used in slide call) |
errorFun |
user function to calculate error measures |
collectFun |
aggregation function (mean, median, etc.) |
An array of forecasting errors of dimensions (horizon x nOrigs x nModels x nSeries)
Diego J. Pedregal
colMedians, rowMedians, tests,
sumStats, gaussTest, ident,
cusum, varTest, conv,
armaFilter, dif, roots,
zplane, acft, slide,
Accuracy, tsDisplay,
size
## Not run: plotSlide(py1, AirPassengers, 100, 1, errorFun)## Not run: plotSlide(py1, AirPassengers, 100, 1, errorFun)
Returns date of next to end time series y
plus_one(y)plus_one(y)
y |
a ts object |
Next time stamp
Diego J. Pedregal
Forecasting using structural Unobseved Components models with prediction intervals
## S3 method for class 'UComp' predict(object, newdata = NULL, n.ahead = NULL, level = 0.95, ...)## S3 method for class 'UComp' predict(object, newdata = NULL, n.ahead = NULL, level = 0.95, ...)
object |
Object of class “UComp”. |
newdata |
New output data to apply “UComp” object to. |
n.ahead |
Number of steps ahead to forecast or new inputs variables including their predictions. |
level |
Confidence level for prediction intervals. |
... |
Ignored. |
See help of UC.
Forecasts of a UC model
A matrix with the mean forecasts and lower and upper prediction intervals
Diego J. Pedregal
UC, UCforecast, UCvalidate, UCfilter, UCsmooth,
UCdisturb, UCcomponents
y <- log(AirPassengers) m1 <- UCforecast(y, model = "llt/eq/arma(0,0)") f1 <- predict(m1)y <- log(AirPassengers) m1 <- UCforecast(y, model = "llt/eq/arma(0,0)") f1 <- predict(m1)
Remove nans at beginning or end of vector
removeNaNs(x)removeNaNs(x)
x |
a vector or a ts object |
vector with nans removed (only those at beginning or end)
Diego J. Pedregal
Roots of polynomial
roots(x)roots(x)
x |
coefficients of polynomial in descending order |
Roots of polynomial
Diego J. Pedregal
colMedians, rowMedians, tests,
sumStats, gaussTest, ident,
cusum, varTest, conv,
armaFilter, dif,
zplane, acft, slide,
plotSlide, Accuracy, tsDisplay,
size
roots(c(1, -2 ,1)) roots(conv(c(1, -1), c(1, 0.8)))roots(c(1, -2 ,1)) roots(conv(c(1, -1), c(1, 0.8)))
Medians of matrix by rows
rowMedians(x, na.rm = TRUE, ...)rowMedians(x, na.rm = TRUE, ...)
x |
a matrix |
na.rm |
boolean indicating whether to remove nans |
... |
rest of inputs |
A vector with all the medians in rows
Diego J. Pedregal
colMedians, tests,
sumStats, gaussTest, ident,
cusum, varTest, conv,
armaFilter, dif, roots,
zplane, acft, slide,
plotSlide, Accuracy, tsDisplay,
size
s <- rowMedians(matrix(4, 3, 2))s <- rowMedians(matrix(4, 3, 2))
Sales index for food of large retailers in Spain
salessales
Time series objects.
Monthly data from January 1995 to December 2019
https://portal.mineco.gob.es/es-es/economiayempresa/EconomiaInformesMacro/Paginas/bdsice.aspx
No return value, called for side effects
salessales
Size of vector, matrix or array
size(y)size(y)
y |
a vector, matrix or array |
A vector with all the dimensions
Diego J. Pedregal
colMedians, rowMedians, tests,
sumStats, gaussTest, ident,
cusum, varTest, conv,
armaFilter, dif, roots,
zplane, acft, slide,
plotSlide, Accuracy, tsDisplay
s <- size(matrix(4, 3, 2)) s <- size(rep(4, 3)) s <- size(array(4, c(3, 2, 2)))s <- size(matrix(4, 3, 2)) s <- size(rep(4, 3)) s <- size(array(4, c(3, 2, 2)))
Rolling forecasting of a matrix of time series
slide( y, orig, forecFun, ..., h = 12, step = 1, output = TRUE, window = NA, parallel = FALSE )slide( y, orig, forecFun, ..., h = 12, step = 1, output = TRUE, window = NA, parallel = FALSE )
y |
a vector, a matrix or a list of time series |
orig |
starting forecasting origin |
forecFun |
user function that implements forecasting methods |
... |
rest of inputs to forecFun function |
h |
forecasting horizon |
step |
observations ahead to move the forecasting origin |
output |
output TRUE/FALSE |
window |
fixed window width in number of observations (NA for non fixed) |
parallel |
run forecasts in parallel |
Takes time series and run forecasting methods implemented in function forecFun h steps ahead along the time series y, starting at forecasting origin orig, and moving step observations ahead. Forecasts may be run in parallel by setting parallel to TRUE. A fixed window width may be specified with input window. The output is of dimensions (h, nOrigs, nModels, nSeries)
An array of forecasts of dimensions (horizon x nOrigs x nModels x nSeries)
Diego J. Pedregal
colMedians, rowMedians, tests,
sumStats, gaussTest, ident,
cusum, varTest, conv,
armaFilter, dif, roots,
zplane, acft,
plotSlide, Accuracy, tsDisplay,
size
## Not run: slide(AirPassengers, 100, forecFun)## Not run: slide(AirPassengers, 100, forecFun)
Auxiliary function run from slide
slideAux( y, orig, forecFun, h = 12, step = 1, output = TRUE, graph = TRUE, window = NA, parallel = FALSE, isList = FALSE, ... )slideAux( y, orig, forecFun, h = 12, step = 1, output = TRUE, graph = TRUE, window = NA, parallel = FALSE, isList = FALSE, ... )
y |
a vector or matrix of time series |
orig |
starting forecasting origin |
forecFun |
user function that implements forecasting methods |
h |
forecasting horizon |
step |
observations ahead to move the forecasting origin |
output |
output TRUE/FALSE |
graph |
fraphical output TRUE/FALSE |
window |
fixed window width in number of observations (NA for non fixed) |
parallel |
run forecasts in parallel |
isList |
whether the input data y is a list or a matrix |
... |
rest of inputs to forecFun function |
Auxiliary output of slide function for just one time series
Diego J. Pedregal
Summary statistics of a matrix of variables
sumStats(y, decimals = 5)sumStats(y, decimals = 5)
y |
a vector, matrix of time series |
decimals |
number of decimals for table |
Position, dispersion, skewness, kurtosis, etc.
Table of values in string matrix
Diego J. Pedregal
colMedians, rowMedians, tests,
gaussTest, ident,
cusum, varTest, conv,
armaFilter, dif, roots,
zplane, acft, slide,
plotSlide, Accuracy, tsDisplay,
size
s <- sumStats(AirPassengers)s <- sumStats(AirPassengers)
Tests on a time series
tests( y, parts = 1/3, nCoef = min(25, length(x)/4), nPar = 0, s = frequency(y), avoid = 16 )tests( y, parts = 1/3, nCoef = min(25, length(x)/4), nPar = 0, s = frequency(y), avoid = 16 )
y |
a vector, ts or tsibble object |
parts |
proportion of sample to include in ratio of variances test |
nCoef |
number of autocorrelation coefficients to estimate |
nPar |
number of parameters in a model if y is a residual |
s |
seasonal period, number of observations per year |
avoid |
number of observations to avoid at beginning of sample to eliminate initial effects |
Multiple tests on a time series, including summary statistics, autocorrelation, Gaussianity and heteroskedasticity,
Table with all test results
Diego J. Pedregal
colMedians, rowMedians,
sumStats, gaussTest, ident,
cusum, varTest, conv,
armaFilter, dif, roots,
zplane, acft, slide,
plotSlide, Accuracy, tsDisplay,
size
tests(AirPassengers)tests(AirPassengers)
Runs all relevant functions for TETS modelling
TETS( y, u = NULL, model = "???", s = frequency(y), h = 2 * s, criterion = "aicc", forIntervals = FALSE, bootstrap = FALSE, nSimul = 5000, verbose = FALSE, alphaL = c(0, 1), betaL = alphaL, gammaL = alphaL, phiL = c(0.8, 0.98), p0 = -99999, Ymin = -Inf, Ymax = Inf )TETS( y, u = NULL, model = "???", s = frequency(y), h = 2 * s, criterion = "aicc", forIntervals = FALSE, bootstrap = FALSE, nSimul = 5000, verbose = FALSE, alphaL = c(0, 1), betaL = alphaL, gammaL = alphaL, phiL = c(0.8, 0.98), p0 = -99999, Ymin = -Inf, Ymax = Inf )
y |
a time series to forecast (it may be either a numerical vector or
a time series object). This is the only input required. If a vector, the additional
input |
u |
a matrix of input time series. If
the output wanted to be forecast, matrix |
model |
the model to estimate. It is a single string indicating the type of model for each component with one or two letters:
|
s |
seasonal period of time series (1 for annual, 4 for quarterly, ...) |
h |
forecast horizon. If the model includes inputs h is not used, the lenght of u is used instead. |
criterion |
information criterion for identification ("aic", "bic" or "aicc"). |
forIntervals |
estimate forecasting intervals (TRUE / FALSE) |
bootstrap |
use bootstrap simulation for predictive distributions |
nSimul |
number of simulation runs for bootstrap simulation of predictive distributions |
verbose |
intermediate estimation output (TRUE / FALSE) |
alphaL |
constraints limits for alpha parameter |
betaL |
constraints limits for beta parameter |
gammaL |
constraints limits for gamma parameter |
phiL |
constraints limits for phi parameter |
p0 |
initial values for parameter search (alpha, beta, phi, gamma, sigma2) with consraints: |
Ymin |
scalar or vector of time varying censoring values from below |
Ymax |
scalar or vector of time varying censoring values from above
|
See help of TETSforecast.
An object of class TETS. It is a list with fields including all the inputs and
the fields listed below as outputs. All the functions in this package fill in
part of the fields of any TETS object as specified in what follows (function
TETS fills in all of them at once):
After running TETSforecast:
p |
Estimated parameters |
criteria |
Values for estimation criteria (LogLik, AIC, BIC, AICc) |
yFor |
Forecasted values of output |
yForV |
Variance of forecasted values of output |
ySimul |
Bootstrap simulations for forecasting distribution evaluation |
After running TETSvalidate:
table |
Estimation and validation table |
comp |
Estimated components in matrix form |
After running TETScomponents:
comp |
Estimated components in matrix form |
Diego J. Pedregal
TETSforecast, TETSvalidate,
TETScomponents
y <- log(AirPassengers) m1 <- TETS(y) m1 <- TETS(y, model = "MAM")y <- log(AirPassengers) m1 <- TETS(y) m1 <- TETS(y, model = "MAM")
Estimates components of TOBIT TETS models
TETScomponents(m)TETScomponents(m)
m |
an object of type |
The same input object with the appropriate fields filled in, in particular:
comp |
Estimated components in matrix form |
Diego J. Pedregal
TETS, TETSforecast, TETSvalidate
m1 <- TETS(log(gdp)) m1 <- TETScomponents(m1)m1 <- TETS(log(gdp)) m1 <- TETScomponents(m1)
Estimates and forecasts TOBIT TETS models
TETSestim(m)TETSestim(m)
m |
an object of type |
TETSestim estimates and forecasts a time series using an
a TOBIT TETS model
The same input object with the appropriate fields filled in, in particular:
p |
Estimated parameters |
yFor |
Forecasted values of output |
yForV |
Variance of forecasted values of output |
ySimul |
Bootstrap simulations for forecasting distribution evaluation |
Diego J. Pedregal
TETS, TETSforecast, TETSvalidate,
TETScomponents
m1 <- TETSsetup(log(gdp)) m1 <- TETSestim(m1)m1 <- TETSsetup(log(gdp)) m1 <- TETSestim(m1)
Estimates and forecasts TOBIT TETS general univariate models
TETSforecast( y, u = NULL, model = "???", s = frequency(y), h = max(2 * s, 6), criterion = "aicc", forIntervals = FALSE, bootstrap = FALSE, nSimul = 5000, verbose = FALSE, alphaL = c(0, 1), betaL = alphaL, gammaL = alphaL, phiL = c(0.8, 0.98), p0 = -99999, Ymin = -Inf, Ymax = Inf )TETSforecast( y, u = NULL, model = "???", s = frequency(y), h = max(2 * s, 6), criterion = "aicc", forIntervals = FALSE, bootstrap = FALSE, nSimul = 5000, verbose = FALSE, alphaL = c(0, 1), betaL = alphaL, gammaL = alphaL, phiL = c(0.8, 0.98), p0 = -99999, Ymin = -Inf, Ymax = Inf )
y |
a time series to forecast (it may be either a numerical vector or
a time series object). This is the only input required. If a vector, the additional
input |
u |
a matrix of input time series. If
the output wanted to be forecast, matrix |
model |
the model to estimate. It is a single string indicating the type of model for each component with one or two letters:
|
s |
seasonal period of time series (1 for annual, 4 for quarterly, ...) |
h |
forecast horizon. If the model includes inputs h is not used, the lenght of u is used instead. |
criterion |
information criterion for identification ("aic", "bic" or "aicc"). |
forIntervals |
estimate forecasting intervals (TRUE / FALSE) |
bootstrap |
use bootstrap simulation for predictive distributions |
nSimul |
number of simulation runs for bootstrap simulation of predictive distributions |
verbose |
intermediate estimation output (TRUE / FALSE) |
alphaL |
constraints limits for alpha parameter |
betaL |
constraints limits for beta parameter |
gammaL |
constraints limits for gamma parameter |
phiL |
constraints limits for phi parameter |
p0 |
initial values for parameter search (alpha, beta, phi, gamma, sigma2) with consraints: |
Ymin |
scalar or vector of time varying censoring values from below |
Ymax |
scalar or vector of time varying censoring values from above
|
TETSforecast is a function for modelling and forecasting univariate
time series with TOBIT ExponenTial Smoothing (TETS) time series models.
It sets up the model with a number of control variables that
govern the way the rest of functions in the package will work. It also estimates
the model parameters by Maximum Likelihood and forecasts the data.
An object of class TETS. It is a list with fields including all the inputs and
the fields listed below as outputs. All the functions in this package fill in
part of the fields of any TETS object as specified in what follows (function
TETS fills in all of them at once):
After running TETSforecast:
p |
Estimated parameters |
criteria |
Values for estimation criteria (LogLik, AIC, BIC, AICc) |
yFor |
Forecasted values of output |
yForV |
Variance of forecasted values of output |
ySimul |
Bootstrap simulations for forecasting distribution evaluation |
After running TETSvalidate:
table |
Estimation and validation table |
comp |
Estimated components in matrix form |
After running TETScomponents:
comp |
Estimated components in matrix form |
Diego J. Pedregal
TETS, TETSvalidate,
TETScomponents
y <- log(AirPassengers) m1 <- TETSforecast(y) m1 <- TETSforecast(y, model = "A?A")y <- log(AirPassengers) m1 <- TETSforecast(y) m1 <- TETSforecast(y, model = "A?A")
Sets up TOBIT TETS general univariate models
TETSsetup( y, u = NULL, model = "???", s = frequency(y), h = 2 * s, criterion = "aicc", forIntervals = FALSE, bootstrap = FALSE, nSimul = 5000, verbose = FALSE, alphaL = c(0, 1), betaL = alphaL, gammaL = alphaL, phiL = c(0.8, 0.98), p0 = -99999, Ymin = -Inf, Ymax = Inf )TETSsetup( y, u = NULL, model = "???", s = frequency(y), h = 2 * s, criterion = "aicc", forIntervals = FALSE, bootstrap = FALSE, nSimul = 5000, verbose = FALSE, alphaL = c(0, 1), betaL = alphaL, gammaL = alphaL, phiL = c(0.8, 0.98), p0 = -99999, Ymin = -Inf, Ymax = Inf )
y |
a time series to forecast (it may be either a numerical vector or
a time series object). This is the only input required. If a vector, the additional
input |
u |
a matrix of input time series. If
the output wanted to be forecast, matrix |
model |
the model to estimate. It is a single string indicating the type of model for each component with one or two letters:
|
s |
seasonal period of time series (1 for annual, 4 for quarterly, ...) |
h |
forecast horizon. If the model includes inputs h is not used, the lenght of u is used instead. |
criterion |
information criterion for identification ("aic", "bic" or "aicc"). |
forIntervals |
estimate forecasting intervals (TRUE / FALSE) |
bootstrap |
use bootstrap simulation for predictive distributions |
nSimul |
number of simulation runs for bootstrap simulation of predictive distributions |
verbose |
intermediate estimation output (TRUE / FALSE) |
alphaL |
constraints limits for alpha parameter |
betaL |
constraints limits for beta parameter |
gammaL |
constraints limits for gamma parameter |
phiL |
constraints limits for phi parameter |
p0 |
initial values for parameter search (alpha, beta, phi, gamma, sigma2) with consraints: |
Ymin |
scalar or vector of time varying censoring values from below |
Ymax |
scalar or vector of time varying censoring values from above
|
See help of TETSforecast.
An object of class TETS. It is a list with fields including all the inputs and
the fields listed below as outputs. All the functions in this package fill in
part of the fields of any TETS object as specified in what follows (function
TETS fills in all of them at once):
After running TETSforecast:
p |
Estimated parameters |
criteria |
Values for estimation criteria (LogLik, AIC, BIC, AICc) |
yFor |
Forecasted values of output |
yForV |
Variance of forecasted values of output |
ySimul |
Bootstrap simulations for forecasting distribution evaluation |
After running TETSvalidate:
table |
Estimation and validation table |
comp |
Estimated components in matrix form |
After running TETScomponents:
comp |
Estimated components in matrix form |
Diego J. Pedregal
TETS, TETSforecast, TETSvalidate,
TETScomponents
y <- log(AirPassengers) m1 <- TETSsetup(y) m1 <- TETSsetup(y, model = "???") m1 <- TETSsetup(y, model = "?AA")y <- log(AirPassengers) m1 <- TETSsetup(y) m1 <- TETSsetup(y, model = "???") m1 <- TETSsetup(y, model = "?AA")
Shows a table of estimation and diagnostics results for TOBIT TETS models
TETSvalidate(m)TETSvalidate(m)
m |
an object of type |
The same input object with the appropriate fields filled in, in particular:
table |
Estimation and validation table |
Diego J. Pedregal
TETS, TETSforecast, TETSvalidate,
TETScomponents
m1 <- TETSforecast(log(gdp)) m1 <- TETSvalidate(m1)m1 <- TETSforecast(log(gdp)) m1 <- TETSvalidate(m1)
Displays time series plot with autocorrelation functions
tsDisplay(y, nCoef = 25, nPar = 0, s = NA)tsDisplay(y, nCoef = 25, nPar = 0, s = NA)
y |
a vector, ts or tsibble object |
nCoef |
number of autocorrelation coefficients to estimate |
nPar |
number of parameters in a model if y is a residual |
s |
seasonal period, number of observations per year |
No return value, called for side effects
Diego J. Pedregal
colMedians, rowMedians, tests,
sumStats, gaussTest, ident,
cusum, varTest, conv,
armaFilter, dif, roots,
zplane, acft, slide,
plotSlide, Accuracy,
size
tsDisplay(AirPassengers)tsDisplay(AirPassengers)
Runs all relevant functions for UC modelling
UC( y, u = NULL, model = "?/none/?/?", h = 24, lambda = 1, outlier = 9999, tTest = FALSE, criterion = "aic", periods = NA, verbose = FALSE, stepwise = FALSE, p0 = -9999.9, arma = FALSE, TVP = NULL, trendOptions = "none/rw/llt/dt", seasonalOptions = "none/equal/different", irregularOptions = "none/arma(0,0)" )UC( y, u = NULL, model = "?/none/?/?", h = 24, lambda = 1, outlier = 9999, tTest = FALSE, criterion = "aic", periods = NA, verbose = FALSE, stepwise = FALSE, p0 = -9999.9, arma = FALSE, TVP = NULL, trendOptions = "none/rw/llt/dt", seasonalOptions = "none/equal/different", irregularOptions = "none/arma(0,0)" )
y |
a time series to forecast (it may be either a numerical vector or
a time series object). This is the only input required. If a vector, the additional
input |
u |
a matrix of external regressors included only in the observation equation.
(it may be either a numerical vector or a time series object). If the output wanted
to be forecast, matrix |
model |
the model to estimate. It is a single string indicating the type of model for each component. It allows two formats "trend/seasonal/irregular" or "trend/cycle/seasonal/irregular". The possibilities available for each component are:
|
h |
forecast horizon. If the model includes inputs h is not used, the lenght of u is used instead. |
lambda |
Box-Cox transformation lambda, NULL for automatic estimation |
outlier |
critical level of outlier tests. If NA it does not carry out any outlier detection (default). A positive value indicates the critical minimum t test for outlier detection in any model during identification. Three types of outliers are identified, namely Additive Outliers (AO), Level Shifts (LS) and Slope Change (SC). |
tTest |
augmented Dickey Fuller test for unit roots used in stepwise algorithm (TRUE / FALSE). The number of models to search for is reduced, depending on the result of this test. |
criterion |
information criterion for identification ("aic", "bic" or "aicc"). |
periods |
vector of fundamental period and harmonics required. |
verbose |
intermediate results shown about progress of estimation (TRUE / FALSE). |
stepwise |
stepwise identification procedure (TRUE / FALSE). |
p0 |
initial parameter vector for optimisation search. |
arma |
check for arma models for irregular components (TRUE / FALSE). |
TVP |
vector of zeros and ones to indicate TVP parameters. |
trendOptions |
trend models to select amongst (e.g., "rw/llt"). |
seasonalOptions |
seasonal models to select amongst (e.g., "none/differentt"). |
irregularOptions |
irregular models to select amongst (e.g., "none/arma(0,1)"). |
UC is a function for modelling and forecasting univariate
time series according to Unobserved Components models (UC).
It sets up the model with a number of control variables that
govern the way the rest of functions in the package work. It also estimates
the model parameters by Maximum Likelihood, forecasts the data, performs smoothing,
estimates model disturbances, estimates components and shows statistical diagnostics.
Standard methods applicable to UComp objects are print, summary, plot,
fitted, residuals, logLik, AIC, BIC, coef, predict, tsdiag.
An object of class UComp. It is a list with fields including all the inputs and
the fields listed below as outputs. All the functions in this package fill in
part of the fields of any UComp object as specified in what follows (function
UC fills in all of them at once):
After running UCforecast or UCestim:
p: Estimated parameters
v: Estimated innovations (white noise in correctly specified models)
yFor: Forecasted values of output
yForV: Forecasted values +- one standard error
criteria: Value of criteria for estimated model
iter: Number of iterations in estimation
grad: Gradient at estimated parameters
covp: Covariance matrix of parameters
After running UCvalidate:
table: Estimation and validation table
After running UCcomponents:
comp: Estimated components in matrix form
compV: Estimated components variance in matrix form
After running UCfilter, UCsmooth or UCdisturb:
yFit: Fitted values of output
yFitV: Variance of fitted values of output
a: State estimates
P: Variance of state estimates
aFor: Forecasts of states
PFor: Forecasts of states variances
After running UCdisturb:
eta: State perturbations estimates
eps: Observed perturbations estimates
Diego J. Pedregal
UC, UCvalidate, UCfilter, UCsmooth,
UCdisturb, UCcomponents,
UChp
y <- log(AirPassengers) m1 <- UC(y) m1 <- UC(y, model = "llt/different/arma(0,0)")y <- log(AirPassengers) m1 <- UC(y) m1 <- UC(y, model = "llt/different/arma(0,0)")
Auxiliar function for UC modeling
UCcommand(command, sys)UCcommand(command, sys)
command |
Command to execute: "forecast", "validate", "filter", "smooth", "disturb", "components", "all" |
sys |
A |
The input UComp object with the appropriate fields filled in
Diego J. Pedregal
UC, UCforecast, UCvalidate, UCfilter,
UCsmooth, UCcomponents, UCdisturb
cycle <- UChp(USgdp) plot(cycle)cycle <- UChp(USgdp) plot(cycle)
Estimates unobserved components of UC models Standard methods applicable to UComp objects are print, summary, plot, fitted, residuals, logLik, AIC, BIC, coef, predict, tsdiag.
UCcomponents(sys)UCcomponents(sys)
sys |
an object of type |
The same input object with the appropriate fields filled in, in particular:
comp: Estimated components in matrix form
compV: Estimated components variance in matrix form
Diego J. Pedregal
UC, UCforecast, UCvalidate, UCfilter,
UCsmooth, UCdisturb,
UChp
m1 <- UC(log(AirPassengers)) m1 <- UCcomponents(m1)m1 <- UC(log(AirPassengers)) m1 <- UCcomponents(m1)
Runs the Disturbance Smoother for UC models
Standard methods applicable to UComp objects are print, summary, plot,
fitted, residuals, logLik, AIC, BIC, coef, predict, tsdiag.
UCdisturb(sys)UCdisturb(sys)
sys |
an object of type |
The same input object with the appropriate fields filled in, in particular:
yFit: Fitted values of output
yFitV: Variance of fitted values of output
a: State estimates
P: Variance of state estimates (diagonal of covariance matrices)
eta: State perturbations estimates
eps: Observed perturbations estimates
Diego J. Pedregal
UC, UCforecast, UCvalidate, UCfilter,
UCsmooth, UCcomponents,
UChp
m1 <- UC(log(AirPassengers)) m1 <- UCdisturb(m1)m1 <- UC(log(AirPassengers)) m1 <- UCdisturb(m1)
Estimates and forecasts UC models
UCestim(sys)UCestim(sys)
sys |
an object of type |
UCestim estimates and forecasts a time series using an
UC model.
The optimization method is a BFGS quasi-Newton algorithm with a
backtracking line search using Armijo conditions.
Parameter names in output table are the following:
Damping: Damping factor for DT trend.
Level: Variance of level disturbance.
Slope: Variance of slope disturbance.
Rho(#): Damping factor of cycle #.
Period(#): Estimated period of cycle #.
Var(#): Variance of cycle #.
Seas(#): Seasonal harmonic with period #.
Irregular: Variance of irregular component.
AR(#): AR parameter of lag #.
MA(#): MA parameter of lag #.
AO#: Additive outlier in observation #.
LS#: Level shift outlier in observation #.
SC#: Slope change outlier in observation #.
Beta(#): Beta parameter of input #.
Cnst: Constant.
Standard methods applicable to UComp objects are print, summary, plot, fitted, residuals, logLik, AIC, BIC, coef, predict, tsdiag.
The same input object with the appropriate fields filled in, in particular:
p: Estimated transformed parameters
v: Estimated innovations (white noise in correctly specified models)
yFor: Forecast values of output
yForV: Forecasted values variance
criteria: Value of criteria for estimated model
covp: Covariance matrix of estimated transformed parameters
grad: Gradient of log-likelihood at the optimum
iter: Estimation iterations
Diego J. Pedregal
UC, UCforecast, UCvalidate, UCfilter,
UCsmooth, UCdisturb, UCcomponents,
UChp
m1 <- UCsetup(log(AirPassengers)) m1 <- UCestim(m1)m1 <- UCsetup(log(AirPassengers)) m1 <- UCestim(m1)
Runs the Kalman Filter for UC models
Standard methods applicable to UComp objects are print, summary, plot,
fitted, residuals, logLik, AIC, BIC, coef, predict, tsdiag.
UCfilter(sys)UCfilter(sys)
sys |
an object of type |
The same input object with the appropriate fields filled in, in particular:
yFit: Fitted values of output
yFitV: Variance of fitted values of output
a: State estimates
P: Variance of state estimates (diagonal of covariance matrices)
Diego J. Pedregal
UC, UCforecast, UCvalidate,
UCsmooth, UCdisturb, UCcomponents,
UChp
m1 <- UC(log(AirPassengers)) m1 <- UCfilter(m1)m1 <- UC(log(AirPassengers)) m1 <- UCfilter(m1)
Estimates and forecasts UC general univariate models
UCforecast( y, u = NULL, model = "?/none/?/?", h = 24, lambda = 1, outlier = 9999, tTest = FALSE, criterion = "aic", periods = NA, verbose = FALSE, stepwise = FALSE, p0 = -9999.9, arma = FALSE, TVP = NULL, trendOptions = "none/rw/llt/dt", seasonalOptions = "none/equal/different", irregularOptions = "none/arma(0,0)" )UCforecast( y, u = NULL, model = "?/none/?/?", h = 24, lambda = 1, outlier = 9999, tTest = FALSE, criterion = "aic", periods = NA, verbose = FALSE, stepwise = FALSE, p0 = -9999.9, arma = FALSE, TVP = NULL, trendOptions = "none/rw/llt/dt", seasonalOptions = "none/equal/different", irregularOptions = "none/arma(0,0)" )
y |
a time series to forecast (it may be either a numerical vector or
a time series object). This is the only input required. If a vector, the additional
input |
u |
a matrix of external regressors included only in the observation equation.
(it may be either a numerical vector or a time series object). If the output wanted
to be forecast, matrix |
model |
the model to estimate. It is a single string indicating the type of model for each component. It allows two formats "trend/seasonal/irregular" or "trend/cycle/seasonal/irregular". The possibilities available for each component are:
|
h |
forecast horizon. If the model includes inputs h is not used, the lenght of u is used instead. |
lambda |
Box-Cox transformation lambda, NULL for automatic estimation |
outlier |
critical level of outlier tests. If NA it does not carry out any outlier detection (default). A positive value indicates the critical minimum t test for outlier detection in any model during identification. Three types of outliers are identified, namely Additive Outliers (AO), Level Shifts (LS) and Slope Change (SC). |
tTest |
augmented Dickey Fuller test for unit roots used in stepwise algorithm (TRUE / FALSE). The number of models to search for is reduced, depending on the result of this test. |
criterion |
information criterion for identification ("aic", "bic" or "aicc"). |
periods |
vector of fundamental period and harmonics required. |
verbose |
intermediate results shown about progress of estimation (TRUE / FALSE). |
stepwise |
stepwise identification procedure (TRUE / FALSE). |
p0 |
initial parameter vector for optimisation search. |
arma |
check for arma models for irregular components (TRUE / FALSE). |
TVP |
vector of zeros and ones to indicate TVP parameters. |
trendOptions |
trend models to select amongst (e.g., "rw/llt"). |
seasonalOptions |
seasonal models to select amongst (e.g., "none/differentt"). |
irregularOptions |
irregular models to select amongst (e.g., "none/arma(0,1)"). |
UCforecast is a function for modelling and forecasting univariate
time series according to Unobserved Components models (UC).
It sets up the model with a number of control variables that
govern the way the rest of functions in the package work. It also estimates
the model parameters by Maximum Likelihood and forecasts the data.
Standard methods applicable to UComp objects are print, summary, plot,
fitted, residuals, logLik, AIC, BIC, coef, predict, tsdiag.
An object of class UComp. It is a list with fields including all the inputs and
the fields listed below as outputs. All the functions in this package fill in
part of the fields of any UComp object as specified in what follows (function
UC fills in all of them at once):
After running UCforecast:
p: Estimated parameters
v: Estimated innovations (white noise in correctly specified models)
yFor: Forecasted values of output
yForV: Forecasted values +- one standard error
criteria: Value of criteria for estimated model
iter: Number of iterations in estimation
grad: Gradient at estimated parameters
covp: Covariance matrix of parameters
After running UCvalidate:
table: Estimation and validation table
After running UCcomponents:
comp: Estimated components in matrix form
compV: Estimated components variance in matrix form
After running UCfilter, UCsmooth or UCdisturb:
yFit: Fitted values of output
yFitV: Variance of fitted values of output
a: State estimates
P: Variance of state estimates
aFor: Forecasts of states
PFor: Forecasts of states variances
After running UCdisturb:
eta: State perturbations estimates
eps: Observed perturbations estimates
Diego J. Pedregal
UC, UCvalidate, UCfilter, UCsmooth,
UCdisturb, UCcomponents,
UChp
y <- log(AirPassengers) m1 <- UCforecast(y) m1 <- UCforecast(y, model = "llt/equal/arma(0,0)")y <- log(AirPassengers) m1 <- UCforecast(y) m1 <- UCforecast(y, model = "llt/equal/arma(0,0)")
Hodrick-Prescott filter estimation
UChp(y, lambda = 1600)UChp(y, lambda = 1600)
y |
A time series object |
lambda |
Smoothing constant (default: 1600) |
The cycle estimation
Diego J. Pedregal
UC, UCforecast, UCvalidate, UCfilter,
UCsmooth, UCcomponents, UCdisturb
cycle <- UChp(USgdp) plot(cycle)cycle <- UChp(USgdp) plot(cycle)
Package for time series modelling and forecasting of times series models inspired on different sources:
Unobserved Components models due to A.C. Harvey (Basic Structural Model: BSM), enhanced with automatic identification tools by Diego J. Pedregal.
ExponenTial Smoothing by R.J. Hyndman and colaborators.
ARIMA models by V. Gómez and A. Maravall
Tobit ETS models by Pedregal, Trapero and Holgado
The package is designed for automatic identification among a wide range of possible models. The models may include exogenous variables. ARMA irregular components and automatic detection of outliers in some instances.
Harvey AC (1989). Forecasting, Structural Time Series Models and the Kalman Filter. Cam- bridge University Press.
de Jong, P & Penzer, J (1998). Diagnosing Shocks in Time Series, Journal of the American Statistical Association, 93, 442, 796-806.
Pedregal, DJ, & Young, PC (2002). Statistical approaches to modelling and forecasting time series. In M. Clements, & D. Hendry (Eds.), Companion to economic forecasting (pp. 69–104). Oxford: Blackwell Publishers.
Durbin J, Koopman SJ (2012). Time Series Analysis by State Space Methods. 38. Oxford University Press.
Proietti T and Luati A (2013). Maximum likelihood estimation of time series models: the Kalman filter and beyond, in Handbook of research methods and applications in empirical macroeconomics, ed. Nigar Hashimzade and Michael Thornton, E. Elgar, UK.
Hyndman RJ, Koehler AB, Ord JK and Snyder RD (2008), Forecasting with exponential smoothing, The State Sapce approach, Berlin, Springer-Verlag.
Gómez V and Maravall, A (2000), Automatic methods for univariate series. In Peña, D., Tiao, G.C. and Tsay R.S., A course in time series analyis. Wiley.
Trapero JR, Holgado E, Pedregal DJ (2024), Demand forecasting under lost sales stock policies, International Journal of Forecasting, 40, 1055-1068.
Diego J. Pedregal
Diego J. Pedregal
Sets up UC general univariate models
UCsetup( y, u = NULL, model = "?/none/?/?", h = 24, lambda = 1, outlier = 9999, tTest = FALSE, criterion = "aic", periods = NA, verbose = FALSE, stepwise = FALSE, p0 = -9999.9, arma = FALSE, TVP = NULL, trendOptions = "none/rw/llt/dt", seasonalOptions = "none/equal/different", irregularOptions = "none/arma(0,0)" )UCsetup( y, u = NULL, model = "?/none/?/?", h = 24, lambda = 1, outlier = 9999, tTest = FALSE, criterion = "aic", periods = NA, verbose = FALSE, stepwise = FALSE, p0 = -9999.9, arma = FALSE, TVP = NULL, trendOptions = "none/rw/llt/dt", seasonalOptions = "none/equal/different", irregularOptions = "none/arma(0,0)" )
y |
a time series to forecast (it may be either a numerical vector or
a time series object). This is the only input required. If a vector, the additional
input |
u |
a matrix of external regressors included only in the observation equation.
(it may be either a numerical vector or a time series object). If the output wanted
to be forecast, matrix |
model |
the model to estimate. It is a single string indicating the type of model for each component. It allows two formats "trend/seasonal/irregular" or "trend/cycle/seasonal/irregular". The possibilities available for each component are:
|
h |
forecast horizon. If the model includes inputs h is not used, the lenght of u is used instead. |
lambda |
Box-Cox transformation lambda, NULL for automatic estimation |
outlier |
critical level of outlier tests. If NA it does not carry out any outlier detection (default). A positive value indicates the critical minimum t test for outlier detection in any model during identification. Three types of outliers are identified, namely Additive Outliers (AO), Level Shifts (LS) and Slope Change (SC). |
tTest |
augmented Dickey Fuller test for unit roots used in stepwise algorithm (TRUE / FALSE). The number of models to search for is reduced, depending on the result of this test. |
criterion |
information criterion for identification ("aic", "bic" or "aicc"). |
periods |
vector of fundamental period and harmonics required. |
verbose |
intermediate results shown about progress of estimation (TRUE / FALSE). |
stepwise |
stepwise identification procedure (TRUE / FALSE). |
p0 |
initial parameter vector for optimisation search. |
arma |
check for arma models for irregular components (TRUE / FALSE). |
TVP |
vector of zeros and ones to indicate TVP parameters. |
trendOptions |
trend models to select amongst (e.g., "rw/llt"). |
seasonalOptions |
seasonal models to select amongst (e.g., "none/differentt"). |
irregularOptions |
irregular models to select amongst (e.g., "none/arma(0,1)"). |
See help of UC.
An object of class UComp. It is a list with fields including all the inputs and
the fields listed below as outputs. All the functions in this package fill in
part of the fields of any UComp object as specified in what follows (function
UC fills in all of them at once):
After running UCforecast:
p: Estimated parameters
v: Estimated innovations (white noise in correctly specified models)
yFor: Forecasted values of output
yForV: Variance of forecasts
criteria: Value of criteria for estimated model
iter: Number of iterations in estimation
grad: Gradient at estimated parameters
covp: Covariance matrix of parameters
After running UCvalidate:
table: Estimation and validation table
After running UCcomponents:
comp: Estimated components in matrix form
compV: Estimated components variance in matrix form
After running UCfilter, UCsmooth or UCdisturb:
yFit: Fitted values of output
yFitV: Estimated fitted values variance
a: State estimates
P: Variance of state estimates
aFor: Forecasts of states
PFor: Forecasts of states variances
After running UCdisturb:
eta: State perturbations estimates
eps: Observed perturbations estimates
Standard methods applicable to UComp objects are print, summary, plot, fitted, residuals, logLik, AIC, BIC, coef, predict, tsdiag.
Diego J. Pedregal
UC, UCforecast, UCvalidate, UCfilter, UCsmooth,
UCdisturb, UCcomponents,
UChp
y <- log(AirPassengers) m1 <- UCsetup(y) m1 <- UCsetup(y, outlier = 4) m1 <- UCsetup(y, model = "llt/equal/arma(0,0)") m1 <- UCsetup(y, model = "?/?/?/?") m1 <- UCsetup(y, model = "llt/?/equal/?", outlier = 4)y <- log(AirPassengers) m1 <- UCsetup(y) m1 <- UCsetup(y, outlier = 4) m1 <- UCsetup(y, model = "llt/equal/arma(0,0)") m1 <- UCsetup(y, model = "?/?/?/?") m1 <- UCsetup(y, model = "llt/?/equal/?", outlier = 4)
Runs the Fixed Interval Smoother for UC models
Standard methods applicable to UComp objects are print, summary, plot,
fitted, residuals, logLik, AIC, BIC, coef, predict, tsdiag.
UCsmooth(sys)UCsmooth(sys)
sys |
an object of type |
The same input object with the appropriate fields filled in, in particular:
yFit: Fitted values of output
yFitV: Variance of fitted values of output
a: State estimates
P: Variance of state estimates (diagonal of covariance matrices)
Diego J. Pedregal
UC, UCforecast, UCvalidate, UCfilter,
UCdisturb, UCcomponents,
UChp
m1 <- UC(log(AirPassengers)) m1 <- UCsmooth(m1)m1 <- UC(log(AirPassengers)) m1 <- UCsmooth(m1)
Shows a table of estimation and diagnostics results for UC models. Equivalent to print or summary. The table shows information in four sections: Firstly, information about the model estimated, the relevant periods of the seasonal component included, and further information about convergence. Secondly, parameters with their names are provided, the asymptotic standard errors, the ratio of the two, and the gradient at the optimum. One asterisk indicates concentrated-out parameters and two asterisks signals parameters constrained during estimation. Thirdly, information criteria and the value of the log-likelihood. Finally, diagnostic statistics about innovations, namely, the Ljung-Box Q test of absense of autocorrelation statistic for several lags, the Jarque-Bera gaussianity test, and a standard ratio of variances test.
UCvalidate(sys, printScreen = TRUE)UCvalidate(sys, printScreen = TRUE)
sys |
an object of type |
printScreen |
print to screen or just return output table |
The same input object with the appropriate fields filled in, in particular:
table: Estimation and validation table
Diego J. Pedregal
UC, UCforecast, UCfilter,
UCsmooth, UCdisturb, UCcomponents,
UChp
m1 <- UC(log(gdp)) m1 <- UCvalidate(m1)m1 <- UC(log(gdp)) m1 <- UCvalidate(m1)
Ratio of variances test
varTest(y, parts = 1/3)varTest(y, parts = 1/3)
y |
a vector, ts or tsibble object |
parts |
portion of sample to estimate variances |
Table with test results
Diego J. Pedregal
colMedians, rowMedians, tests,
sumStats, gaussTest, ident,
cusum, conv,
armaFilter, dif, roots,
zplane, acft, slide,
plotSlide, Accuracy, tsDisplay,
size
varTest(AirPassengers)varTest(AirPassengers)
Estimates and forecasts weekly time series with monthly and annual seasonal patterns
WEEKforecast( y, u = NULL, initial_date, h = 24, lambda = 1, criterion = "aic", p0 = -9999.9, verbose = FALSE )WEEKforecast( y, u = NULL, initial_date, h = 24, lambda = 1, criterion = "aic", p0 = -9999.9, verbose = FALSE )
y |
A numeric vector, |
u |
Optional matrix or vector of exogenous regressors. If provided, it must cover both the estimation and forecast periods. |
initial_date |
A character or |
h |
Integer indicating the forecast horizon (number of weeks ahead). |
lambda |
Box–Cox transformation parameter. |
criterion |
Information criterion used for model selection (AIC, BIC or AICc). |
p0 |
Initial parameter vector for Maximum Likelihood estimation. |
verbose |
if |
WEEKforecast estimates and forecasts univariate weekly time series using
Dynamic Harmonic Regression (DHR).
The function is designed for weekly data but builds the seasonal structure from underlying daily calendar information. In particular, it incorporates:
Monthly seasonality via harmonic terms derived from calendar months
Annual seasonality via multiple harmonic components based on calendar years
Standard methods applicable to UComp objects are available.
An object of class UComp. It is a list containing the model specification,
estimated parameters, and forecasting results.
Diego J. Pedregal
UC, UCforecast, UCfilter,
UCsmooth, UCdisturb,
UCcomponents
y <- rnorm(400) m <- WEEKforecast(y, initial_date = "2015-01-01", h = 12)y <- rnorm(400) m <- WEEKforecast(y, initial_date = "2015-01-01", h = 12)
Real-imaginary plane to show roots of digital filters (ARMA)
zplane(MApoly = 1, ARpoly = 1)zplane(MApoly = 1, ARpoly = 1)
MApoly |
coefficients of numerator polynomial in descending order |
ARpoly |
coefficients of denominator polynomial in descending order |
Shows the real-imaginary plane to show zeros (roots of numerator or MA polynomial) and poles (roots of denominator of AR polynomial). Unit roots and real vs imaginary roots can be seen by eye
No return value, called for side effects
Diego J. Pedregal
colMedians, rowMedians, tests,
sumStats, gaussTest, ident,
cusum, varTest, conv,
armaFilter, dif, roots,
acft, slide,
plotSlide, Accuracy, tsDisplay,
size
zplane(c(1, -2, 1), c(1, -0.8))zplane(c(1, -2, 1), c(1, -0.8))