由於在Stata中使用cluster
選項,所以標準錯誤不同。
R:
data(Grunfeld)
library(plm)
grun.re <- plm(inv~-1+value+capital,data=Grunfeld,model="fd")
> summary(grun.re)
Oneway (individual) effect First-Difference Model
Call:
plm(formula = inv ~ -1 + value + capital, data = Grunfeld, model = "fd")
Balanced Panel: n=10, T=20, N=200
Residuals :
Min. 1st Qu. Median Mean 3rd Qu. Max.
-202.00 -15.20 -1.76 -1.39 7.95 199.00
Coefficients :
Estimate Std. Error t-value Pr(>|t|)
value 0.0890628 0.0082341 10.816 < 2.2e-16 ***
capital 0.2786940 0.0471564 5.910 1.58e-08 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
塔塔
reg D.(inv value capital), nocons
Source | SS df MS Number of obs = 190
-------------+------------------------------ F( 2, 188) = 70.58
Model | 259740.92 2 129870.46 Prob > F = 0.0000
Residual | 345936.615 188 1840.08838 R-squared = 0.4288
-------------+------------------------------ Adj R-squared = 0.4228
Total | 605677.536 190 3187.7765 Root MSE = 42.896
------------------------------------------------------------------------------
D.inv | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
value |
D1. | .0890628 .0082341 10.82 0.000 .0728197 .1053059
|
capital |
D1. | .278694 .0471564 5.91 0.000 .1856703 .3717177
如果要通過組集羣,這裏是解決方案:
R:
library(lmtest) # for coeftest function
coeftest(grun.re,vcov=vcovHC(grun.re,type="HC0",cluster="group"))
t test of coefficients:
Estimate Std. Error t value Pr(>|t|)
value 0.089063 0.013728 6.4878 7.512e-10 ***
capital 0.278694 0.130954 2.1282 0.03462 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
塔塔:
. reg D.(inv value capital), nocons cluster(firm)
Linear regression Number of obs = 190
F( 2, 9) = 47.80
Prob > F = 0.0000
R-squared = 0.4288
Root MSE = 42.896
(Std. Err. adjusted for 10 clusters in firm)
------------------------------------------------------------------------------
| Robust
D.inv | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
value |
D1. | .0890628 .0145088 6.14 0.000 .0562416 .1218841
|
capital |
D1. | .278694 .138404 2.01 0.075 -.0343976 .5917857
------------------------------------------------------------------------------
你可以看到,有細微的差別。有關R的詳細信息,請參閱plm manual第39頁以及here加here
謝謝。我應該已經意識到,plm只是對差異數據運行OLS而不調整面板結構。有沒有辦法讓它聚集在ID(或更合適的東西)? –
我已經更新了答案。但是,有一點差異。你可以檢查參考。 – Metrics
它是否仍在「plm手冊」第39頁?或者它是關於'vcovHC魯棒協方差矩陣估計器'的一節,在第65頁(版本1.4-0)?謝謝 – pidosaurus