ECM.EngleGran: VGLTSM family function for the Two-dimensional...

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

View source: R/ECMEngleGran.R

Description

Estimates a bidimensional error-correction model of order–(K, L), as proposed by Engle–Granger (Two step–approach; 1987), with bivariate normal errors by maximum likelihood estimation using Fisher scoring.

Usage

1
2
3
4
5
6
7
8
9
      ECM.EngleGran(ecm.order = c(1, 1),
                    zero = c("var", "cov"),
                    resids.pattern = c("intercept", "trend",
                                       "neither", "both")[1],
                    lag.res = 1, 
                    lmean = "identitylink",
                    lvar  = "loglink",
                    lcov  = "identitylink",
                    ordtsDyn = 0)

Arguments

ecm.order

Length–2 (positive) integer vector. The order of the ECM model.

zero

Integer or character–string vector. Details at zero.

resids.pattern

Character. How the static linear regression y[2, t] ~ y[1, t] must be settle to estimate the residuals zhat[t]. The default is a linear model with intercept, and no trend term. See below for details.

lag.res

Numeric, single positive integer. The error term for the long–run equilibrium path is lagged up to order lag.res. See below for further details.

lmean, lvar, lcov

Same as MVNcov.

ordtsDyn

Positive integer. Allows to compare the estimated coefficients with those provided by the package 'tsDyn'. See below for further details.

Details

This is an implementation of the two–step approach as proposed by Engle–Granger [1987] to estimate an order–(K, L) bidimensional error correction model (ECM) with bivariate normal errors.

This ECM class models the dynamic behaviour of two cointegrated I(1)-variables, say y[1, t] and y[2, t] with, probably, y[2, t] a function of y[1, t]. Note, the response must be a two–column matrix, where the first entry is the regressor, i.e, y[1, t] above, and the regressand in the second colum. See Example 2 below.

The general specification of the ECM class described by this family function is

Δy[1, t] |Φ[t - 1] = φ[0, 1] + γ[1] zhat[t - k] + ∑_i^K φ[1, i] Δ y[2, t - i] + ∑_j^L φ[2, j] Δ y[1, t - j] + e[1, t],

Δy[2, t] |Φ [t - 1] = ψ[0, 1] + γ[2] zhat[t - k] + ∑_i^K ψ[1, i] Δ y[1, t - i] + ∑_j^L ψ[2, j] Δ y[2, t - j] + e[1, t].

Under the binormality assumption on the errors (e[1, t], e[2, t])^T with covariance matrix V, model above can be seen as a VGLM fitting linear models over the conditional means, μΔy[1, t] = E(Δy[1, t] | Φ[t - 1]) and μΔy[2, t] = E(Δy[2, t] | Φ[t - 1]), producing

(Δy[1, t] | Φ[t - 1], Δy[2, t] | Φ[t - 1])^T ~ N2(μ Δy[1, t], μ Δy[2, t] , V).

The covariance matrix is assumed to have elements σ^2[1], σ^2[2], and Cov[12].

Hence, the parameter vector is

θ = (φ[0, 1], γ[1], φ[1, i], φ[2, j], ψ[0, 1], γ[2], ψ[1, i], ψ[2, j], σ^2[1], σ^[2], Cov[12])^T,

for i = 1, …, K and j = 1, …, L.

The linear predictor is

η = (μ Δy[1], μ Δy[2], log σ^2[1], log σ^2[2], Cov[12] )^T.

The estimated cointegrated vector, βhat* = (1, -βhat)^T is obtained by linear regression depending upon resids.pattern, as follows:

1) y[2, t] = β[0] + β[1] * y[1, t] + z[t], if resids.pattern = "intercept",

2) y[2, t] = β[1] * y[1, t] + β[2] * t + z[t], if resids.pattern = "trend",

3) y[2, t] = β[1] * y[1, t] + z[t], if resids.pattern = "neither", or else,

4) y[2, t] = β[0] + β[1] * y[1, t] + β[2] * t + z[t], if resids.pattern = "both",

where βhat* = (β[0], β[1], β[2])^T, and z[t] assigns the error term.

Note, the estimated residuals, zhat[t] are (internally) computed from any of the linear models 1) – 4) selected, and then lagged up to order alg.res, and embedded as explanatories in models Δy[1, t] |Φ[t - 1] and Δy[2, t] |Φ[t - 1] above. By default, zhat[t - 1] are considered (as lag.res = 1), although it may be any lag zhat[t - k], for k > 0. Change this through argument lag.res.

Value

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

Note

Reduced–Rank VGLMs (RR-VGLMs) can be utilized to aid the increasing number of parameters as K and L grows. See rrvglm.

By default, σ^2[1], σ^[2] and Cov[12] are intercept–only. Set argument zero accordingly to change this.

Package tsDyn also has routines to fit ECMs. However, the bivariate–ECM handled (similar to that one above) differs in their parametrization: tsDyn considers the current estimated residual, zhat[t] instead of zhat[t - 1] in models Δy[1, t] |Φ[t - 1] and Δy[2, t] |Φ[t - 1].

See Example 3 below which compares ECMs fitted with VGAMextra and tsDyn.

Author(s)

Victor Miranda

References

Engle, R.F. and Granger C.W.J. (1987) Co-integration and error correction: Representation, estimation and testing. Econometrica, 55(2), 251–276.

Pfaff, B. (2011) Analysis of Integrated and Cointegrated Time Series with R. Seattle, Washington, USA: Springer.

See Also

MVNcov, rrvglm, CommonVGAMffArguments, Links, vglm.

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
## Example 1. Comparing the Engle -- Granger procedure carried oud by two procedures.
##            ECM.EngleGran() makes easier the fitting process.
## Here, we will use:
## A) The R code 4.2, in Chapter 4, Pfaff (2011).
##    This code 1) generates artificial data and 2) fits an ECM, following
##    the Engle --Granger procedure. 
## B) The ECM.EngleGran() family function to fit the same model assuming
##    bivariate normal innovations. 
## The downside in the R code 4.2 is the assumption of no--correlation among
## the errors. These are generated indenpendently.
## A)
## STEP 1. Set up the data (R code as in Pfaff (2011)).
nn <- 100
set.seed(123456)
e1 <- rnorm(nn)   # Independent of e2
e2 <- rnorm(nn)
y1 <-  cumsum(e1)
y2 <- 0.6 * y1 + e2
lr.reg <- lm(y2 ~ y1)
error <- residuals(lr.reg)
error.lagged <- error[-c(nn - 1, nn)]
dy1 <- diff(y1)
dy2 <- diff(y2)
diff.dat <- data.frame(embed(cbind(dy1, dy2), 2))
colnames(diff.dat) <- c('dy1', 'dy2', 'dy1.1', 'dy2.1')

##  STEP 2. Fit the ECM model, using lm(), R code as in Pfaff (2011).
ecm.reg <- lm(dy2 ~ error.lagged + dy1.1 + dy2.1, data = diff.dat)

summary(ecm.reg)


## B) Now, using ECM.EngleGran() and VGLMs, the steps at A) can be skipped. 
## Enter the I(1)--variables in the response vector only, putting down the
## the dependent variable from the I(1) set, i.e. y2, in the second column.

coint.data <- data.frame(y1 = y1, y2 = y2)
fit.ECM <- vglm(cbind(y1, y2) ~ 1, ECM.EngleGran, data = coint.data, trace = TRUE)

## Check coefficients ##
coef(fit.ECM, matrix = TRUE)  ## Compare 'Diff2' with summary(ecm.reg)
coef(summary(ecm.reg))

head(depvar(fit.ECM))   # The estimated differences (first order)
vcov(fit.ECM)
constraints(fit.ECM, matrix = TRUE)

## Not run: 
### Example 2.  Here, we compare ECM.EngleGran() from VGAMextra with VECM() from
##              package "tsDyn" when fitting an ECM(1, 1). We will make use of
##              the argument 'ordtsDyn' so that the outcomes can be compared.

library("tsDyn")  # Need to be installed first.
fit.tsDyn1 <- with(coint.data, VECM(cbind(y2, y1), lag = 1, estim = "2OLS")) #  MODEL 1
summary(fit.tsDyn1)

### Fit same model using ECM.EngleGran(). NOTE: Set ordtsDyn = 1 !!          #  MODEL 2
fit.ECM.2 <- vglm(cbind(y1, y2) ~ 1, ECM.EngleGran(ecm.order = c(1, 1),
                  resids.pattern = "neither", ordtsDyn = 1),
                  data = coint.data, trace = TRUE)

coef.ECM.2 <- coef(fit.ECM.2, matrix = TRUE)
fit.tsDyn1$coefficients                      ## From pakage 'tsDyn'.
t(coef.ECM.2[, 1:2][c(2, 1, 4, 3), ][, 2:1]) ## FROM VGAMextra 


### Example 3. An ECM(2, 2), with residuals estimated by OLS, with NO intercept
###            and NO trend term. The data set is 'zeroyld', from package tsDyn.
###            ECM.EngleGran() and with VECM() willbe compared again.
data(zeroyld, package = "tsDyn")

# Fit a VECM with Engle-Granger 2OLS estimator:
vecm.eg <- VECM(zeroyld, lag=2, estim = "2OLS") 
summary(vecm.eg)

# For the same data, fit a VECM with ECM.EngleGran(), from VGAMextra.
# Set ordtsDyn = 1 for compatibility! 
fit.ECM.3 <- vglm(cbind(long.run, short.run) ~ 1, ECM.EngleGran(ecm.order = c(2, 2),
                                  resids.pattern = "neither", ordtsDyn = 1),
                  data = zeroyld, trace = TRUE)
coef.ECM.3 <- coef(fit.ECM.3, matrix = TRUE)

#### Compare results
vecm.eg$coefficients                               # From tsDyn
t(coef.ECM.3[, 1:2][c(2, 1, 5, 3, 6, 4 ),][, 2:1]) # FROM VGAMextra

## End(Not run)

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