estimates table fd_2 fd_2t3 fod_1 fod_1t2 , b(%3.2f) se(%3.2f) stats(N J J_pval) modelwidth(8)
sjlog close, replace
sjlog using pvar14, replace
pvar ln_wks ln_wage, fd instlags(2/3) gmmstyle
estimates store fd_2t3g
pvar ln_wks ln_wage, fod instlags(1/2) gmmstyle
estimates store fod_1t2g
estimates table fd_2t3g fod_1t2g, b(%4.2f) se(%4.2f) stats(N J J_pval) modelwidth(8)
sjlog close, replace
sjlog using pvar15, replace
pvarsoc ln_wks ln_wage, maxl(3) pvaropts(instlags(1/3) fod gmmstyle)
sjlog close, replace
sjlog using pvar16, replace
pvarsoc ln_wks ln_wage, maxl(3) pvaropts(instlags(2/4) fod gmmstyle)
sjlog close, replace
案例2:psidextract数据
简介:我们使用psidextract数据,我们复制了Holtz-Eakin、Newey和Rosen(1988)中表2所示的简化形式的面板VAR,使用了Stata中收入与动态(PSID)面板研究数据中对1976-1982年528名男性的观察。
在他们最初的分析中,Holtz-Eakin, Newey和Rosen(1988)使用了1968年至1981年期间观察到的898名男性样本,使用了年工作时间和年平均时薪。所以我们的样品成分和时间段与原始的文章略有不同。在本例中,假设对数转换工资率(lwage)和工作周数(lwks)是每个变量的三个滞后函数。我们还假设工资率和工作周的系数在整个样本中是普遍的,并且系统的个体异质性被个体固定效应所捕获。变量fem是一个表示被调查者性别的二元变量。
本部分完整操作请查看文章:
面板VAR模型教程(建模动作+代码+结果)
Stata:面板向量自回归操作教程
完整代码为:
// Example 1: PSID
sjlog using pvar1, replace
webuse psidextract
generate lwks = ln(wks)
pvar lwks lwage iffem == 0, lags(3)
sjlog close, replace
sjlog using pvar2, replace
pvargranger
sjlog close, replace
sjlog using pvar3, replace
pvarstable
sjlog close, replace
sjlog using pvar4, replace
pvarstable, graph
sjlog close, replace
graph exportpvar1.eps, replace
sjlog using pvar5, replace
pvarirf, oirf mc(200) byoption(yrescale) porder(lwage lwks)
sjlog close, replace
graph exportpvar2.eps, replace
capture erase fevd_ci.dta
sjlog using pvar6, replace
pvarfevd, mc(200) porder(lwage lwks) save( "fevd_ci.dta")
sjlog close, replace
sjlog using pvar7, replace
pvarsoc lwks lwage iffem == 0, pvaropts(instlags(1/4))
sjlog close, replace
sjlog using pvar8, replace
pvar lwks lwage iffem == 0, lags(1) instlags(1/4)
pvargranger
sjlog close, replace
sjlog using pvar9, replace
xtunitroot ht lwks iffem == 0
xtunitroot ht lwage iffem == 0
sjlog close, replace
sjlog using pvar10, replace
generate gwage = (exp(lwage)-exp(l.lwage))/exp(l.lwage)
generate gwks = (wks - l.wks)/l.wks
xtunitroot ht gwks iffem == 0
xtunitroot ht gwage iffem == 0
pvarsoc gwks gwage iffem == 0, pvaropts(instlags(1/4))
pvar gwks gwage iffem == 0, lags(1) instlags(1/4)
pvargranger
sjlog close, replace
案例3:lutkepohl2数据
代码为:
/ Example comparing -pvar- and -var- using time-series data
webuse lutkepohl2
gen id = 1
xtset id qtr
* Estimate VAR model
qui var dln_inv dln_inc dln_consump, lags(1)
est store var1
* Estimate pVAR models
qui pvar dln_inv dln_inc dln_consump, lags(1)
est store pvar1_1
qui pvar dln_inv dln_inc dln_consump, lags(1) instl(1/5) gmms
est store pvar1_5
* Comare VAR estimates
est table var1 pvar1_1 pvar1_5, se stat(N tmin tmax) drop(_cons)
* Create -var- IRF file
est restore var1
irf create varirf, step(10) set(myirf1, replace)
* Compare FEVD
irf table fevd, response(dln_inv) noci
pvarfevd, response(dln_inv)
* Compare IRF - all variables
irf graph oirf, byop(yrescale)
est restore pvar1_1
pvarirf, byop(yrescale) oirf mc(200)
* Compare IRF - dln_inv:dln_inv
irf graph oirf, i(dln_inv) r(dln_inv) title( "VAR1") saving(var1_irf, replace)
est restore pvar1_1
pvarirf, imp(dln_inv) res(dln_inv) oirf mc(200) title( "PVAR1_1")
graph save pvar1_1_irf, replace
est restore pvar1_5
pvarirf, imp(dln_inv) res(dln_inv) oirf mc(200) title( "PVAR1_5")
graph save pvar1_5_irf, replace
graph combine var1_irf.gph pvar1_1_irf.gph pvar1_5_irf.gph
案例4:grunfeld数据
本部分完整操作请查看文章: Stata:面板VAR模型(pvar2命令)
* # 3.1、导入数据,然后修改变量名称,设定