MAXff {VGAMextra}R Documentation

VGLTSMs Family Functions: Order–q Moving Average Model with covariates

Description

Estimates the intercept, standard deviation (or variance) of the random noise (not necessarily constant), and the conditional–mean model coefficients of an order–q moving average (MA) process with covariates (MAX(q)) by maximum likelihood estimation using Fisher scoring.

Usage

      MAXff(order    = 1,
            zero     = c(if (nomean) NULL else "Mean", "MAcoeff"),
            xLag     = 0,
            type.EIM = c("exact", "approximate")[1],
            var.arg  = TRUE, 
            nomean   = FALSE,
            noChecks = FALSE,
            lmean    = "identitylink", 
            lsd      = "loglink",
            lvar     = "loglink",
            lMAcoeff = "identitylink",
            imean    = NULL,
            isd      = NULL,
            ivar     = NULL,
            iMAcoeff = NULL)      

Arguments

order

The order 'q' of the MA model, recycled if needed. By default q = 1.

zero

Integer or character–string vector. Same as ARIMAXff. Details at zero.

xLag

Same as ARIMAXff.

type.EIM, var.arg

Same as ARIMAXff.

nomean

Logical. nomean = TRUE supresses estimation of the mean (intercept of the conditional–mean model).

noChecks

Logical. Same as ARIMAXff.

lmean, lsd, lvar, lMAcoeff

Link functions applied to the mean (intercept), the standard deviation or variance of the random noise, and the MA coefficients (conditional–mean model). Note, lmean plays the role of ldrift.

imean, isd, ivar, iMAcoeff

Same as ARIMAXff. Note, imean plays the role of idrift.

Details

Similar to ARXff, this family function fits an order–q moving average model with covariates (MAX(q)), another special case of the class VGLM–ARIMA (Miranda and Yee, 2018). Observations, Y_t, are modelled as

Y_t | \Phi_{t - 1} = \mu_t + \phi_{1} \varepsilon_{t - 1} + \ldots + \phi_q \varepsilon_{t - q} + \varepsilon_t,

where \mu_t is the (possibly time–dependent) intercept, modelled as \mu_t = \mu + \boldsymbol{\beta}^T \boldsymbol{x}_t, and the errors are mean–zero Gaussian: \varepsilon_t | \Phi_{t - 1} \sim N(0, \sigma^2_{\varepsilon_t | \Phi_{t - 1}}). The symbol \Phi_{t} denotes the history of the joint process \left(Y_{t}, \boldsymbol{X}_{t + 1}^T \right), at time t for a time–varying covariate vector \boldsymbol{x}_t.

At each step of Fisher scoring, the exact log-likelihood based on model above is computed through dMAq.

The linear predictor by default is

\boldsymbol{\eta} = \left( \mu_t, \log \sigma^{2}_{\varepsilon_{t | \Phi_{t - 1}}}, \phi_1, \ldots, \phi_q \right)^T.

The unconditional mean of the process is simply E(Y_{t}) = \mu, provided no covariates added.

This family function is not restricted to the noise to be strictly white noise (in the sense of constant variance). That is, covariates may be incorporated in the linear predictor \log \sigma^{2}_{\varepsilon_{t | \Phi_{t - 1}}}. Also, it handles multiple responses so that a matrix can be used as the response. For further details on VGLM/VGAM–link functions, such as logitlink, refer to Links.

Value

An object of class "vglmff" (see vglmff-class) to be used by VGLM/VGAM modelling functions, e.g., vglm or vgam.

Warning

By default, a moving-average model of order-1 is fitted.

If different, the order is recycled up to the number of responses entered in the vglm \ vgam call has been matched.

Successful convergence depends on reasonably setting initial values. If initial values computed by the algorithm are not adequate, make use of the the optional initial values (imean, isd, etc.)

For constraints on the paramaters see cm.ARMA.

Note

Further choices for the random noise, besides Gaussian, will be implemented over time.

zero can be either an integer vector or a vector of character strings specifying either the position(s) or name(s) (partially or not) of the parameter(s) modeled as intercept-only. For MAXff, the parameters are placed and named as follows (by convention):

c("Mean", "noiseVar" or "noiseSD", "MAcoeff").

Users can modify the zero argument accordingly. For simplicity, the second choice recommended. See CommonVGAMffArguments for further details on zero.

If no constraints are entered in the fitting process, (e.g., via cm.ARMA) this family function internally verifies by default whether the estimated series is invertible (since noChecks = FALSE). To ignore this step, set noChecks = TRUE. If the estimated MA process is non-invertible, MLE coefficients will conform with the corresponding invertible MA model.

Further details about these checks are shown within the summary() output.

Author(s)

Victor Miranda and Thomas W. Yee.

References

Miranda, V. and Yee, T.W. (2018) Vector Generalized Linear Time Series Models. In preparation.

Madsen, H. (2008) Time Series Analysis Florida, USA: Chapman & Hall. (Sections 5.3 to 5.5).

Tsay, R. (2013) An Introduction to Analysis of Financial data with R. New Jersey, USA: Wiley Sections 2.2 to 2.4.

See Also

ARIMAXff, ARXff, checkTS.VGAMextra, CommonVGAMffArguments, Links, vglm, vgam.

Examples

set.seed(2)
nn    <- 130
### Coefficients
phi1  <-  0.34; phi2 <- -1.19; phi3 <- 0.26
### Intercept
mu    <- c(-1.4, 2.3)
### Noise standar deviations (Two responses)
sdMA  <- c(sqrt(6.5), sqrt(4.0))
### A single covariate.
Xcov <- runif(nn)

# Generating two MA processes, TS1 and TS2, Gaussian noise.
# Note, the SD noise for TS2 is function of Xcov.

y1   <- mu[1] + arima.sim(nn, 
                          model = list( ma = c(phi1, phi1^2)), 
                          rand.gen = rnorm, sd = exp(sdMA[1]) ) 
y2   <- mu[2] + arima.sim(nn, 
                          model = list( ma = c(phi1, phi2, phi3) ), 
                          rand.gen = rnorm, sd = exp(Xcov + sdMA[2]) )
# OUR DATA
tsdata <- data.frame(x2 = Xcov , TS1 = y1, TS2 = y2)

#------------------------------------------------------------------------#
# 1. A simple MA(3) to compare with 'arima()'.

myfit0 <- vglm(TS1 ~ 1,
               MAXff(order = 3, type.EIM = "exact",
                    var.arg = FALSE),
               #constraints = cm.ARMA(Model = ~ 1, 
               #                      lags.cm = 2, 
               #                      Resp = 1),
               data = tsdata, trace = TRUE) 

Coef(myfit0)[c(3, 4, 1)]
fitArima <- arima(tsdata$TS1, order = c(0, 0, 2)) 
coef(fitArima)

AIC(myfit0); BIC(myfit0)

# ------------------------------------------------------------------------#
# 2. Estimate an MA(3), intercept-only, using initial values.

myfit <- vglm(TS2 ~ 1,
              MAXff(order = 3, type.EIM = c("exact", "approx")[1],
                   # Optional initial values.
                    imean = 3,
                    iMAcoeff = c(0.3, -0.2, 0.25),
                   var.arg = TRUE),
              data = tsdata, trace = TRUE)

Coef(myfit)
summary(myfit)
constraints(myfit)


#----------------------------------------#
# Same model fitted using arima()
#----------------------------------------#

fitArima <- arima(tsdata$TS2, order = c(0, 0, 3)) 
coef(fitArima)


#------------------------------------------------------------------------#
# 3. An MAX(3) with one covariate, testing its effect over the
#    standard deviation of the Gaussian noise. Note the 'zero' argument.

myfit1 <- vglm(TS2 ~ x2,
               # Or Multiple responses! 
               # cbind(TS1, TS2) ~ 1,
               MAXff(order = 3, type.EIM = "exact", xLag = 1,
                    # Optional initial values:
                    # idev.mean = 1.4, 
                    # iMAcoeff = c(2.3, -1.2, 0.25), isd = 1.6,
                    
                    # NOTE THE ZERO ARGUMENT:
                    zero = c("Mean", "MAcoeff"),
                    
                    var.arg = TRUE),
               data = tsdata, trace = TRUE)

coef(myfit1, matrix = TRUE) 
summary(myfit1)
vcov(myfit1)

constraints(myfit1)

#------------------------------------------------------------------------#
# Model above CANNOT be fitted using arima()
#------------------------------------------------------------------------#


[Package VGAMextra version 0.0-6 Index]