I am working on vector auto-regression (VARs) and impulse response function (IRFs) estimation based on panel data with 33 individuals over 77 quarters. How should this type of situation be analyzed? What algorithm's exist for this purpose? I would prefer to conduct these analyses in R, so if anyone is familiar with R code or a package designed for this purpose that they could suggest, that would be especially helpful.
-
$\begingroup$ Welcome to the site, @Roman. Asking for R packages is off-topic for CV (see our help page). Moreover, this Q would be off-topic on Stack Overflow as well. You might try the r-help listserv. $\endgroup$– gung - Reinstate MonicaCommented Oct 16, 2013 at 17:34
-
$\begingroup$ This question appears to be off-topic because it is about asking for R packages. $\endgroup$– gung - Reinstate MonicaCommented Oct 16, 2013 at 17:34
-
$\begingroup$ could I ask for the algorithm for panel VAR estimation? $\endgroup$– RomCommented Oct 16, 2013 at 17:40
-
3$\begingroup$ Sure, you can ask about how to deal w/ this situation, & in the process of answering someone might be able to provide some helpful R code (or not...). It's just asking 'what package will do X' that's off-topic. If you want the question to stay here (& stay open), just edit your Q to make it on-topic. It may help you to read the relevant section of the help page & our guide to asking questions in reformulating your Q. $\endgroup$– gung - Reinstate MonicaCommented Oct 16, 2013 at 17:51
-
$\begingroup$ I edited this in the hopes that it might lead to more productive answers for you. Please make sure it is still asking what you want to know & see if you like it. If not, click "rollback" to return it to your last edit with my apologies. $\endgroup$– gung - Reinstate MonicaCommented Oct 16, 2013 at 18:18
6 Answers
Here you will find the R-package and the link to the paper.
-
$\begingroup$ I've created a parallelized version of the code to bootstrap the impulse response functions at github.com/hannes101/ParallelPanelVAR $\endgroup$ Commented Apr 11, 2018 at 8:31
Common panel data vector autoregression models include the Arellano-Bond estimator (commonly referred to as "difference" GMM), the Blundell-Bond estimator (commonly referred to as "system" GMM) and the Arellano-Bover estimator. All use GMM, and begin with a model: $$y_{it}=\sum_{l=1}^p\rho_ly_{i,t-l}+x_{i,t}'\beta+\alpha_i+\epsilon_{it} $$
Arellano and Bond takes the first difference of $y_{i,t}$ to remove the fixed effect, $\alpha_i$ and then uses lagged levels as instruments: $$ E[\Delta \epsilon_{it}y_{i,t-2}]=0$$
This is basically the same as the procedure detailed in this Holtz-Eakin Newey Rosen article, which also provides some instructions for implementation.
Blundell and Bond use lagged first differences as instruments for levels:
$$ E[\epsilon_{it}\Delta y_{i,t-1}]=0$$ The name "system" GMM usually means a mix of these instruments with those from Arellano Bond.
Arellano and Bover use the system GMM and also explore forward demeaning of variables, which to my knowledge is not directly implemented for R
, but you can check out their paper for details.
In R
, both Arellano-Bond and Blundell-Bond are implemented in the plm
package, under the command pgmm
. The documentation I've linked to provides instructions and examples for exactly how to implement them.
-
$\begingroup$ Thank you very much! I used plm package for simple panels. And I was worring about its application for PVARs. Thank you. $\endgroup$– RomCommented Nov 24, 2014 at 17:25
-
1$\begingroup$ researchgate.net/publication/322526372_panelvar_044 you will find the package here. Good luck with your research $\endgroup$ Commented Jan 20, 2018 at 20:16
You can use a system of seemingly unrelated regression equations (using the package systemfit) after you convert the dataset with pdata.frame (plm package). You need to derive the impulse response functions by yourself. If you follow Hamilton's or Greene's textbook, it should not be too complicated.
I just found this paper "Panel Vector Autoregression in R: The Panelvar Package" (2017) by Michael Sigmund, Robert Ferstl and Daniel Unterkofler, which basically is a description of the methods implemented in R. https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2896087
Additionally, there's another question here: Panel vector autoregression models in R?
The authors are now in the process of publishing the code on CRAN, but already provide binary packages on researchgate. https://www.researchgate.net/project/Panel-Vector-Autoregression-Models-with-different-GMM-estimators
The binary panelvar package can be downloaded directly, I think sources should be available on CRAN in the near future. https://www.researchgate.net/publication/322526372_panelvar_044
-
1$\begingroup$ Link-only answers may become useless if link breaks (this really happens). You could expand your answer with presentation of major concepts from the paper, you link to. Or at least write 'check out
Panelvar
package. $\endgroup$ Commented Jul 11, 2017 at 8:50 -
$\begingroup$ Well, the package is not yet published anywhere, so I basically just wanted to add some references. Hope this is now enough. $\endgroup$ Commented Jul 11, 2017 at 8:53
-
2$\begingroup$ Yes, that's better. Now I can search for this paper even if your link breaks. Thanks! $\endgroup$ Commented Jul 11, 2017 at 9:00
-
$\begingroup$ The package
panelvar
is available on CRAN by now. Once installed and loaded, I would start at?pvargmm
$\endgroup$– altabqCommented Jul 9, 2019 at 14:38
I would suggest using the {vars}
library in R. It has a function for estimating a VAR-model and for estimating an impulse response function from this model and for investigating Granger causality etc.
I suggest you look into the following functions:
> VARselect()
> VAR()
> irf()
> causality()
-
$\begingroup$ thank you @fredrikhs for your comments. actually {vars} is good for time-series. how to use this package for the purpose of panels? direct applying doesn't work... $\endgroup$– RomCommented Oct 17, 2013 at 9:21
-
$\begingroup$ Can you give an example, what does the data look like? $\endgroup$ Commented Oct 17, 2013 at 14:04
-
$\begingroup$ The data is in ordinary format as for the {plm} package purpose. Vars: ID country year REER GDP FinalConsumpExpend DimesticDemand ...(21 vars in total) over 1994Q1:2003Q1 period of time $\endgroup$– RomCommented Oct 21, 2013 at 5:23
-
$\begingroup$ The
vars
package does not work with panel data, afaik $\endgroup$– altabqCommented Jul 9, 2019 at 13:56
Hi @Roman and every one else. I am also in panel VAR models and in my search, I came across this stata-based user-written commands pvar and xtvar. I have used pvar already and it seems quite okay. You can read more about it here, and a step-by-step application
-
$\begingroup$ here is the link to the pvar command and application: paneldataconference2015.ceu.hu/Program/Michael-Abrigo.pdf $\endgroup$– AyobamiCommented Jul 16, 2017 at 15:40
-
1$\begingroup$ The OP asked for R code so I am not sure why you think Stata would be any help to him. Perhaps you can edit your answer to elaborate? $\endgroup$– mdeweyCommented Jul 16, 2017 at 16:16