搜索
人大经济论坛 附件下载

附件下载

所在主题:
文件名:  SSRN-id2896087.pdf
资料下载链接地址: https://bbs.pinggu.org/a-2433314.html
附件大小:
207.73 KB   举报本内容
在R中进行面板向量自回归(panel var)的程序。实际上还包括了对应于Stata中动态面板xtabond2的R程序







In this paper we extend two general methods of moment estimators to panel vector autoregression models (PVAR) with p lags of endogenous variables, predetermined and strictly exogenous variables. First, the first difference GMM estimator (Holtz-Eakin et al., 1988; Arellano and Bond, 1991) is extended to this general PVAR model. Second, we do the same for the system GMM estimator (Blundell and Bond, 1998). We implement these estimators in the R package panelvar. In addition to the GMM-estimators we contribute to the literature by providing specification tests (Hansen overidentification test, lag selection criterion and stability test of the PVAR polynomial) and classical structural analysis for PVAR models such as orthogonal and generalized impulse response functions, bootstrapped confidence intervals for impulse response analysis and forecast error variance decompositions. Finally, we implement the first difference and the forward orthogonal transformation to remove the fixed effects.

在Rstudio中安装package步骤:“Tools” ->“Install packages” -> "Install from Package Archive File" 然后选择zip


Examples with Cigar Data

We apply our package to the Cigar data set which was used by Baltagi and Levin (1992), Baltagi, Griffin, and Xiong (2000) and Croissant and Millo (2008). The data set covers variables that are relevant for cigarette demand in 46 American states over the period 1963 to 1992. These variables include price, sales, population, population over 16 years, consumer price inflation and minimum price. Especially, the availability of price and quantity are a classical example for vector autoregression models.

library(panelvar)data(Cigar)ex1_cigar_data <- pvargmm(dependent_vars = c("log_sales", "log_price"), lags = 1, predet_vars = c("log_ndi"), exog_vars = c("cpi", "log_pop16"), transformation = "fod", data = Cigar, panel_identifier= c("state", "year"), steps = c("twostep"), system_instruments = TRUE, max_instr_dependent_vars = 10, max_instr_predet_vars = 10, min_instr_dependent_vars = 2L, min_instr_predet_vars = 1L, collapse = TRUE)summary(ex1_cigar_data)

Dynamic Panel VAR estimation, twostep GMM

Transformation: Forward orthogonal deviations
Group variable: state
Time variable: year
Number of observations = 1380
Number of groups = 46
Obs per group: min = 30
Obs per group: avg = 30
Obs per group: max = 30

fod_log_sales

fod_log_price

fod_lag1_log_sales0.8517***-0.0350**
(0.0231)(0.0136)
fod_lag1_log_price-0.0981***0.8512***
(0.0185)(0.0147)
fod_log_ndi0.1172***0.0561***
(0.0203)(0.0137)
fod_cpi-0.0011***0.0017***
(0.0003)(0.0002)
fod_log_pop16-0.00500.0000
(0.0041)(0.0020)
const0.1930***0.2080***

(0.0110)

(0.0058)

[size=0.8em]p < 0.001, p < 0.01, p < 0.05

Hansen test of overid. restrictions: chi2(56) = 39.69 Prob > chi2 = 0.951
(Robust, but weakened by many instruments.)



Next, we test the stability of the autoregressive process:

stab_ex1_cigar_data <- stability(ex1_cigar_data)print(stab_ex1_cigar_data)
## Eigenvalue stability condition:## ## Eigenvalue Modulus## 10.9100521 0.9100521## 20.7928343 0.7928343## ## All the eigenvalues lie inside the unit circle.## PVAR satisfies stability condition.plot(stab_ex1_cigar_data)


In vector autoregression models researchers are often interested in impuls response analysis. Recently, researcher prefer the generalized impuls response analysis (GIRF) introduced by Pesaran and Shin (1998) to orthogonal impuls response analysis (OIRF) as it is independent of the ordering of the endogenous variables. However, GIRF and OIRF are closely related. Lin (2006) states that when <span class="MathJax" id="MathJax-Element-7-Frame" tabindex="0" data-mathml="Σϵ" role="presentation" style="display: inline; line-height: normal; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">ΣϵΣϵ is diagonal OIRF and GIRF are the same. The GIRF of the effect of an unit shock to the r-th equation is the same as that of an orthogonal impulse response but different for other shocks. Hence, the GIRF can easily computed by using OIRF with each variable as the leading one.

ex1_cigar_data_girf <-girf(ex1_cigar_data, n.ahead = 12, ma_approx_steps= 12)ex1_cigar_data_oirf <-oirf(ex1_cigar_data, n.ahead = 12)

plot(ex1_cigar_data_girf, ex1_cigar_data_bs)




    熟悉论坛请点击新手指南
下载说明
1、论坛支持迅雷和网际快车等p2p多线程软件下载,请在上面选择下载通道单击右健下载即可。
2、论坛会定期自动批量更新下载地址,所以请不要浪费时间盗链论坛资源,盗链地址会很快失效。
3、本站为非盈利性质的学术交流网站,鼓励和保护原创作品,拒绝未经版权人许可的上传行为。本站如接到版权人发出的合格侵权通知,将积极的采取必要措施;同时,本站也将在技术手段和能力范围内,履行版权保护的注意义务。
(如有侵权,欢迎举报)
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

GMT+8, 2026-1-24 10:20