buildVECM: Building a Vector Error Correction Model

Description Usage Arguments Details Value See Also Examples

Description

A quick way to investigate the short run relationship of cointegrating variables moving to equilibrium.

The function creates the formula format for the VECM equation from the cointegrating relationship. Where the cointegrating relationship is Y ~ X1 + X2 and the non-stationary variables are c(z1, z2), the VECM equation is diff(Y) ~ 1 + L(ErrPos, 1) + L(ErrNeg, 1) + L(diff(X1), 1:k) + L(diff(X2), 1:k) + L(diff(Y), 1:k) + L(z1, 1:k) + L(z2, 1:k), with k = the number of lags.

ErrPos and ErrNeg come from the Error equation Y - Yhat predicted from the coefficients*parameters of a DOLS equation.

It then determines a maximum lag number based of off the number of observations using an ad hoc method and runs the model ad the varying lag sizes, keeping the observation start and end dates restricted to the strictest range. The final number of lags to be chosen is selected by choosing the smallest akaike information criterion value (AIC).

It also calculates the robust standard errors using Newey West with assistance of the lmtest and sandwhich packages.

Usage

1
 buildVECM(coint_formula, data, stationary_vars = NULL, fixedk = NULL, SplitError = TRUE, robusterrors = TRUE, fixedk_DOLS = NULL, selection = AIC) 

Arguments

coint_fomula

A representation of the formula that will be built into the VECM short-term equation.

data

The data frame containing the variables to be called by the formula.

stationary_vars

A continuation of the formula consisting of stationary variables within data. Must be written with a leading "~" in the format of "~ Z1" to work.

fixedk

The number of lags that the output will have. If is NULL, determines the number of lags through model selection, starting at a maximum value of floor(nrow(data)^(1/3)).

SplitError

Default is TRUE. If TRUE will include a positive Error and a negative Error term in the model to highlight asymmetries.

robusterrors

The HAC estimator.

fixedk_DOLS

The number of lags/leads that the internal DOLS output, which is used to create the error corrrection term, will have. If is NULL, determines the number of lags/leads through model selection, starting at a maximum value of floor(nrow(data)^(1/3)/2).

selection

The funciton used during model selection. Default set to BIC but can match any function that acts on a model object

Details

A formula has an implied intercept term. To remove this use either y ~ x - 1 or y ~ 0 + x.

Value

Error

returns a 3 column matrix of the decomposed Error (y-yhat from the DOLS non-nuissance parameters), only the Positive changes in Error, and the Negative changes in Error.

selection

returns a table showing the lags and the AIC, fixed observations, for choosing the number of lags to use.

lags

returns the # of lags identified for the model with the smallest AIC.

HAC

returns the robust errors implementing the Newey & West (1987, 1994) heteroskedasticity and autocorrelation consistent (HAC) covariance matrix estimators.

See Also

buildDOLS, aic

Examples

1
2
3
4
5
dat.ts <- ts(Asymmetry[,-1], start = c(2003,6), frequency = 12)
# Use the buildVECM function which does a number of steps displayed in a list object
vecm <- buildVECM(Pgasoline ~ Pcrude, dat.ts, ~ Utilization, SplitError = TRUE, robusterrors = T)
vecm
summary(vecm) 

efriedland/friedland documentation built on Feb. 9, 2021, 11:53 a.m.