Learn R Programming

mar1s (version 2.1.1)

compose.mar1s: Compose and Decompose MAR(1)S Process

Description

compose.mar1s composes MAR(1)S process realization by given vector of log-innovations.

decompose.mar1s extracts MAR(1)S process components from time series.

Usage

compose.mar1s(object, loginnov, start.time = head(time(loginnov), 1),
              xreg.absdata = NULL, init.absdata = NULL)

decompose.mar1s(object, absdata, start.time = head(time(absdata), 1), init.absdata = rep(NA, NCOL(absdata)))

Arguments

object

An object of class "mar1s" specifying the model parameters.

loginnov

A univariate time series containing the log-innovations.

absdata

A univariate or multivariate time series containing the process realization.

start.time

The sampling time for the first simulation step.

xreg.absdata

A matrix-like object with row count = n.ahead, specifying the values for the external regressors. If NULL, default values are used.

init.absdata

A vector specifying the initial values of the process. If NULL, default values are used.

Value

absdata

Realization of the process (a univariate or multivariate time series object).

logdata

Logarithm of absdata (a univariate or multivariate time series object).

logstoch

Log-stochastic component (a univariate or multivariate time series object).

logresid

Random component (a univariate time series object).

Details

Multiplicative AR(1) with Seasonal (MAR(1)S) process is defined as

$$x_t = exp(s_t + y_t)$$

$$y_{t, 1} = b_1 y_{t, 2} + \dots + b_k y_{t, k + 1} + z_t$$

$$z_t = a z_{t-1} + e_t$$

where

\(s_t\) is the log-seasonal component,

\(y_t\) is the AR(1) (log-stochastic) component,

\(e_t\) is the log-residuals (random component).

See Also

compose.ar1 for the AR(1) with external regressors processes, fit.mar1s for fitting MAR(1)S process to data, sim.mar1s for MAR(1)S process simulation and prediction.

Examples

Run this code
# NOT RUN {
data(forest.fire, package = "mar1s")
data(nesterov.index, package = "mar1s")

## Simple
mar1s <- fit.mar1s(window(forest.fire, 1969, 1989))

x <- ts(rnorm(365, sd = mar1s$logresid.sd), start = c(1989, 1))
plot(compose.mar1s(mar1s, x)$absdata)

decomp <- decompose.mar1s(mar1s, mar1s$decomposed$absdata)
delta <- abs(nan2na(mar1s$decomposed$logresid) -
             nan2na(decomp$logresid))
stopifnot(all(na.exclude(tail(delta, -1)) < 1E-6))

## External regressors
mar1s <- fit.mar1s(window(forest.fire, 1969, 1989),
                   window(nesterov.index[, "mean"], 1969, 1989))

x <- rnorm(365, sd = mar1s$logresid.sd)
xreg <- window(nesterov.index[, "mean"], 1989.001, 1990)
plot(compose.mar1s(mar1s, x, c(1989, 1), xreg)$absdata)

decomp <- decompose.mar1s(mar1s, mar1s$decomposed$absdata)
delta <- abs(mar1s$decomposed$logstoch - decomp$logstoch)
stopifnot(all(na.exclude(delta) < 1E-6))
delta <- abs(nan2na(mar1s$decomposed$logresid) -
             nan2na(decomp$logresid))
stopifnot(all(na.exclude(tail(delta, -1)) < 1E-6))
# }

Run the code above in your browser using DataLab