Panel data regression: Robust standard errors

前端 未结 2 584
醉梦人生
醉梦人生 2021-02-06 10:07

my problem is this: I get NA where I should get some values in the computation of robust standard errors.

I am trying to do a fixed effect panel regression

2条回答
  •  时光取名叫无心
    2021-02-06 10:54

    The plm package can estimate clustered SEs for panel regressions. The original data is no longer available, so here's an example using dummy data.

    require(foreign)
    require(plm)
    require(lmtest)
    test <- read.dta("http://www.kellogg.northwestern.edu/faculty/petersen/htm/papers/se/test_data.dta")
    
    fpm <- plm(y ~ x, test, model='pooling', index=c('firmid', 'year'))
    
    ##Arellano clustered by *group* SEs
    > coeftest(fpm, vcov=function(x) vcovHC(x, cluster="group", type="HC0"))
    
    t test of coefficients:
    
                Estimate Std. Error t value Pr(>|t|)    
    (Intercept) 0.029680   0.066939  0.4434   0.6575    
    x           1.034833   0.050540 20.4755   <2e-16 ***
    ---
    Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
    

    If you're using lm models (instead of plm), then the multiwayvcov package may help.

    library("lmtest")
    library("multiwayvcov")
    
    data(petersen)
    m1 <- lm(y ~ x, data = petersen)
    
    > coeftest(m1, vcov=function(x) cluster.vcov(x, petersen[ , c("firmid")], 
       df_correction=FALSE))
    
    t test of coefficients:
    
                Estimate Std. Error t value Pr(>|t|)    
    (Intercept) 0.029680   0.066939  0.4434   0.6575    
    x           1.034833   0.050540 20.4755   <2e-16 ***
    ---
    Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
    

    For more details see:

    • Fama-MacBeth and Cluster-Robust (by Firm and Time) Standard Errors in R.

    See also:

    • Double clustered standard errors for panel data

提交回复
热议问题