10

plm我希望一位同事使用R 中的包(或其他包)复制我用 Stata 估计的一阶差分线性面板数据模型。

在 Stata 中,xtreg没有第一个差异选项,所以我运行:

reg D.(y x), nocons cluster(ID)

在 R 中,我正在做:

plm(formula = y ~ -1 + x, data = data, model = "fd", index = c("ID","Period"))

系数匹配,但 R 中的标准误差大于 Stata。我查看了plm帮助和 pdf 文档,但我一定遗漏了一些东西。

4

1 回答 1

13

标准错误是不同的,因为您cluster在 Stata 中使用选项。

回复:

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

如果要按组进行集群,解决方案如下:

回复:

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 手册第 39 页以及此处以及此处

于 2013-09-27T18:24:11.567 回答