# Question about FixedEffectModels?

**URL:** <https://discourse.julialang.org/t/question-about-fixedeffectmodels/83363>\
**Category:** General Usage\
**Created:** [June 26, 2022, 3:29pm UTC](https://discourse.julialang.org/t/question-about-fixedeffectmodels/83363 "2022-06-26T15:29:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raymond](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raymond/32/36557_2.png) [@Raymond](https://discourse.julialang.org/u/Raymond)\
**Post date:** [June 26, 2022, 3:29pm UTC](https://discourse.julialang.org/t/question-about-fixedeffectmodels/83363/1 "2022-06-26T15:29:45Z")

</div>

Dear all,

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

```julia
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

```julia
. 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?

---

<div class="post-metadata">

**Author:** ![Raymond](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raymond/32/36557_2.png) [@Raymond](https://discourse.julialang.org/u/Raymond)\
**Post date:** [June 26, 2022, 3:32pm UTC](https://discourse.julialang.org/t/question-about-fixedeffectmodels/83363/2 "2022-06-26T15:32:51Z")

</div>

I find that the coefficient, standard error and t value are all the same, only P values are different.

---

<div class="post-metadata">

**Author:** ![Raymond](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raymond/32/36557_2.png) [@Raymond](https://discourse.julialang.org/u/Raymond)\
**Post date:** [June 26, 2022, 3:40pm UTC](https://discourse.julialang.org/t/question-about-fixedeffectmodels/83363/3 "2022-06-26T15:40:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [June 26, 2022, 3:44pm UTC](https://discourse.julialang.org/t/question-about-fixedeffectmodels/83363/4 "2022-06-26T15:44:13Z")

</div>

This seems like a problem, please file an issue with FixedEffectModels. Here is the same code with `reghdfe`

```julia
reghdfe invest mvalue kstock, vce(cluster company) noabsorb
(MWFE estimator converged in 1 iterations)

HDFE Linear regression Number of obs = 200
Absorbing 1 HDFE group F( 2, 9) = 51.59
Statistics robust to heteroskedasticity Prob > F = 0.0000
                                                  R-squared = 0.8124
                                                  Adj R-squared = 0.8105
                                                  Within R-sq. = 0.8124
Number of clusters (company) = 10 Root MSE = 94.4084

                               (Std. err. adjusted for 10 clusters in company)
------------------------------------------------------------------------------
             | Robust
      invest | Coefficient std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
      mvalue | .1155622 .0158943 7.27 0.000 .0796067 .1515176
      kstock | .2306785 .0849671 2.71 0.024 .0384695 .4228874
       _cons | -42.71437 20.4252 -2.09 0.066 -88.91939 3.490649
------------------------------------------------------------------------------

```

---

<div class="post-metadata">

**Author:** ![Raymond](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raymond/32/36557_2.png) [@Raymond](https://discourse.julialang.org/u/Raymond)\
**Post date:** [June 26, 2022, 3:46pm UTC](https://discourse.julialang.org/t/question-about-fixedeffectmodels/83363/5 "2022-06-26T15:46:21Z")

</div>

The results of `reghdfe` are also different from Julia.

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [June 26, 2022, 3:47pm UTC](https://discourse.julialang.org/t/question-about-fixedeffectmodels/83363/6 "2022-06-26T15:47:01Z")

</div>

yes I was hoping they would be the same. But they are not.

---

<div class="post-metadata">

**Author:** ![Raymond](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raymond/32/36557_2.png) [@Raymond](https://discourse.julialang.org/u/Raymond)\
**Post date:** [June 26, 2022, 5:25pm UTC](https://discourse.julialang.org/t/question-about-fixedeffectmodels/83363/7 "2022-06-26T17:25:47Z")

</div>

> [@Raymond](#):
>
> ```julia
> julia> using DataFrames, RDatasets, FixedEffectModels
> 
> julia> df = dataset("plm", "GrunFeld");
> 
> julia> ols = reg(df, @formula(Inv ~ Value + Capital), Vcov.cluster(:Firm))
> 
> ```

I have filed an issue on github. Matthieu Gomez has solved the problem and replied to me. But I don’t know what he means.

 ![截屏2022-06-27 01.22.18](https://global.discourse-cdn.com/julialang/original/3X/6/3/6391f3de06d5cc1efc00fb54449608e620433ff6.png)

---

<div class="post-metadata">

**Author:** ![Raymond](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raymond/32/36557_2.png) [@Raymond](https://discourse.julialang.org/u/Raymond)\
**Post date:** [June 26, 2022, 5:26pm UTC](https://discourse.julialang.org/t/question-about-fixedeffectmodels/83363/8 "2022-06-26T17:26:20Z")

</div>

So can I update `FixedEffectModels` to solve the problem?
