FixedEffects / FixedEffectModels.jl

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

StatsBase version incompatibility #207

Closed mattwigway closed 2 years ago

mattwigway commented 2 years ago

When using FixedEffectModels 1.7.0 with StatsBase 0.33.14, I get the following error:

ERROR: LoadError: MethodError: no method matching vcov(::Vcov.VcovData{LinearAlgebra.Cholesky{Float64, Matrix{Float64}}, 1}, ::Vcov.ClusterCovariance)
Closest candidates are:
  vcov(::Union{StatsModels.TableRegressionModel, StatsModels.TableStatisticalModel}, ::Any...; kwargs...) at ~/.julia/packages/StatsModels/qY2YS/src/statsmodel.jl:28
Stacktrace:
 [1] reg(df::Any, formula::FormulaTerm, vcov::StatsBase.CovarianceEstimator; contrasts::Dict, weights::Union{Nothing, Symbol}, save::Union{Bool, Symbol}, method::Symbol, nthreads::Integer, double_precision::Bool, tol::Real, maxiter::Integer, drop_singletons::Bool, progress_bar::Bool, dof_add::Integer, subset::Union{Nothing, AbstractVector}, first_stage::Bool)
   @ FixedEffectModels ~/.julia/packages/FixedEffectModels/kJPKw/src/fit.jl:389
 [2] top-level scope
   @ ~/git/fixedeffectserror/test.jl:4
in expression starting at /Users/mwbc/git/fixedeffectserror/test.jl:4

If I upgrade to StatsBase 0.33.19 the problem disappears. The offending line seems to be https://github.com/FixedEffects/FixedEffectModels.jl/blob/master/src/fit.jl#L389 . Here, StatsBase.vcov is called but this is now called StatsAPI.vcov. I guess more recent StatsBase re-exports vcov from StatsAPI. So either the StatsBase compat entry should be updated, or this line should be changed to StatsAPI.vcov.

MWE: https://gist.github.com/mattwigway/f10dbc682506b1ce4a65b395c5dd0dd4

matthieugomez commented 2 years ago

Thanks. Should be fixed by https://github.com/FixedEffects/FixedEffectModels.jl/pull/208