Sparse VAR (sparsevar)

License Version CRAN_Status_Badge Downloads

Some R functions useful to estimate sparse VAR / VECM models.


To install the stable version from CRAN:


To install the developing version:

devtools::install_github("svazzole/sparsevar", "master")

Check here to understand which are the dependencies of devtools for your OS.

Quick start

To load the sparsevar package simply type


Using the function included in the package, we simply generate a 20x20 VAR(2) process

sim <- simulateVAR(N = 20, p = 2)

This command will generate a model with two sparse matrices with 5% of non-zero entries and a Toeplitz variance-covariance matrix with rho = 0.5. We can estimate the matrices of the process using for example

fit <- fitVAR(sim$series, p = 2, threshold = TRUE)

The results can be seen by plotting the two var objects

plotVAR(sim, fit)

the first row of the plot is made by the matrices of the simulated process and the second row is formed by their estimates.

The fit contains also the estimate of the variance/covariance matrix of the residuals


which can be compared with the covariance matrix of the errors of the generating process



The functions included for model estimation are:

For simulations:

For plotting:


[1] Basu, Sumanta; Michailidis, George. Regularized estimation in sparse high-dimensional time series models. Ann. Statist. 43 (2015), no. 4, 1535--1567. doi:10.1214/15-AOS1315.