FixedEffects / FixedEffectModels.jl

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

Degrees of freedom always 1 #230

Closed droodman closed 1 year ago

droodman commented 1 year ago

When I run this example in the documentation I get DOF = 1 instead of the 32 in README.md. More generally, everything I try I get DOF=1...

julia> versioninfo()
Julia Version 1.9.0
Commit 8e63055292 (2023-05-07 11:25 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 16 × Intel(R) Core(TM) i7-10875H CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, skylake)
  Threads: 1 on 16 virtual cores

(@v1.9) pkg> status FixedEffectModels
Status `C:\Users\drood\.julia\environments\v1.9\Project.toml`
  [9d5cd8c9] FixedEffectModels v1.9.1

julia> using DataFrames, RDatasets, FixedEffectModels

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

julia> reg(df, @formula(Sales ~ NDI + fe(State) + fe(Year)), Vcov.cluster(:State), weights = :Pop)
                            FixedEffectModel
=========================================================================
Number of obs:                 1380   Degrees of freedom:               1
R²:                           0.803   R² adjusted:                  0.798
F-statistic:                13.3382   P-value:                      0.001
R² within:                    0.139   Iterations:                       5
=========================================================================
        Estimate  Std. Error    t-stat  Pr(>|t|)   Lower 95%    Upper 95%
─────────────────────────────────────────────────────────────────────────
NDI  -0.00526264  0.00144097  -3.65216    0.0007  -0.0081649  -0.00236038
=========================================================================
matthieugomez commented 1 year ago

Thanks, this is solved by https://github.com/FixedEffects/FixedEffectModels.jl/commit/4e795e91457d7501aeb8a987c24d8faff56353a9