Title: | Transfer Function and ARIMA Models |
---|---|
Description: | Building customized transfer function and ARIMA models with multiple operators and parameter restrictions. Functions for model identification, model estimation (exact or conditional maximum likelihood), model diagnostic checking, automatic outlier detection, calendar effects, forecasting and seasonal adjustment. See Bell and Hillmer (1983) <doi:10.1080/01621459.1983.10478005>, Box, Jenkins, Reinsel and Ljung <ISBN:978-1-118-67502-1>, Box, Pierce and Newbold (1987) <doi:10.1080/01621459.1987.10478430>, Box and Tiao (1975) <doi:10.1080/01621459.1975.10480264>, Chen and Liu (1993) <doi:10.1080/01621459.1993.10594321>. |
Authors: | Jose L. Gallego [aut, cre] |
Maintainer: | Jose L. Gallego <[email protected]> |
License: | GPL-2 |
Version: | 0.3.2 |
Built: | 2024-11-01 11:28:15 UTC |
Source: | CRAN |
The tfarima package provides classes and methods to build customized transfer function and ARIMA models with multiple operators and parameter restrictions. The package also includes functions for model identification, model estimation (exact or conditional maximum likelihood), model diagnostic checking, automatic outlier detection, calendar effects, forecasting and seasonal adjustment.
Jose Luis Gallego [email protected]
Bell, W.R. and Hillmer, S.C. (1983) Modeling Time Series with Calendar Variation, Journal of the American Statistical Association, Vol. 78, No. 383, pp. 526-534.
Box, G.E., Jenkins, G.M., Reinsel, G.C. and Ljung, G.M. (2015) Time Series Analysis: Forecasting and Control. John Wiley & Sons, Hoboken.
Box, G.E.P., Pierce, D.A. and Newbold, D. A. (1987) Estimating Trend and Growth Rates in Seasonal Time Series, Journal of the American Statistical Association, Vol. 82, No. 397, pp. 276-282.
Box, G.E.P. and Tiao, G.C. (1975) “Intervention Analysis with Applications to Economic and Environmental Problems”, Journal of the American Statistical Association, Vol. 70, No. 349, pp. 70-79.
Chen, C. and Liu, L. (1993) Joint Estimation of Model Parameters and Outlier Effects in Time Series, Journal of the American Statistical Association, Vol. 88, No. 421, pp. 284-297
Thompson, H. E. and Tiao, G. C. (1971) "Analysis of Telephone Data: A Case Study of Forecasting Seasonal Time Series," Bell Journal of Economics, The RAND Corporation, vol. 2(2), pages 515-541, Autumn.
as.lagpol
converts a numeric vector c(1, -a_1, ..., -a_d) into
a lag polynomial .
as.lagpol(pol, p = 1)
as.lagpol(pol, p = 1)
pol |
a numeric vector. |
p |
integer power. |
An object of class lagpol
.
as.lagpol(c(1, -0.8)) as.lagpol(c(1, 0, 0, 0, -0.8))
as.lagpol(c(1, -0.8)) as.lagpol(c(1, 0, 0, 0, -0.8))
arima
into um
.as.um
converts an object of class arima
into an object
of class um
.
as.um(arima)
as.um(arima)
arima |
an object of class |
An object of class um
.
z <- AirPassengers a <- arima(log(z), order = c(0,1,1), seasonal = list(order = c(0,1,1), frequency = 12)) um1 <- as.um(a)
z <- AirPassengers a <- arima(log(z), order = c(0,1,1), seasonal = list(order = c(0,1,1), frequency = 12)) um1 <- as.um(a)
autocorr
computes the simple/partial autocorrelations of an ARMA model.
autocorr(um, ...) ## S3 method for class 'um' autocorr(um, lag.max = 10, par = FALSE, ...)
autocorr(um, ...) ## S3 method for class 'um' autocorr(um, lag.max = 10, par = FALSE, ...)
um |
an object of class |
... |
additional arguments. |
lag.max |
maximum lag for autocovariances. |
par |
logical. If TRUE partial autocorrelations are computed. |
A numeric vector.
The I polynomial is ignored.
ar1 <- um(ar = "1-0.8B") autocorr(ar1, lag.max = 13) autocorr(ar1, lag.max = 13, par = TRUE)
ar1 <- um(ar = "1-0.8B") autocorr(ar1, lag.max = 13) autocorr(ar1, lag.max = 13, par = TRUE)
autocov
computes the autocovariances of an ARMA model.
## S3 method for class 'stsm' autocov(mdl, ...) autocov(mdl, ...) ## S3 method for class 'um' autocov(mdl, lag.max = 10, ...)
## S3 method for class 'stsm' autocov(mdl, ...) autocov(mdl, ...) ## S3 method for class 'um' autocov(mdl, lag.max = 10, ...)
mdl |
an object of class |
... |
additional arguments. |
lag.max |
maximum lag for autocovariances. |
A numeric vector.
The I polynomial is ignored.
# Local level model b <- 1 C <- as.matrix(1) stsm1 <- stsm(b = b, C = C, s2v = c(lvl = 1469.619), s2u = c(irr = 15103.061)) autocov(stsm1) ar1 <- um(ar = "1-0.8B") autocov(ar1, lag.max = 13)
# Local level model b <- 1 C <- as.matrix(1) stsm1 <- stsm(b = b, C = C, s2v = c(lvl = 1469.619), s2u = c(irr = 15103.061)) autocov(stsm1) ar1 <- um(ar = "1-0.8B") autocov(ar1, lag.max = 13)
bsm
creates/estimates basic structural models for seasonal time
series.
bsm( y, bc = FALSE, seas = c("hd", "ht", "hs"), s2v = c(lvl = 0.2, slp = 0.05, seas = 0.075), s2u = 0.1, xreg = NULL, fSv = NULL, ... )
bsm( y, bc = FALSE, seas = c("hd", "ht", "hs"), s2v = c(lvl = 0.2, slp = 0.05, seas = 0.075), s2u = 0.1, xreg = NULL, fSv = NULL, ... )
y |
an object of class |
bc |
logical. If TRUE logs are taken. |
seas |
character, type of seasonality (Harvey-Durbin (hd), Harvey-Todd (ht), Harrison-Steven (ht)) |
s2v |
variances of the error vector v_t. |
s2u |
variance of the error u_t. |
xreg |
matrix of regressors. |
fSv |
function to create the covariance matrix of v_t. |
... |
other arguments. |
An object of class stsm
.
Durbin, J. and Koopman, S.J. (2012) Time Series Analysis by State Space Methods, 2nd ed., Oxford University Press, Oxford.
bsm1 <- bsm(AirPassengers, bc = TRUE)
bsm1 <- bsm(AirPassengers, bc = TRUE)
calendar
extends the ARIMA model um
by including a set of
deterministic variables to capture the calendar variation in a monthly time
series. Two equivalent representations are available: (i) D0, D1, ..., D6,
(ii) L, D1-D0, ..., D6-D0 where D0, D2, ..., D6 are deterministic variables
representing the number of Sundays, Mondays, ..., Saturdays, L = D0 + D1 + ...
+ D6 is the of the month. Alternatively, the Leap Year indicator (LPY) can be
included instead of L. The seven trading days can also be compacted into two
variables: week days and weekends. Optionally, a deterministic variable to
estimate the Easter effect can also be included, see "easter
".
## S3 method for class 'tfm' calendar( mdl, y = NULL, form = c("dif", "td", "td7", "td6", "wd"), ref = 0, lom = TRUE, lpyear = TRUE, easter = FALSE, len = 4, easter.mon = FALSE, n.ahead = 0, p.value = 1, envir = NULL, ... ) calendar(mdl, ...) ## S3 method for class 'um' calendar( mdl, y = NULL, form = c("dif", "td", "td7", "td6", "wd"), ref = 0, lom = TRUE, lpyear = TRUE, easter = FALSE, len = 4, easter.mon = FALSE, n.ahead = 0, p.value = 1, envir = NULL, ... )
## S3 method for class 'tfm' calendar( mdl, y = NULL, form = c("dif", "td", "td7", "td6", "wd"), ref = 0, lom = TRUE, lpyear = TRUE, easter = FALSE, len = 4, easter.mon = FALSE, n.ahead = 0, p.value = 1, envir = NULL, ... ) calendar(mdl, ...) ## S3 method for class 'um' calendar( mdl, y = NULL, form = c("dif", "td", "td7", "td6", "wd"), ref = 0, lom = TRUE, lpyear = TRUE, easter = FALSE, len = 4, easter.mon = FALSE, n.ahead = 0, p.value = 1, envir = NULL, ... )
mdl |
|
y |
a time series. |
form |
representation for calendar effects: (1) |
ref |
a integer indicating the the reference day. By default, ref = 0. |
lom , lpyear
|
a logical value indicating whether or not to include the lom/lead year indicator. |
easter |
logical. If |
len |
the length of the Easter, integer. |
easter.mon |
logical. TRUE indicates that Easter Monday is a public holiday. |
n.ahead |
a positive integer to extend the sample period of the
deterministic variables with |
p.value |
estimates with a p-value greater than p.value are omitted. |
envir |
environment in which the function arguments are evaluated. If NULL the calling environment of this function will be used. |
... |
other arguments. |
An object of class "tfm
".
W. R. Bell & S. C. Hillmer (1983) Modeling Time Series with Calendar Variation, Journal of the American Statistical Association, 78:383, 526-534, DOI: 10.1080/01621459.1983.10478005
Y <- tfarima::rsales um1 <- um(Y, i = list(1, c(1, 12)), ma = list(1, c(1, 12)), bc = TRUE) tfm1 <- calendar(um1)
Y <- tfarima::rsales um1 <- um(Y, i = list(1, c(1, 12)), ma = list(1, c(1, 12)), bc = TRUE) tfm1 <- calendar(um1)
CalendarVar
creates a set of deterministic variables to capture
calendar effects.
CalendarVar( x, form = c("dif", "td", "td7", "td6", "wd", "wd2", "null"), ref = 0, lom = TRUE, lpyear = TRUE, easter = FALSE, len = 4, easter.mon = FALSE, n.ahead = 0 )
CalendarVar( x, form = c("dif", "td", "td7", "td6", "wd", "wd2", "null"), ref = 0, lom = TRUE, lpyear = TRUE, easter = FALSE, len = 4, easter.mon = FALSE, n.ahead = 0 )
x |
an object of class |
form |
a character indicated the set of calendar variables: td, td7, td6, wd. |
ref |
a non-negative integer indicating the reference day. |
lom |
logical. If TRUE length of the month effect is also estimated. |
lpyear |
logical. If TRUE a leap year effect is also estimated. |
easter |
logical. If TRUE an additional deterministic variable is generated to capture Easter effects. |
len |
duration of the Easter, integer. |
easter.mon |
logical. It is TRUE if Holy Monday is a public holiday. |
n.ahead |
number of additional observations to extend the sample period. |
An object of class mts
or ts
.
Bell, W.R. and Hillmer, S.C. (1983) “Modeling time series with calendar variation”, Journal of the American Statistical Society, Vol. 78, pp. 526–534.
Y <- rsales X <- CalendarVar(Y, easter = TRUE)
Y <- rsales X <- CalendarVar(Y, easter = TRUE)
ccf
displays ccf between prewhitened inputs and residuals.
ccf.tfm(tfm, lag.max = NULL, method = c("exact", "cond"), envir = NULL, ...)
ccf.tfm(tfm, lag.max = NULL, method = c("exact", "cond"), envir = NULL, ...)
tfm |
a |
lag.max |
number of lags. |
method |
Exact/conditional residuals. |
envir |
environment in which the function arguments are evaluated. If NULL the calling environment of this function will be used. |
... |
additional arguments. |
coef
extracts the "coefficients" from a TF model.
## S3 method for class 'tfm' coef(object, ...)
## S3 method for class 'tfm' coef(object, ...)
object |
a |
... |
other arguments. |
A numeric vector.
coef
extracts the "coefficients" from a um object.
## S3 method for class 'um' coef(object, ...)
## S3 method for class 'um' coef(object, ...)
object |
a |
... |
other arguments. |
A numeric vector.
diagchk
displays tools for diagnostic checking.
## S3 method for class 'tfm' diagchk( mdl, y = NULL, method = c("exact", "cond"), lag.max = NULL, lags.at = NULL, freq.at = NULL, std = TRUE, envir = NULL, ... ) diagchk(mdl, ...) ## S3 method for class 'um' diagchk( mdl, z = NULL, method = c("exact", "cond"), lag.max = NULL, lags.at = NULL, freq.at = NULL, std = TRUE, envir = NULL, ... )
## S3 method for class 'tfm' diagchk( mdl, y = NULL, method = c("exact", "cond"), lag.max = NULL, lags.at = NULL, freq.at = NULL, std = TRUE, envir = NULL, ... ) diagchk(mdl, ...) ## S3 method for class 'um' diagchk( mdl, z = NULL, method = c("exact", "cond"), lag.max = NULL, lags.at = NULL, freq.at = NULL, std = TRUE, envir = NULL, ... )
mdl |
an object of class |
y |
an object of class |
method |
exact or conditional residuals. |
lag.max |
number of lags for ACF/PACF. |
lags.at |
the lags of the ACF/PACF at which tick-marks are to be drawn. |
freq.at |
the frequencies of the (cum) periodogram at at which tick-marks are to be drawn. |
std |
logical. If TRUE standardized residuals are shown. |
envir |
environment in which the function arguments are evaluated. If NULL the calling environment of this function will be used. |
... |
additional arguments. |
z |
optional, an object of class |
z <- AirPassengers airl <- um(z, i = list(1, c(1,12)), ma = list(1, c(1,12)), bc = TRUE) diagchk(airl)
z <- AirPassengers airl <- um(z, i = list(1, c(1,12)), ma = list(1, c(1,12)), bc = TRUE) diagchk(airl)
display
shows graphs characterizing one or a list of ARMA models.
display(um, ...) ## S3 method for class 'um' display( um, lag.max = 25, n.freq = 501, log.spec = FALSE, graphs = c("acf", "pacf", "spec"), byrow = FALSE, eq = TRUE, ... ) ## Default S3 method: display(um, ...)
display(um, ...) ## S3 method for class 'um' display( um, lag.max = 25, n.freq = 501, log.spec = FALSE, graphs = c("acf", "pacf", "spec"), byrow = FALSE, eq = TRUE, ... ) ## Default S3 method: display(um, ...)
um |
an object of class |
... |
additional arguments. |
lag.max |
number of lags for ACF/PACF. |
n.freq |
number of frequencies for the spectrum. |
log.spec |
logical. If TRUE log spectrum is computed. |
graphs |
vector of graphs. |
byrow |
orientation of the graphs. |
eq |
logical. If TRUE the model equation is used as title. |
um1 <- um(ar = "(1 - 0.8B)(1 - 0.8B^12)") um2 <- um(ma = "(1 - 0.8B)(1 - 0.8B^12)") display(list(um1, um2))
um1 <- um(ar = "(1 - 0.8B)(1 - 0.8B^12)") um2 <- um(ma = "(1 - 0.8B)(1 - 0.8B^12)") display(list(um1, um2))
easter
extends the ARIMA model um
by including a regression
variable to capture the Easter effect.
easter(um, ...) ## S3 method for class 'um' easter( um, z = NULL, len = 4, easter.mon = FALSE, n.ahead = 0, envir = NULL, ... )
easter(um, ...) ## S3 method for class 'um' easter( um, z = NULL, len = 4, easter.mon = FALSE, n.ahead = 0, envir = NULL, ... )
um |
an object of class |
... |
other arguments. |
z |
a time series. |
len |
a positive integer specifying the duration of the Easter. |
easter.mon |
logical. If TRUE Easter Monday is also taken into account. |
n.ahead |
a positive integer to extend the sample period of the
Easter regression variable with |
envir |
environment in which the function arguments are evaluated. If NULL the calling environment of this function will be used. |
An object of class "tfm
".
Y <- rsales um1 <- um(Y, i = list(1, c(1, 12)), ma = list(1, c(1, 12)), bc = TRUE) tfm1 <- easter(um1)
Y <- rsales um1 <- um(Y, i = list(1, c(1, 12)), ma = list(1, c(1, 12)), bc = TRUE) tfm1 <- easter(um1)
fit
fits the stsm to the time series y.
## S3 method for class 'stsm' fit(mdl, method = "BFGS", show.iter = FALSE, ...)
## S3 method for class 'stsm' fit(mdl, method = "BFGS", show.iter = FALSE, ...)
mdl |
an object of class |
method |
argument of the |
show.iter |
logical value to show or hide the estimates at the different iterations. |
... |
other arguments. |
An object of class "stsm" with the estimated variances.
# Local level model b <- 1 C <- as.matrix(1) stsm1 <- stsm(Nile, b, C, s2v = c(lvl = 0.5), s2u = c(irr = 1), fit = FALSE) stsm1 <- fit(stsm1, method = "L-BFGS-B")
# Local level model b <- 1 C <- as.matrix(1) stsm1 <- stsm(Nile, b, C, s2v = c(lvl = 0.5), s2u = c(irr = 1), fit = FALSE) stsm1 <- fit(stsm1, method = "L-BFGS-B")
fit
fits the univariate model to the time series z.
## S3 method for class 'tfm' fit( mdl, y = NULL, method = c("exact", "cond"), optim.method = "BFGS", show.iter = FALSE, fit.noise = TRUE, envir = NULL, ... ) fit(mdl, ...) ## S3 method for class 'um' fit( mdl, z = NULL, method = c("exact", "cond"), optim.method = "BFGS", show.iter = FALSE, envir = NULL, ... )
## S3 method for class 'tfm' fit( mdl, y = NULL, method = c("exact", "cond"), optim.method = "BFGS", show.iter = FALSE, fit.noise = TRUE, envir = NULL, ... ) fit(mdl, ...) ## S3 method for class 'um' fit( mdl, z = NULL, method = c("exact", "cond"), optim.method = "BFGS", show.iter = FALSE, envir = NULL, ... )
mdl |
|
y |
a |
method |
Exact/conditional maximum likelihood. |
optim.method |
the |
show.iter |
logical value to show or hide the estimates at the different iterations. |
fit.noise |
logical. If TRUE parameters of the noise model are fixed. |
envir |
environment in which the function arguments are evaluated. If NULL the calling environment of this function will be used. |
... |
additional arguments. |
z |
a time series. |
A tfm
object.
An object of class "um" with the estimated parameters.
The um
function estimates the corresponding ARIMA model when a time
series is provided. The fit
function is useful to fit a model to
several time series, for example, in a Monte Carlo study.
z <- AirPassengers airl <- um(i = list(1, c(1, 12)), ma = list(1, c(1, 12)), bc = TRUE) airl <- fit(airl, z)
z <- AirPassengers airl <- um(i = list(1, c(1, 12)), ma = list(1, c(1, 12)), bc = TRUE) airl <- fit(airl, z)
fit2autocov
fits a STS model to a vector of theoretical
autocovariances.
fit2autocov(mdl, ...) ## S3 method for class 'stsm' fit2autocov(mdl, g, method = "BFGS", show.iter = FALSE, ...)
fit2autocov(mdl, ...) ## S3 method for class 'stsm' fit2autocov(mdl, g, method = "BFGS", show.iter = FALSE, ...)
mdl |
an object of class |
... |
other arguments. |
g |
a vector of theoretical autocovariances (gamma[k], k= 0, ..., K). |
method |
optimation method. |
show.iter |
logical. If TRUE, estimates at each iteration are printed. |
An object of class stsm
.
um1 <- um(Nile, i = 1, ma = 1) g <- autocov(um1, lag.max = 1) # Local level model b <- 1 C <- as.matrix(1) stsm1 <- stsm(Nile, b, C, s2v = c(lvl = 0.5), s2u = c(irr = 1), fit = FALSE) stsm2 <- fit2autocov(stsm1, g) stsm2
um1 <- um(Nile, i = 1, ma = 1) g <- autocov(um1, lag.max = 1) # Local level model b <- 1 C <- as.matrix(1) stsm1 <- stsm(Nile, b, C, s2v = c(lvl = 0.5), s2u = c(irr = 1), fit = FALSE) stsm2 <- fit2autocov(stsm1, g) stsm2
ide
displays graphs useful to identify a tentative ARIMA model for a
time series.
ide( Y, transf = list(), order.polreg = 0, lag.max = NULL, lags.at = NULL, freq.at = NULL, wn.bands = TRUE, graphs = c("plot", "acf", "pacf"), set.layout = TRUE, byrow = TRUE, main = "", envir = NULL, ... )
ide( Y, transf = list(), order.polreg = 0, lag.max = NULL, lags.at = NULL, freq.at = NULL, wn.bands = TRUE, graphs = c("plot", "acf", "pacf"), set.layout = TRUE, byrow = TRUE, main = "", envir = NULL, ... )
Y |
Univariate or multivariate time series. |
transf |
Data transformations, list(bc = F, d = 0, D = 0, S = F), where bc is the Box-Cox logarithmic transformation, d and D are the number of nonseasonal and seasonal differences, and S is the annual sum operator. |
order.polreg |
an integer indicating the order of a polynomial trend. |
lag.max |
number of autocorrelations. |
lags.at |
the lags of the ACF/PACF at which tick-marks are to be drawn. |
freq.at |
the frequencies of the (cum) periodogram at at which tick-marks are to be drawn. |
wn.bands |
logical. If TRUE confidence intervals for sample autocorrelations are computed assuming a white noise series. |
graphs |
graphs to be shown: plot, hist, acf, pacf, pgram, cpgram (cummulative periodogram), rm (range-median). |
set.layout |
logical. If TRUE the layout is set by the function, otherwise it is set by the user. |
byrow |
logical. If TRUE the layout is filled by rows, otherwise it is filled by columns. |
main |
title of the graph. |
envir |
environment in which the function arguments are evaluated. If NULL the calling environment of this function will be used. |
... |
additional arguments. |
Y <- AirPassengers ide(Y, graphs = c("plot", "rm")) ide(Y, transf = list(list(bc = TRUE, S = TRUE), list(bc = TRUE, d = 1, D = 1)))
Y <- AirPassengers ide(Y, graphs = c("plot", "rm")) ide(Y, transf = list(list(bc = TRUE, S = TRUE), list(bc = TRUE, d = 1, D = 1)))
intervention
estimates the effect of a intervention at a known time.
## S3 method for class 'tfm' intervention( mdl, y = NULL, type, time, n.ahead = 0, envir = parent.frame(), ... ) intervention(mdl, ...) ## S3 method for class 'um' intervention( mdl, y = NULL, type, time, n.ahead = 0, envir = parent.frame(), ... )
## S3 method for class 'tfm' intervention( mdl, y = NULL, type, time, n.ahead = 0, envir = parent.frame(), ... ) intervention(mdl, ...) ## S3 method for class 'um' intervention( mdl, y = NULL, type, time, n.ahead = 0, envir = parent.frame(), ... )
mdl |
|
y |
a "ts" object, optional. |
type |
the type intervention (pulse, step, ramp) or the type of outlier (AO, LS, TC, IO). |
time |
the date of the intervention, in format c(year, season). |
n.ahead |
a positive integer to extend the sample period of the
intervention variable with |
envir |
the environment in which to look for the time series z when it is passed as a character string. |
... |
additional arguments. |
an object of class "tfm
" or a table.
InterventionVar
creates an intervention variable to capture the effect
of an external event.
InterventionVar(Y, date, type = c("P", "S", "R"), n.ahead = 0)
InterventionVar(Y, date, type = c("P", "S", "R"), n.ahead = 0)
Y |
an object of class |
date |
the date of the event, c(year, month). |
type |
a character indicating the type of intervention variables: (P) pulse, (S) step, (R). |
n.ahead |
number of additional observations to extend the sample period. |
An intervention variable, a 'ts' object.
G. E. P. Box, G. C. Tiao, “Intervention Analysis with Applications to Economic and Environmental Problems”, Journal of the American Statistical Association, Vol. 70, No. 349. (Mar., 1975), pp. 70-79.
Y <- seriesJ$Y P58 <- InterventionVar(Y, date = 58, type = "P")
Y <- seriesJ$Y P58 <- InterventionVar(Y, date = 58, type = "P")
inv
inverts a lag polynomial until the indicated lag.
inv(lp, ...) ## S3 method for class 'lagpol' inv(lp, lag.max = 10, ...)
inv(lp, ...) ## S3 method for class 'lagpol' inv(lp, lag.max = 10, ...)
lp |
an object of class |
... |
additional arguments. |
lag.max |
largest order of the inverse lag polynomial. |
inv
returns a numeric vector with the coefficients
of the inverse lag polynomial truncated at lag.max.
inv(as.lagpol(c(1, 1.2, -0.8)))
inv(as.lagpol(c(1, 1.2, -0.8)))
lagpol
creates a lag polynomial of the form . This class of lag polynomials is defined by a vector of d
coefficients c(coef_1, ..., coef_d), the powers s and p, and a vector of k
parameters c(param_1, ..., param_k). The vector c(coef_1, ..., coef_d) is
actually a vector of math expressions to compute the value of each
coefficient in terms of the parameters.
lagpol(param = NULL, s = 1, p = 1, lags = NULL, coef = NULL)
lagpol(param = NULL, s = 1, p = 1, lags = NULL, coef = NULL)
param |
a vector/list of named parameters. |
s |
the seasonal period, integer. |
p |
the power of lag polynomial, integer. |
lags |
a vector of lags for sparse polynomials. |
coef |
a vector of math expressions. |
lagpol
returns an object of class "lagpol" with the following
components:
Vector of coefficients c(coef_1, ..., coef_p) provided to create the lag polynomial.
Base lag polynomial, c(1, -coef_1, ..., -coef_d).
Power lag polynomial when p > 1.
lagpol(param = c(phi = 0.8) ) lagpol(param = c(phi1 = 1.2, phi2 = -0.6), s = 4) lagpol(param = c(delta = 1), p = 2)
lagpol(param = c(phi = 0.8) ) lagpol(param = c(phi1 = 1.2, phi2 = -0.6), s = 4) lagpol(param = c(delta = 1), p = 2)
logLik
computes the exact or conditional log-likelihood of object of
the class um
.
## S3 method for class 'um' logLik(object, z = NULL, method = c("exact", "cond"), ...)
## S3 method for class 'um' logLik(object, z = NULL, method = c("exact", "cond"), ...)
object |
an object of class |
z |
an object of class |
method |
exact or conditional. |
... |
additional arguments. |
The exact or conditional log-likelihood.
modify
modifies an object of class um
or tfm
by adding and/or removing lag polynomials.
## S3 method for class 'tfm' modify(mdl, ...) modify(mdl, ...) ## S3 method for class 'um' modify( mdl, ar = NULL, i = NULL, ma = NULL, mu = NULL, sig2 = NULL, bc = NULL, fit = TRUE, ... )
## S3 method for class 'tfm' modify(mdl, ...) modify(mdl, ...) ## S3 method for class 'um' modify( mdl, ar = NULL, i = NULL, ma = NULL, mu = NULL, sig2 = NULL, bc = NULL, fit = TRUE, ... )
mdl |
an object of class |
... |
additional arguments. |
ar |
list of stationary AR lag polynomials. |
i |
list of nonstationary AR (I) polynomials. |
ma |
list of MA polynomials. |
mu |
mean of the stationary time series. |
sig2 |
variance of the error. |
bc |
logical. If TRUE logs are taken. |
fit |
logical. If TRUE, model is fitted. |
An object of class um
or um
.
um1 <- um(ar = "(1 - 0.8B)") um2 <- modify(um1, ar = list(0, "(1 - 0.9B)"), ma = "(1 - 0.5B)")
um1 <- um(ar = "(1 - 0.8B)") um2 <- modify(um1, ar = list(0, "(1 - 0.9B)"), ma = "(1 - 0.5B)")
nabla
multiplies the I polynomials of an object of
the um
class.
nabla(um) ## S3 method for class 'um' nabla(um)
nabla(um) ## S3 method for class 'um' nabla(um)
um |
an object of class |
A numeric vector c(1, a1, ..., ad)
This function returns the member variable um$nabla
.
um1 <- um(i = "(1 - B)(1 - B^12)") nabla(um1)
um1 <- um(i = "(1 - B)(1 - B^12)") nabla(um1)
noise
computes the noise of a linear transfer function model.
noise(tfm, ...) ## S3 method for class 'tfm' noise(tfm, y = NULL, diff = TRUE, exp = FALSE, envir = NULL, ...)
noise(tfm, ...) ## S3 method for class 'tfm' noise(tfm, y = NULL, diff = TRUE, exp = FALSE, envir = NULL, ...)
tfm |
an object of the class |
... |
additional arguments. |
y |
output of the TF model if it is different to that of the
|
diff |
logical. If TRUE, the noise is differenced with the "i" operator of the univariate model of the noise. |
exp |
logical. If TRUE, the antilog transformation is applied. |
envir |
environment in which the function arguments are evaluated. If NULL the calling environment of this function will be used. |
A "ts" object.
outlierDates
shows the indeces and dates of outliers.
outlierDates(x, c = 3)
outlierDates(x, c = 3)
x |
an |
c |
critical value to determine whether or not an observation is an outlier. |
A table with the indices, dates and z-scores of the outliers.
outliers
performs a detection of four types of anomalies (AO, TC, LS
and IO) in a time series described by an ARIMA model. If the dates of the
outliers are unknown, an iterative detection process like that proposed by
Chen and Liu (1993) is conducted.
## S3 method for class 'tfm' outliers( mdl, y = NULL, types = c("AO", "LS", "TC", "IO"), dates = NULL, c = 3, calendar = FALSE, easter = FALSE, resid = c("exact", "cond"), n.ahead = NULL, p.value = 1, tc.fix = TRUE, envir = NULL, ... ) outliers(mdl, ...) ## S3 method for class 'um' outliers( mdl, y = NULL, types = c("AO", "LS", "TC", "IO"), dates = NULL, c = 3, calendar = FALSE, easter = FALSE, resid = c("exact", "cond"), n.ahead = 0, p.value = 1, tc.fix = TRUE, envir = NULL, ... )
## S3 method for class 'tfm' outliers( mdl, y = NULL, types = c("AO", "LS", "TC", "IO"), dates = NULL, c = 3, calendar = FALSE, easter = FALSE, resid = c("exact", "cond"), n.ahead = NULL, p.value = 1, tc.fix = TRUE, envir = NULL, ... ) outliers(mdl, ...) ## S3 method for class 'um' outliers( mdl, y = NULL, types = c("AO", "LS", "TC", "IO"), dates = NULL, c = 3, calendar = FALSE, easter = FALSE, resid = c("exact", "cond"), n.ahead = 0, p.value = 1, tc.fix = TRUE, envir = NULL, ... )
mdl |
|
y |
an object of class |
types |
a vector with the initials of the outliers to be detected, c("AO", "LS", "TC", "IO"). |
dates |
a list of dates c(year, season). If |
c |
a positive constant to compare the z-ratio of the effect of an
observation and decide whether or not it is an outlier. This argument is
only used when |
calendar |
logical; if true, calendar effects are also estimated. |
easter |
logical; if true, Easter effect is also estimated. |
resid |
type of residuals (exact or conditional) used to identify outliers. |
n.ahead |
a positive integer to extend the sample period of the
intervention variables with |
p.value |
estimates with a p-value greater than p.value are omitted. |
tc.fix |
a logical value indicating if the AR coefficient in the transfer function of the TC is estimated or fix. |
envir |
environment in which the function arguments are evaluated. If NULL the calling environment of this function will be used. |
... |
other arguments. |
an object of class "tfm
" or a table.
Y <- rsales um1 <- um(Y, i = list(1, c(1, 12)), ma = list(1, c(1, 12)), bc = TRUE) outliers(um1)
Y <- rsales um1 <- um(Y, i = list(1, c(1, 12)), ma = list(1, c(1, 12)), bc = TRUE) outliers(um1)
output
filters the input using the transfer function.
output.tf(tf)
output.tf(tf)
tf |
an object of the S3 class "tf". |
A "ts" object
pccf
displays cross correlation function between input and output
after prewhitening both through a univariate model.
pccf( x, y, um.x = NULL, um.y = NULL, lag.max = NULL, plot = TRUE, envir = NULL, main = NULL, nu.weights = FALSE, ... )
pccf( x, y, um.x = NULL, um.y = NULL, lag.max = NULL, plot = TRUE, envir = NULL, main = NULL, nu.weights = FALSE, ... )
x |
input, a 'ts' object or a numeric vector. |
y |
output, a 'ts' object or a numeric vector. |
um.x |
univariate model for input. |
um.y |
univariate model for output. |
lag.max |
number of lags, integer. |
plot |
logical value to indicate if the ccf graph must be graphed or computed. |
envir |
environment in which the function arguments are evaluated. If NULL the calling environment of this function will be used. |
main |
title of the graph. |
nu.weights |
logical. If TRUE the coefficients of the IRF are computed instead of the cross-correlations. |
... |
additional arguments. |
The estimated cross correlations are displayed in a graph or returned into a numeric vector.
phi
multiplies the AR polynomials of an object of
the um
class.
phi(um) ## S3 method for class 'um' phi(um)
phi(um) ## S3 method for class 'um' phi(um)
um |
an object of class |
A numeric vector c(1, a1, ..., ad)
This function returns the member variable um$phi
.
um1 <- um(ar = "(1 - 0.8B)(1 - 0.5B)") phi(um1)
um1 <- um(ar = "(1 - 0.8B)(1 - 0.5B)") phi(um1)
pi.weights
computes the pi-weights of an AR(I)MA model.
pi.weights(um, ...) ## S3 method for class 'um' pi.weights(um, lag.max = 10, var.pi = FALSE, ...)
pi.weights(um, ...) ## S3 method for class 'um' pi.weights(um, lag.max = 10, var.pi = FALSE, ...)
um |
an object of class |
... |
additional arguments. |
lag.max |
largest AR(Inf) coefficient required. |
var.pi |
logical. If TRUE (FALSE), the I polynomials is considered (ignored). |
A numeric vector.
um1 <- um(i = "(1 - B)(1 - B^12)", ma = "(1 - 0.8B)(1 - 0.8B^12)") pi.weights(um1, var.pi = TRUE)
um1 <- um(i = "(1 - B)(1 - B^12)", ma = "(1 - 0.8B)(1 - 0.8B^12)") pi.weights(um1, var.pi = TRUE)
predict
computes point and interval predictions for a time series
based on a tfm
object.
## S3 method for class 'tfm' predict( object, newdata = NULL, y = NULL, ori = NULL, n.ahead = NULL, level = 0.95, i = NULL, envir = NULL, ... )
## S3 method for class 'tfm' predict( object, newdata = NULL, y = NULL, ori = NULL, n.ahead = NULL, level = 0.95, i = NULL, envir = NULL, ... )
object |
an object of class |
newdata |
new data for the predictors for the forecast period. This is
a matrix if there is more than one predictor. The number of columns is
equal to the number of predictors, the number of rows equal to
|
y |
an object of class |
ori |
the origin of prediction. By default, it is the last observation. |
n.ahead |
number of steps ahead. |
level |
confidence level. |
i |
transformation of the series |
envir |
environment in which the function arguments are evaluated. If NULL the calling environment of this function will be used. |
... |
additional arguments. |
Forecasts for the inputs of a tfm
object can be provided
in tree ways: (1) extending the time series with forecasts so that the length
of the intput is greater than the length of the output, (2) computed
internally from the um
object associated to the input and (3) with
the newdata
argument.
predict
computes point and interval predictions for a time series
from models of class um
.
## S3 method for class 'um' predict( object, z = NULL, ori = NULL, n.ahead = 1, level = 0.95, i = NULL, envir = NULL, ... )
## S3 method for class 'um' predict( object, z = NULL, ori = NULL, n.ahead = 1, level = 0.95, i = NULL, envir = NULL, ... )
object |
an object of class |
z |
an object of class |
ori |
the origin of prediction. By default, it is the last observation. |
n.ahead |
number of steps ahead. |
level |
confidence level. |
i |
transformation of the series |
envir |
environment in which the function arguments are evaluated. If NULL the calling environment of this function will be used. |
... |
additional arguments. |
An object of class "tfm
".
Z <- AirPassengers um1 <- um(Z, i = list(1, c(1, 12)), ma = list(1, c(1, 12)), bc = TRUE) p <- predict(um1, n.ahead = 12) p plot(p, n.back = 60)
Z <- AirPassengers um1 <- um(Z, i = list(1, c(1, 12)), ma = list(1, c(1, 12)), bc = TRUE) p <- predict(um1, n.ahead = 12) p plot(p, n.back = 60)
Print numeric vector as a lagpol object
printLagpol(pol, digits = 2)
printLagpol(pol, digits = 2)
pol |
numeric vectors with the coefficients of a normalized polynomial. |
digits |
number of decimals. |
Print a list of lagpol objects
printLagpolList(llp, digits = 2)
printLagpolList(llp, digits = 2)
llp |
a list of |
digits |
number of decimals. |
psi
computes the psi-weights of an AR(I)MA model.
psi.weights(um, ...) ## S3 method for class 'um' psi.weights(um, lag.max = 10, var.psi = FALSE, ...)
psi.weights(um, ...) ## S3 method for class 'um' psi.weights(um, lag.max = 10, var.psi = FALSE, ...)
um |
an object of class |
... |
additional arguments. |
lag.max |
Largest MA(Inf) coefficient required. |
var.psi |
logical. If TRUE the I polynomials is also inverted. If FALSE it is ignored. |
A numeric vector.
um1 <- um(i = "(1 - B)(1 - B^12)", ma = "(1 - 0.8B)(1 - 0.8B^12)") psi.weights(um1) psi.weights(um1, var.psi = TRUE)
um1 <- um(i = "(1 - B)(1 - B^12)", ma = "(1 - 0.8B)(1 - 0.8B^12)") psi.weights(um1) psi.weights(um1, var.psi = TRUE)
residuals
computes the exact or conditional residuals of a TF model.
## S3 method for class 'tfm' residuals(object, y = NULL, method = c("exact", "cond"), envir = NULL, ...)
## S3 method for class 'tfm' residuals(object, y = NULL, method = c("exact", "cond"), envir = NULL, ...)
object |
a |
y |
output of the TF model (if it is different to that of the "tfm" object). |
method |
a character string specifying the method to compute the residuals, exact or conditional. |
envir |
environment in which the function arguments are evaluated. If NULL the calling environment of this function will be used. |
... |
additional arguments. |
A "ts" object.
residuals
computes the exact or conditional residuals.
## S3 method for class 'um' residuals(object, z = NULL, method = c("exact", "cond"), envir = NULL, ...)
## S3 method for class 'um' residuals(object, z = NULL, method = c("exact", "cond"), envir = NULL, ...)
object |
an object of class |
z |
an object of class |
method |
exact/conditional residuals. |
envir |
environment in which the function arguments are evaluated. If NULL the calling environment of this function will be used. |
... |
additional arguments. |
An object of class um
.
z <- AirPassengers airl <- um(z, i = list(1, c(1, 12)), ma = list(1, c(1, 12)), bc = TRUE) r <- residuals(airl) summary(r)
z <- AirPassengers airl <- um(z, i = list(1, c(1, 12)), ma = list(1, c(1, 12)), bc = TRUE) r <- residuals(airl) summary(r)
rform
finds the reduce form for a STS model.
rform(mdl, ...) ## S3 method for class 'stsm' rform(mdl, ...)
rform(mdl, ...) ## S3 method for class 'stsm' rform(mdl, ...)
mdl |
an object of class |
... |
other arguments. |
An object of class um
.
b <- 1 C <- as.matrix(1) stsm1 <- stsm(b = b, C = C, s2v = c(lvl = 1469.619), s2u = c(irr = 15103.061)) rf1 <- rform(stsm1) nabla(rf1) theta(rf1)
b <- 1 C <- as.matrix(1) stsm1 <- stsm(b = b, C = C, s2v = c(lvl = 1469.619), s2u = c(irr = 15103.061)) rf1 <- rform(stsm1) nabla(rf1) theta(rf1)
roots
compute the roots of the AR, I, MA lag polynomials an ARIMA
model.
roots(x, ...) ## S3 method for class 'um' roots(x, opr = c("arma", "ar", "ma", "i", "arima"), ...)
roots(x, ...) ## S3 method for class 'um' roots(x, opr = c("arma", "ar", "ma", "i", "arima"), ...)
x |
an object of class |
... |
additional arguments. |
opr |
character that indicates which operators are selected. |
List of matrices with the roots of each single polynomial.
um1 <- um(ar = "(1 - 0.8B)(1 - 0.8B^12)") roots(um1)
um1 <- um(ar = "(1 - 0.8B)(1 - 0.8B^12)") roots(um1)
roots.lagpol
computes the roots of a lag polynomial.
## S3 method for class 'lagpol' roots(x, table = TRUE, ...) ## Default S3 method: roots(x, ...)
## S3 method for class 'lagpol' roots(x, table = TRUE, ...) ## Default S3 method: roots(x, ...)
x |
an object of class |
table |
logical. If TRUE, it returns a five columns table showing the real and imaginary parts, the modulus, the frequency and the period of each root. |
... |
additional arguments. |
A vector or a table.
roots(c(1, 1.2, -0.8))
roots(c(1, 1.2, -0.8))
156 monthly observations from January 1967 to December 1979.
rsales
rsales
An object of class ts
of length 156.
Chen, C. and Liu, L. (1993) Joint Estimation of Model Parameters and Outlier Effects in Time Series, Journal of the American Statistical Association, Vol. 88, No. 421, pp. 284-297
S
generates the annual sum of a monthly or quarterly time series.
S(x, extend = TRUE)
S(x, extend = TRUE)
x |
an |
extend |
logical. If TRUE, the transformed series is extended with NA's to have the same length as the origianl series. |
The transformed time series, a ts
object.
sdummies
creates an full set of seasonal dummies.
sdummies(Y, ref = 1, constant = FALSE, n.ahead = 0)
sdummies(Y, ref = 1, constant = FALSE, n.ahead = 0)
Y |
an object of class |
ref |
the reference season, positive integer |
constant |
logical indicator to include a column of ones. |
n.ahead |
number of additional observations to extend the sample period. |
A matrix of trigonometric variables.
Y <- AirPassengers P58 <- sincos(Y)
Y <- AirPassengers P58 <- sincos(Y)
seasadj
removes the seasonal component of time series.
seasadj(mdl, ...) ## S3 method for class 'um' seasadj( mdl, z = NULL, method = c("mixed", "forecast", "backcast"), envir = NULL, ... )
seasadj(mdl, ...) ## S3 method for class 'um' seasadj( mdl, z = NULL, method = c("mixed", "forecast", "backcast"), envir = NULL, ... )
mdl |
|
... |
additional arguments. |
z |
an object of class |
method |
forward/backward forecasts or a mixture of the two. |
envir |
environment in which the function arguments are evaluated. If NULL the calling environment of this function will be used. |
seasadj
returns a seasonal adjusted time series.
Y <- AirPassengers um1 <- um(Y, bc = TRUE, i = list(1, c(1,12)), ma = list(1, c(1,12))) Y <- seasadj(um1) ide(Y)
Y <- AirPassengers um1 <- um(Y, bc = TRUE, i = list(1, c(1,12)), ma = list(1, c(1,12))) Y <- seasadj(um1) ide(Y)
226 observations.
seriesC
seriesC
An object of class numeric
of length 226.
Box, G.E., Jenkins, G.M., Reinsel, G.C. and Ljung, G.M. (2015) Time Series Analysis: Forecasting and Control. John Wiley & Sons, Hoboken.
Sampling interval 9 seconds; observations for 296 pairs of data points.
seriesJ
seriesJ
A object of class data.frame with 296 rows and 2 columns:
0.60-0.04 (input gas rate in cubir feet per minute.)
% CO2 in outlet gas.
Box, G.E., Jenkins, G.M., Reinsel, G.C. and Ljung, G.M. (2015) Time Series Analysis: Forecasting and Control. John Wiley & Sons, Hoboken.
setinputs
adds new inputs into a transfer function model.setinputs
adds new inputs into a transfer function model.
## S3 method for class 'tfm' setinputs( mdl, xreg = NULL, inputs = NULL, y = NULL, envir = parent.frame(), ... ) setinputs(mdl, ...) ## S3 method for class 'um' setinputs(mdl, xreg = NULL, inputs = NULL, y = NULL, envir = NULL, ...)
## S3 method for class 'tfm' setinputs( mdl, xreg = NULL, inputs = NULL, y = NULL, envir = parent.frame(), ... ) setinputs(mdl, ...) ## S3 method for class 'um' setinputs(mdl, xreg = NULL, inputs = NULL, y = NULL, envir = NULL, ...)
mdl |
a |
xreg |
a matrix of inputs. |
inputs |
a list of tf objects. |
y |
an optional ts object. |
envir |
an environment. |
... |
other arguments. |
A tfm
object.
sform
finds the structural form for an ARIMA model from its the eventual
forecast function.
sform(mdl, ...) ## S3 method for class 'um' sform(mdl, fSv = NULL, par = NULL, ...)
sform(mdl, ...) ## S3 method for class 'um' sform(mdl, fSv = NULL, par = NULL, ...)
mdl |
an object of class |
... |
other arguments. |
fSv |
optional function to create the covariance matrix. |
par |
vector of parameters for function fSv. |
An object of class stsm
airl <- um(i = list(1, c(1, 12)), ma = "(1 - 0.86B)(1 - 0.8B12)") sf <- sform(airl) sf
airl <- um(i = list(1, c(1, 12)), ma = "(1 - 0.86B)(1 - 0.8B12)") sf <- sform(airl) sf
signal
extracts the signal of a TF model.
signal(mdl, ...) ## S3 method for class 'tfm' signal(mdl, y = NULL, diff = TRUE, envir = NULL, ...)
signal(mdl, ...) ## S3 method for class 'tfm' signal(mdl, y = NULL, diff = TRUE, envir = NULL, ...)
mdl |
an object of the class |
... |
additional arguments. |
y |
output of the TF model if it is different to that of the
|
diff |
logical. If TRUE, the noise is differenced with the "i" operator of the univariate model of the noise. |
envir |
environment in which the function arguments are evaluated. If NULL the calling environment of this function will be used. |
A "ts" object.
sim
generates a random time series from an object of class um
or tfm
.
## S3 method for class 'tfm' sim(mdl, n = 100, y0 = NULL, seed = NULL, ...) sim(mdl, ...) ## S3 method for class 'um' sim( mdl, n = 100, z0 = NULL, n0 = 0, a = NULL, seed = NULL, envir = parent.frame(), ... )
## S3 method for class 'tfm' sim(mdl, n = 100, y0 = NULL, seed = NULL, ...) sim(mdl, ...) ## S3 method for class 'um' sim( mdl, n = 100, z0 = NULL, n0 = 0, a = NULL, seed = NULL, envir = parent.frame(), ... )
mdl |
an object of class |
n |
number of observations. |
y0 |
initial conditions for the nonstationary series. |
seed |
an integer. |
... |
other arguments. |
z0 |
initial conditions for the nonstationary series. |
n0 |
remove the n0 first observation, integer. |
a |
vector of innovations, optional. |
envir |
environment in which the function arguments are evaluated. If NULL the calling environment of this function will be used. |
An object of class ts
.
sincos
creates an full set of trigonometric variables.
sincos(Y, n.ahead = 0, constant = FALSE)
sincos(Y, n.ahead = 0, constant = FALSE)
Y |
an object of class |
n.ahead |
number of additional observations to extend the sample period. |
constant |
logical indicator to include a column of ones. |
A matrix of trigonometric variables.
Y <- AirPassengers P58 <- sincos(Y)
Y <- AirPassengers P58 <- sincos(Y)
spec
computes the spectrum of an ARMA model.
spec(um, ...) ## S3 method for class 'um' spec(um, n.freq = 501, ...)
spec(um, ...) ## S3 method for class 'um' spec(um, n.freq = 501, ...)
um |
an object of class |
... |
additional parameters. |
n.freq |
number of frequencies. |
A matrix with the frequencies and the power spectral densities.
The I polynomial is ignored.
um1 <- um(i = "(1 - B)(1 - B^12)", ma = "(1 - 0.8B)(1 - 0.8B^12)") s <- spec(um1, lag.max = 13)
um1 <- um(i = "(1 - B)(1 - B^12)", ma = "(1 - 0.8B)(1 - 0.8B^12)") s <- spec(um1, lag.max = 13)
std
standardizes a time series.
std(x)
std(x)
x |
a |
The standardized time series.
stsm
creates an S3 object representing a time-invariant structural
time series model.
stsm(y, b, C, fSv, s2v, s2u = 1, xreg = NULL, bc = FALSE, fit = TRUE, ...)
stsm(y, b, C, fSv, s2v, s2u = 1, xreg = NULL, bc = FALSE, fit = TRUE, ...)
y |
an object of class |
b |
vector of constants. |
C |
matrix of constants. |
fSv |
function to create the covariance matrix of v_t. |
s2v |
variances of the vector error v_t in the state equation. |
s2u |
variance of the error u_t in the observation equation. |
xreg |
matrix of regressors. |
bc |
logical. If TRUE logs are taken. |
fit |
logical. If TRUE, model is fitted. |
... |
other arguments. |
y_t = b'x_t + u_t (observation equation), x_t = Cx_t-1 + v_t (state equation).
An object of class stsm
.
Durbin, J. and Koopman, S.J. (2012) Time Series Analysis
# Local level model b <- 1 C <- as.matrix(1) stsm1 <- stsm(Nile, b, C, s2v = c(lvl = 0.5), s2u = c(irr = 1)) stsm1
# Local level model b <- 1 C <- as.matrix(1) stsm1 <- stsm(Nile, b, C, s2v = c(lvl = 0.5), s2u = c(irr = 1)) stsm1
sum_um
creates a univariate (ARIMA) model from the
sum of serveral univariate (arima) models.
sum_um(...)
sum_um(...)
... |
List of "um" S3 objects. |
A "um" S3 object.
um1 <- um(i = "(1 - B)", ma = "(1 - 0.8B)") um2 <- um(i = "(1 - B12)", ma = "(1 - 0.8B^12)") um3 <- sum_um(um1, um2)
um1 <- um(i = "(1 - B)", ma = "(1 - 0.8B)") um2 <- um(i = "(1 - B12)", ma = "(1 - 0.8B^12)") um3 <- sum_um(um1, um2)
summary
method for class "tfm".
## S3 method for class 'tfm' summary( object, y = NULL, method = c("exact", "cond"), digits = max(3L, getOption("digits") - 3L), envir = NULL, ... )
## S3 method for class 'tfm' summary( object, y = NULL, method = c("exact", "cond"), digits = max(3L, getOption("digits") - 3L), envir = NULL, ... )
object |
a |
y |
a "ts" object. |
method |
exact or conditional maximum likelihood. |
digits |
number of significant digits to use when printing. |
envir |
environment in which the function arguments are evaluated. If NULL the calling environment of this function will be used. |
... |
additional arguments. |
A tfm
object.
summary
prints a summary of the estimation and diagnosis.
## S3 method for class 'um' summary( object, z = NULL, method = c("exact", "cond"), digits = max(3L, getOption("digits") - 3L), envir = NULL, ... )
## S3 method for class 'um' summary( object, z = NULL, method = c("exact", "cond"), digits = max(3L, getOption("digits") - 3L), envir = NULL, ... )
object |
an object of class |
z |
an object of class |
method |
exact/conditional maximum likelihood. |
digits |
number of significant digits to use when printing. |
envir |
environment in which the function arguments are evaluated. If NULL the calling environment of this function will be used. |
... |
additional arguments. |
A list with the summary of the estimation and diagonosis.
z <- AirPassengers airl <- um(z, i = list(1, c(1,12)), ma = list(1, c(1,12)), bc = TRUE) summary(airl)
z <- AirPassengers airl <- um(z, i = list(1, c(1,12)), ma = list(1, c(1,12)), bc = TRUE) summary(airl)
tf
creates a rational transfer function for an input, V(B) = w0(1 -
w_1B - ... - w_qB^q)/(1-d_1B - ... - d_pB^p)B^dX_t. Note that in this
specification the constant term of the MA polynomial is factored out so that
both polynomials in the numerator and denominator are normalized and can be
specified with the lagpol
function in the same way as the operators of
univariate models.
tf( x = NULL, delay = 0, w0 = 0, ar = NULL, ma = NULL, um = NULL, n.back = NULL, par.prefix = "", envir = NULL )
tf( x = NULL, delay = 0, w0 = 0, ar = NULL, ma = NULL, um = NULL, n.back = NULL, par.prefix = "", envir = NULL )
x |
input, a ts object or a numeric vector. |
delay |
integer. |
w0 |
constant term of the polynomial V(B), double. |
ar |
list of stationary AR polynomials. |
ma |
list of MA polynomials. |
um |
univariate model for stochastic input. |
n.back |
number of backcasts to extend the input. |
par.prefix |
prefix name for parameters. |
envir |
environment in which the function arguments are evaluated. If NULL the calling environment of this function will be used. |
An object of the class "tf".
Box, G.E., Jenkins, G.M., Reinsel, G.C. and Ljung, G.M. (2015) Time Series Analysis: Forecasting and Control. John Wiley & Sons, Hoboken.
Wei, W.W.S. (2006) Time Series Analysis Univariate and Multivariate Methods. 2nd Edition, Addison Wesley, New York, 33-59.
um
.
x <- rep(0, 100) x[50] <- 1 tfx <- tf(x, w0 = 0.8, ar = "(1 - 0.5B)(1 - 0.7B^12)")
x <- rep(0, 100) x[50] <- 1 tfx <- tf(x, w0 = 0.8, ar = "(1 - 0.5B)(1 - 0.7B^12)")
tfest
provides preestimates of the transfer function
between an output and an input.
tfest( y, x, delay = 0, p = 1, q = 2, um.y = NULL, um.x = NULL, n.back = NULL, par.prefix = "", envir = NULL )
tfest( y, x, delay = 0, p = 1, q = 2, um.y = NULL, um.x = NULL, n.back = NULL, par.prefix = "", envir = NULL )
y |
output, a ts object or a numeric vector. |
x |
input, a ts object or a numeric vector. |
delay |
integer. |
p |
order of the AR polynomial, integer |
q |
order of the MA polynomial, integer. |
um.y |
univariate model for output, um object or NULL. |
um.x |
univariate model for input, um object or NULL. |
n.back |
number of backcasts. |
par.prefix |
prefix name for parameters. |
envir |
environment in which the function arguments are evaluated. If NULL the calling environment of this function will be used. |
A "tf" S3 object
tfm
creates a multiple input transfer function model.
tfm( output = NULL, xreg = NULL, inputs = NULL, noise, fit = TRUE, envir = NULL, new.name = TRUE, ... )
tfm( output = NULL, xreg = NULL, inputs = NULL, noise, fit = TRUE, envir = NULL, new.name = TRUE, ... )
output |
a ts object or a numeric vector. |
xreg |
a matrix of regressors. |
inputs |
a list of tf objects. |
noise |
a um object for the noise. |
fit |
logical. If TRUE, model is fitted. |
envir |
environment in which the function arguments are evaluated. If NULL the calling environment of this function will be used. |
new.name |
logical. Argument used internally: if TRUE a new name is assigned to the output, otherwise it keeps its name saved in noise$z. |
... |
additional arguments. |
An object of the class tfm
.
Box, G.E., Jenkins, G.M., Reinsel, G.C. and Ljung, G.M. (2015) Time Series Analysis: Forecasting and Control. John Wiley & Sons, Hoboken.
Unscramble MA polynomial
theta(um) ## S3 method for class 'um' theta(um)
theta(um) ## S3 method for class 'um' theta(um)
um |
an object of class |
A numeric vector c(1, a1, ..., ad)
This function returns the member variable um$theta
.
um1 <- um(ma = "(1 - 0.8B)(1 - 0.5B)") theta(um1)
um1 <- um(ma = "(1 - 0.8B)(1 - 0.5B)") theta(um1)
tsdiag.tfm
is a wrap of the stats::tsdiag function.
## S3 method for class 'tfm' tsdiag(object, gof.lag = 10, ...)
## S3 method for class 'tfm' tsdiag(object, gof.lag = 10, ...)
object |
a fitted |
gof.lag |
the maximum number of lags for a Portmanteau goodness-of-fit test |
... |
additional arguments. |
stats::tsdiag.
tsdiag.um
is a wrap of the stats::tsdiag function.
## S3 method for class 'um' tsdiag(object, gof.lag = 10, ...)
## S3 method for class 'um' tsdiag(object, gof.lag = 10, ...)
object |
a fitted |
gof.lag |
the maximum number of lags for a Portmanteau goodness-of-fit test |
... |
additional arguments. |
stats::tsdiag.
tsvalue
select a value from a time series by date.
tsvalue(x, date)
tsvalue(x, date)
x |
an |
date |
the time of the specific observation, c(year, month/quarter). |
The value of the observation, double.
ucomp
estimates the unobserved components of a time series (trend,
seasonal, cycle, stationary and irregular) from the eventual forecast
function.
## S3 method for class 'tfm' ucomp( mdl, y = NULL, method = c("mixed", "forecast", "backcast"), envir = NULL, ... ) ucomp(mdl, ...) ## S3 method for class 'um' ucomp( mdl, z = NULL, method = c("mixed", "forecast", "backcast"), envir = NULL, ... )
## S3 method for class 'tfm' ucomp( mdl, y = NULL, method = c("mixed", "forecast", "backcast"), envir = NULL, ... ) ucomp(mdl, ...) ## S3 method for class 'um' ucomp( mdl, z = NULL, method = c("mixed", "forecast", "backcast"), envir = NULL, ... )
mdl |
|
y |
an object of class |
method |
forward/backward forecasts or a mixture of the two. |
envir |
environment in which the function arguments are evaluated. If NULL the calling environment of this function will be used. |
... |
additional arguments. |
z |
an object of class |
A matrix with the unobserved components.
Z <- AirPassengers um1 <- um(Z, i = list(1, c(1, 12)), ma = list(1, c(1, 12)), bc = TRUE) uc <- ucomp(um1)
Z <- AirPassengers um1 <- um(Z, i = list(1, c(1, 12)), ma = list(1, c(1, 12)), bc = TRUE) uc <- ucomp(um1)
um
creates an S3 object representing a univariate ARIMA model, which
can contain multiple AR, I and MA polynomials, as well as parameter
restrictions.
um( z = NULL, ar = NULL, i = NULL, ma = NULL, mu = NULL, sig2 = 1, bc = FALSE, fit = TRUE, envir = parent.frame(), ... )
um( z = NULL, ar = NULL, i = NULL, ma = NULL, mu = NULL, sig2 = 1, bc = FALSE, fit = TRUE, envir = parent.frame(), ... )
z |
an object of class |
ar |
list of stationary AR lag polynomials. |
i |
list of nonstationary AR (I) polynomials. |
ma |
list of MA polynomials. |
mu |
mean of the stationary time series. |
sig2 |
variance of the error. |
bc |
logical. If TRUE logs are taken. |
fit |
logical. If TRUE, model is fitted. |
envir |
the environment in which to look for the time series z when it is passed as a character string. |
... |
additional arguments. |
An object of class um
.
Box, G.E.P., Jenkins, G.M., Reinsel, G.C. and Ljung, G.M. (2015) Time Series Analysis: Forecasting and Control. John Wiley & Sons, Hoboken.
ar1 <- um(ar = "(1 - 0.8B)") ar2 <- um(ar = "(1 - 1.4B + 0.8B^2)") ma1 <- um(ma = "(1 - 0.8B)") ma2 <- um(ma = "(1 - 1.4B + 0.8B^2)") arma11 <- um(ar = "(1 - 1.4B + 0.8B^2)", ma = "(1 - 0.8B)")
ar1 <- um(ar = "(1 - 0.8B)") ar2 <- um(ar = "(1 - 1.4B + 0.8B^2)") ma1 <- um(ma = "(1 - 0.8B)") ma2 <- um(ma = "(1 - 1.4B + 0.8B^2)") arma11 <- um(ar = "(1 - 1.4B + 0.8B^2)", ma = "(1 - 0.8B)")
varsel
omits non-significant inputs from a transfer function model.
varsel(tfm, ...) ## S3 method for class 'tfm' varsel(tfm, y = NULL, p.value = 0.1, envir = NULL, ...)
varsel(tfm, ...) ## S3 method for class 'tfm' varsel(tfm, y = NULL, p.value = 0.1, envir = NULL, ...)
tfm |
a |
... |
other arguments. |
y |
a "ts" object. |
p.value |
probability value to decide whether or not to omit an input. |
envir |
environment in which the function arguments are evaluated. If NULL the calling environment of this function will be used. |
A tfm
object or a "um" if no input is significant at that level.
Monthly data from January 1951 to October 1966.
Wtelephone
Wtelephone
A object of class data.frame with 215 rows and 2 columns:
Monthly outward station movements.
Montly inward station movements.
https://drive.google.com/file/d/1LP8aMIQewMrxgOlrg9rN3eWHhZuUsY8K/view?usp=sharing
Thompson, H. E. and Tiao, G. C. (1971) "Analysis of Telephone Data: A Case Study of Forecasting Seasonal Time Series," Bell Journal of Economics, The RAND Corporation, vol. 2(2), pages 515-541, Autumn.