FixedEffects / FixedEffectModels.jl

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

Error: expansion cannot be computed #192

Closed Shresth-Garg closed 2 years ago

Shresth-Garg commented 2 years ago

Thanks for the fix #190!

I pulled in the new version, however, now I am getting an "expansion cannot be computed error" on some specifications. I also updated all the packages by running ] update before pulling in the new code. My guess is that something breaks in the latest StatModels package. I also get the same error when using GLM.jl to run the regression. I have tried the following:

1) Reinstalling Julia from scratch and using the published version of FixedEffectModels.jl. 2) Going back to 1.6.5 and using the published version.

I also started a discussion on the Julia discourse (link) - following the suggestion there I will also file an issue in the StatModels and CSV.

The regression I run is:

model = reg(df_test, @formula(var1 ~ var2))

The error I get is:

ERROR: expansion can't be computed
Stacktrace:
  [1] error(s::String)
    @ Base .\error.jl:33
  [2] beta_inc_asymptotic_asymmetric(a::Float64, b::Float64, x::Float64, y::Float64, w::Float64, epps::Float64)
    @ SpecialFunctions C:\Users\shres\.julia\packages\SpecialFunctions\rNt4H\src\beta_inc.jl:384
  [3] _beta_inc(a::Float64, b::Float64, x::Float64, y::Float64)
    @ SpecialFunctions C:\Users\shres\.julia\packages\SpecialFunctions\rNt4H\src\beta_inc.jl:849
  [4] _beta_inc
    @ C:\Users\shres\.julia\packages\SpecialFunctions\rNt4H\src\beta_inc.jl:736 [inlined]
  [5] beta_inc
    @ C:\Users\shres\.julia\packages\SpecialFunctions\rNt4H\src\beta_inc.jl:729 [inlined]
  [6] betaccdf
    @ C:\Users\shres\.julia\packages\StatsFuns\dTYga\src\distrs\beta.jl:44 [inlined]
  [7] fdistccdf(ν1::Float64, ν2::Float64, x::Float64)
    @ StatsFuns C:\Users\shres\.julia\packages\StatsFuns\dTYga\src\distrs\fdist.jl:18
  [8] fdistccdf(ν1::Int64, ν2::Int64, x::Float64)
    @ StatsFuns C:\Users\shres\.julia\packages\StatsFuns\dTYga\src\distrs\fdist.jl:19
  [9] reg(df::Any, formula::FormulaTerm, vcov::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{T} where T}, first_stage::Bool)
    @ FixedEffectModels C:\Users\shres\.julia\packages\FixedEffectModels\0oavj\src\fit.jl:392
 [10] reg (repeats 2 times)
    @ C:\Users\shres\.julia\packages\FixedEffectModels\0oavj\src\fit.jl:61 [inlined]
 [11] top-level scope
    @ REPL[414]:1

df_test.csv

The test dataset I use is attached. Any suggestions will be appreciated!

Shresth-Garg commented 2 years ago

I was able to fix the error by downgrading StatsFuns.jl from the latest version (0.9.16) to the previous version (0.9.15). I will file an issue in that package. Should I keep this issue open it's fixed?

Edit: Nevermind, there's already a thread there.

matthieugomez commented 2 years ago

Do you get it for ``real'' regressions or just with made up data?

Shresth-Garg commented 2 years ago

I get it for real regressions in a data set involving small firms making production decisions. In the dataframe attached to the original post, var1 is log of the output, while var2 is log of one of the inputs (labor).

matthieugomez commented 2 years ago

Thanks. Should be fixed now thanks to @andreasnoack just run ]update