ECM.EngleGran {VGAMextra} | R Documentation |
VGLTSM family function for the
Two–dimensional Error–Correction Model
(Engle and Granger, 1987) for
–variables
Description
Estimates a bidimensional error-correction model of
order–(,
), as proposed by Engle–Granger
(Two step–approach; 1987), with bivariate normal errors
by maximum likelihood estimation using Fisher scoring.
Usage
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 |
resids.pattern |
Character. How the static linear regression
|
lag.res |
Numeric, single positive integer. The error
term for the long–run equilibrium path is
lagged up to order |
lmean , lvar , lcov |
Same as |
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–(,
) bidimensional error correction
model (ECM) with bivariate normal errors.
This ECM class models the dynamic behaviour of two
cointegrated -variables,
say
and
with,
probably,
a function of
.
Note, the response must be a two–column matrix,
where the first entry is the regressor,
i.e,
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
Under the binormality assumption on the errors
with covariance matrix
,
model above can be seen as a
VGLM fitting linear models over the conditional means,
and
,
producing
The covariance matrix is assumed
to have elements
and
Hence, the parameter vector is
for and
.
The linear predictor is
The estimated cointegrated vector,
=
is obtained by linear regression
depending upon
resids.pattern
,
as follows:
1) ,
if
resids.pattern = "intercept"
,
2) ,
if
resids.pattern = "trend"
,
3) ,
if
resids.pattern = "neither"
, or else,
4) ,
if
resids.pattern = "both"
,
where and
assigns the error term.
Note, the estimated residuals,
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
and
above.
By default,
are considered (as
lag.res
= 1), although it may be any lag
, for
.
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 and
grows.
See
rrvglm
.
By default, and
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,
instead of
in models
and
.
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
## 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)