MAXff: VGLTSMs Family Functions: Order-q Moving Average Model with...

Description Usage Arguments Details Value Warning Note Author(s) References See Also Examples

View source: R/TSfamilyMAX.R

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
      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] | Φ[t - 1] = μ[t] + φ[1] e[t - 1] + … + φ[q] e[t - p] + e[t],

where μ[t] is the (possibly time–dependent) intercept, modelled as mu[t] = μ + β^T x[t], and the errors are mean–zero Gaussian: e[t] | Φ[t - 1] ~ N(0 , σ[e]^2 | Φ [t - 1] ) . The symbol Φ[t] denotes the history of the joint process (Y[t], X[t + 1]) , at time t for a time–varying covariate vector 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

η = (μ[t], log σ[e]^2 | Φ[t - 1], φ[1], …, φ[q] )^T.

The unconditional mean of the process is simply E(Y[t]) = μ , 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 σ[e]^2 | Φ[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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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()
#------------------------------------------------------------------------#

VGAMextra documentation built on May 24, 2021, 9:07 a.m.