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

Estimate either a VAR or a VECM.

1 2 3 4 |

`data` |
multivariate time series (first row being first=oldest value) |

`lag` |
Number of lags to include in each regime |

`r` |
Number of cointegrating relationships |

`include` |
Type of deterministic regressors to include |

`model` |
Model to estimate. Either a VAR or a VECM |

`I` |
For VAR only: whether in the VAR the variables are to be taken in levels (original series) or in difference, or similarly to the univariate ADF case. |

`beta` |
for VECM only: user-specified cointegrating value.
If NULL, will be estimated using the estimator specified in |

`estim` |
Type of estimator for the VECM: '2OLS' for the two-step approach or 'ML' for Johansen MLE |

`LRinclude` |
Possibility to include in the long-run relationship and the ECT a trend, a, constant, etc. Can also be a matrix with exogeneous regressors |

`exogen` |
Inclusion of exogenous variables (first row being first=oldest value). Is either of same size than data (then automatically cut) or than end-sample. |

This function provides basic functionalities for VAR and VECM models. More comprehensive functions are in package vars. A few differences appear in the VECM estimation:

- Engle-Granger estimator
The Engle-Granger estimator is available

- Presentation
Results are printed in a different ways, using a matrix form

- lateX export
The matrix of coefficients can be exported to latex, with or without standard-values and significance stars

Two estimators are available: the Engle-Granger two-steps
approach (`2OLS`

) or the Johansen (`ML`

). For the 2OLS,
deterministic regressors (or external variables if `LRinclude`

is of
class numeric) can be added for the estimation of the cointegrating value and
for the ECT. This is only working when the beta value is not pre-specified.

The argument `beta`

is only for `VECM`

, look at the specific help page for more details.

Fitted model data

Matthieu Stigler

`VECM`

which is just a wrapper for `lineVar(..., model="VECM")`

.
Methods `predict.VAR`

, `VARrep`

, `regime`

, `irf`

and `toLatex`

.

`TVAR`

and `TVECM`

for the corresponding threshold
models. `linear`

for the univariate AR model.

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 | ```
data(zeroyld)
#Fit a VAR
VAR <- lineVar(zeroyld, lag=1)
VAR
#summary(VAR)
#compare results with package vars:
if(require(vars)) {
a<-VAR(zeroyld, p=1)
coef_vars <- t(sapply(coef(a), function(x) x[c(3,1,2),1]))
all.equal(coef(VAR),coef_vars, check.attributes=FALSE)
}
###VECM
VECM.EG <- lineVar(zeroyld, lag=2, model="VECM")
VECM.EG
#summary(VECM.EG)
VECM.ML <- lineVar(zeroyld, lag=2, model="VECM", estim="ML")
VECM.ML
#summary(VECM.ML)
###Check Johansen MLE
myVECM <- lineVar(zeroyld, lag=1, include="const", model="VECM", estim="ML")
myVECM
#summary(myVECM, digits=7)
#comparing with vars package
if(require(vars)){
a<-ca.jo(zeroyld, spec="trans")
a
#summary(a)
#same answer also!
}
##export to Latex
#toLatex(VECM.EG)
#toLatex(summary(VECM.EG))
options("show.signif.stars"=FALSE)
#toLatex(summary(VECM.EG), parenthese="Pvalue")
options("show.signif.stars"=TRUE)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.