2015-08-13 49 views
1

我看了一下plm(面板模型的R軟件包)如何實現隨機效應的Breusch-Pagan測試,並注意到它沒有考慮到不平衡面板Breusch-Pagan隨機效應測試在不平衡面板的plm中的實現

plmtest()並未警告您。對於不平衡面板,我們需要如Baltagi/Li(1990)給出的隨機效應的Breusch-Pagan測試的另一版本: 對於不完整面板的誤差分量模型的拉格朗日乘數測試,Econometric Reviews,9:1,103 -107,DOI:10.1080/07474939008800180。由於本文是一個有點難以閱讀,你也可以看看STATA是怎麼做的:http://www.stata.com/manuals13/xtxtregpostestimation.pdf

編輯 修改測試允許不平衡面板現在是在包裝上CRAN(因爲版本1.6-4) 。

回答

0

編輯:中plm從1.6-4在CRAN的版本(2016年12月)還設有plmtest()不平衡檢驗統計量。

由於現在已經解決,我會在這裏發佈答案。 代碼現在是在R-僞造發展v1.15-16的plm版本: https://r-forge.r-project.org/projects/plm/https://r-forge.r-project.org/R/?group_id=406

這裏是如何複製從塔塔的文檔的例子:

# get data set from STATA's webpage 
# It is an unbalanced panel 
require(haven) # required to read STATA data file 
nlswork <- read_dta("http://www.stata-press.com/data/r14/nlswork.dta") 
nlswork$race <- factor(nlswork$race) # fix data 
nlswork$race2 <- factor(ifelse(nlswork$race == 2, 1, 0)) # need this variable for example 
pnlswork <- pdata.frame(nlswork, index=c("idcode", "year"), drop.index=F) 

# note STATA 14 uses by default a different method compared to plm's Swamy–Arora variance component estimator 
# This is why in comparison with web examples from STATA the random effects coefficients slightly differ 
plm_re_nlswork <- plm(ln_wage ~ grade + age + I(age^2) + ttl_exp + I(ttl_exp^2) + tenure + I(tenure^2) + race2 + not_smsa + south 
         , data = pnlswork, model = "random") 

# reassembles the FE estimation by STATA in Example 2 of http://www.stata.com/manuals13/xtxtreg.pdf 
plm_fe_nlswork <- plm(ln_wage ~ grade + age + I(age^2) + ttl_exp + I(ttl_exp^2) + tenure + I(tenure^2) + race2 + not_smsa + south 
         , data = pnlswork, model = "within") 

plm_pool_nlswork <- plm(ln_wage ~ grade + age + I(age^2) + ttl_exp + I(ttl_exp^2) + tenure + I(tenure^2) + race2 + not_smsa + south 
         , data = pnlswork, model = "pooling") 


# Run Breusch-Pagan test with modification for unbalanced panels of Baltahi/Li (1990) 
# Reassembles Exmaple 1 in http://www.stata.com/manuals13/xtxtregpostestimation.pdf 

plmtest(plm_pool_nlswork)  
## Lagrange Multiplier Test - individual effects - Breusch-Pagan Test for unbalanced Panels as in Baltagi/Li (1990) 
## data: ln_wage ~ grade + age + I(age^2) + ttl_exp + I(ttl_exp^2) + tenure + ... 
## BP_unbalanced = 14779.98, df = 1, p-value < 0.00000000000000022 
## alternative hypothesis: significant effects