FixedEffects / FixedEffectModels.jl

Fast Estimation of Linear Models with IV and High Dimensional Categorical Variables
Other
225 stars 46 forks source link

Bug! Different p values from Stata #201

Closed zdlspace0528 closed 2 years ago

zdlspace0528 commented 2 years ago

Dear all,

When I use FixedEffectModels with Vcov.cluster, I get the different p values from the results of Stata.

julia> using DataFrames, RDatasets, FixedEffectModels

julia> df = dataset("plm", "GrunFeld");

julia> ols = reg(df, @formula(Inv ~ Value + Capital), Vcov.cluster(:Firm))
                             Linear Model
======================================================================
Number of obs:                 200  Degrees of freedom:              3
R2:                          0.812  R2 Adjusted:                 0.811
F-Stat:                    51.5906  p-value:                     0.000
======================================================================
Inv         | Estimate Std.Error  t value Pr(>|t|) Lower 95% Upper 95%
----------------------------------------------------------------------
Value       | 0.115562 0.0158943  7.27065    0.000 0.0842173  0.146907
Capital     | 0.230678 0.0849671  2.71492    0.007 0.0631166   0.39824
(Intercept) | -42.7144   20.4252 -2.09126    0.038  -82.9945  -2.43425
======================================================================

In Stata, the result is,

. webuse grunfeld,clear

. reg invest mvalue kstock, cl(company)

Linear regression                               Number of obs     =        200
                                                F(2, 9)           =      51.59
                                                Prob > F          =     0.0000
                                                R-squared         =     0.8124
                                                Root MSE          =     94.408

                               (Std. err. adjusted for 10 clusters in company)
------------------------------------------------------------------------------
             |               Robust
      invest | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
      mvalue |     0.1156     0.0159     7.27   0.000       0.0796      0.1515
      kstock |     0.2307     0.0850     2.71   0.024       0.0385      0.4229
       _cons |   -42.7144    20.4252    -2.09   0.066     -88.9194      3.4906
------------------------------------------------------------------------------

Why I get the different p values?

In Julia, the degrees of freedom is 3, but in Stata, the degrees of freedom is 2.

matthieugomez commented 2 years ago

Thanks. Solved with https://github.com/FixedEffects/FixedEffectModels.jl/pull/202

zdlspace0528 commented 2 years ago

@matthieugomez How to update the latest version 1.6.7?