Sparse VAR/VECM Models Estimation

A wrapper for sparse VAR/VECM time series models estimation using penalties like ENET (Elastic Net), SCAD (Smoothly Clipped Absolute Deviation) and MCP (Minimax Concave Penalty). Based on the work of Sumanta Basu and George Michailidis .

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:

  • fitVAR: to estimate a sparse VAR multivariate time series with ENET, SCAD or MC+;
  • fitVECM: to estimate a sparse VECM (Vector Error Correction Model) using LS with penalty (again: ENET, SCAD or MC+);
  • impulseResponse: compute the impulse response function;
  • errorBands: estimate the error bands for the IRF (using bootstrap);

For simulations:

  • simulateVAR: to generate a sparse VAR multivariate time series;
  • createSparseMatrix: used to create sparse matrices with a given density;

For plotting:

  • plotMatrix: useful to plot matrices and sparse matrices;
  • plotVAR: plot all the matrices of the model or models in input;
  • plotIRF: plot IRF function;
  • plotGridIRF: multiple plots of IRF.


[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.


sparsevar 0.0.10

  • Added plotVECM function
  • Removed plotComparisonVAR (substituted by plotVAR)
  • Added the option to generate VARs with given matrices
  • Fixed AIC
  • Fixed problems with error bands options
  • Added tests
  • Added the function computeForecasts

sparsevar 0.0.9

  • Fast SCAD estimation (using picasso package; works only with SCAD and timeSlice)
  • Added function to compute VAR forecasts
  • Added information criteria (AIC, SChwartz and Hannan-Quinn)
  • Fixed mean estimation for timeSlice

sparsevar 0.0.7

  • Major code rewriting
  • Remove dependecies from MTS and caret
  • Added impulse response error bands (using bootstrap)
  • Added plot functions for IRF
  • New timeSlice estimation
  • Removed repeated cross validation

sparsevar 0.0.6

  • Added impulse response function for VAR processes

sparsevar 0.0.5

  • Added timeSlice estimation
  • Fixed normalization constant in creating sparse var matrix
  • Fixed parallel backend in Windows

sparsevar 0.0.4

  • Added as output the residuals of the estimation (for estimateVAR)
  • Fixed parallel background in LASSO estimation
  • Now repeatedCV returns MSE

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.0.11 by Simone Vazzoler, a year ago

Report a bug at

Browse source code at

Authors: Simone Vazzoler [aut, cre]

Documentation:   PDF Manual  

Task views: Time Series Analysis

GPL-2 license

Imports Matrix, ncvreg, parallel, doParallel, glmnet, ggplot2, reshape2, grid, mvtnorm, picasso, corpcor

Suggests knitr, testthat

Suggested by fsMTS.

See at CRAN