Getting an error for FixedEffectModels

Hello everyone,

Recently I updated all my packages on Julia 1.6 via Pkg.update() and also ]up, and since then the regressions I had previously been running using FixedEffectModels.reg are not working anymore.

Here’s a minimum working example:

using CSV, DataFrames

using FixedEffectModels

using DataFramesMeta

df = DataFrame(var1 = rand(9), var2 = rand(9), var3 = rand(9), var4 = rand(9)  )

FixedEffectModels.reg(df, @formula(var1 ~ var2 + var3 + var4))

And here’s the error I get:

Error showing value of type FixedEffectModel:
ERROR: MethodError: no method matching stderror(::FixedEffectModel)
Closest candidates are:
  stderror(::Union{StatsModels.TableRegressionModel, StatsModels.TableStatisticalModel}, ::Any...; kwargs...) at /home/rubaiyat/.julia/packages/StatsModels/m1jYD/src/statsmodel.jl:28
Stacktrace:
  [1] show(io::IOContext{Base.TTY}, x::FixedEffectModel)
    @ FixedEffectModels ~/.julia/packages/FixedEffectModels/0oavj/src/FixedEffectModel.jl:204
  [2] show(io::IOContext{Base.TTY}, #unused#::MIME{Symbol("text/plain")}, x::FixedEffectModel)
    @ Base.Multimedia ./multimedia.jl:47
  [3] (::REPL.var"#38#39"{REPL.REPLDisplay{REPL.LineEditREPL}, MIME{Symbol("text/plain")}, Base.RefValue{Any}})(io::Any)
    @ REPL /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:220
  [4] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:462
  [5] display(d::REPL.REPLDisplay, mime::MIME{Symbol("text/plain")}, x::Any)
    @ REPL /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:213
  [6] display(d::REPL.REPLDisplay, x::Any)
    @ REPL /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:225
  [7] display(x::Any)
    @ Base.Multimedia ./multimedia.jl:328
  [8] #invokelatest#2
    @ ./essentials.jl:708 [inlined]
  [9] invokelatest
    @ ./essentials.jl:706 [inlined]
 [10] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
    @ REPL /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:247
 [11] (::REPL.var"#40#41"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
    @ REPL /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:231
 [12] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:462
 [13] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
    @ REPL /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:229
 [14] (::REPL.var"#do_respond#61"{Bool, Bool, REPL.var"#72#82"{REPL.LineEditREPL, REPL.REPLHistoryProvider}, REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
    @ REPL /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:798
 [15] #invokelatest#2
    @ ./essentials.jl:708 [inlined]
 [16] invokelatest
    @ ./essentials.jl:706 [inlined]
 [17] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/LineEdit.jl:2441
 [18] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:1126
 [19] (::REPL.var"#44#49"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL ./task.jl:411

Any help on what could be causing this? I just used ]up right now and here’s my output, in case it helps.

(@v1.6) pkg> up
    Updating registry at `~/.julia/registries/General`
    Updating registry at `~/.julia/registries/JuliaComputingRegistry`
   Installed GR_jll ──────────── v0.64.0+0
   Installed FiniteDifferences ─ v0.12.23
   Installed StaticArrays ────── v1.3.5
   Installed Plots ───────────── v1.25.10
   Installed GR ──────────────── v0.64.0
  Downloaded artifact: GR
    Updating `~/.julia/environments/v1.6/Project.toml`
  [26cc04aa] ↑ FiniteDifferences v0.12.22 ⇒ v0.12.23
  [91a5bcdd] ↑ Plots v1.25.9 ⇒ v1.25.10
    Updating `~/.julia/environments/v1.6/Manifest.toml`
  [26cc04aa] ↑ FiniteDifferences v0.12.22 ⇒ v0.12.23
  [28b8d3ca] ↑ GR v0.63.1 ⇒ v0.64.0
  [91a5bcdd] ↑ Plots v1.25.9 ⇒ v1.25.10
  [90137ffa] ↑ StaticArrays v1.3.4 ⇒ v1.3.5
  [d2c73de3] ↑ GR_jll v0.63.1+0 ⇒ v0.64.0+0
    Building GR → `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/9f836fb62492f4b0f0d3b06f55983f2704ed0883/build.log`
Precompiling project...
  ? FixedEffects
  ? Vcov
  ? StatsFuns
  ? Distributions
  ? StatsModels
  ? FixedEffectModels
  ? BlackBoxOptim
  ? GLM
  ? ForwardDiff
  ? JuMP
  ? NLSolversBase
  ? LineSearches
  ? Plots
  ? Optim
  14 dependencies successfully precompiled in 28 seconds (216 already precompiled, 1 skipped during auto due to previous errors)
  14 dependencies failed but may be precompilable after restarting julia

As I mentioned I haven’t updated to Julia 1.7 yet, could that be causing the issue?

Thanks!

I can’t replicate. This does not mean that your error doesn’t exist or that there is nothing to be fixed.

Try everything in a new environment. In a new session, run

] activate --temp
] add DataFramesMeta, CSV, FixedEffectModels
df = DataFrame(var1 = rand(9), var2 = rand(9), var3 = rand(9), var4 = rand(9)  )

FixedEffectModels.reg(df, @formula(var1 ~ var2 + var3 + var4))

and see if the error persists.

Still getting the same error unfortunately.

Darn.

What’s the ouptut of ] status? There is this commit from a long time ago about stderr vs stderror. Maybe you have a super super old version?

Here’s the output

   Status `/tmp/jl_lvLqni/Project.toml`
  [336ed68f] CSV v0.10.2
  [1313f7d8] DataFramesMeta v0.10.0
  [9d5cd8c9] FixedEffectModels v1.6.4

Looks like I’m on the latest version of FixedEffectModels.

In the output for ]up that I posted above, there are ?s after FixedEffectModels and says there is a failure to precompile. Could that mean something?

yeah probably. Please file an issue with FixedEffectModels.jl.

@nilshg and @matthieu might have something to say in the meantime.

I’m on 1.7.2 with the following versions which help. Maybe you can try pinning those versions

pkg> st
      Status `/tmp/jl_OLasno/Project.toml`
  [336ed68f] CSV v0.10.2
  [1313f7d8] DataFramesMeta v0.10.0
  [9d5cd8c9] FixedEffectModels v1.6.4
1 Like

I can reproduce this on 1.7.2 and FixedEffectModels v.1.6.4. Tests fail locally as well, which is odd given that the package hasn’t been changed since August last year.

No idea what’s going on unfortunately and currently no time to investigate, but definitely worth filing an issue!

1 Like

I did a little digging on this. the stderror function was defined by StatsBase.jl, the most recent release release moved that and some other functions to StatsAPI.jl and did not define the same function. In StatsBase, it was:

stderror(model::StatisticalModel) = sqrt.(diag(vcov(model)))

In StatsAPI it is now:

function stderror end

I don’t know if there was a reason that function was skipped or if it was just overlooked (since most of the other functions that StatsBase defined in that section would just result in an error).

As a temporary fix, I think you can just add a function for FixedEffectModels:

FixedEffectModels.stderror(model::StatisticalModel) = sqrt.(diag(vcov(model)))
1 Like

I just realized the same. See https://github.com/JuliaStats/StatsAPI.jl/pull/9.

2 Likes

OK, it should be fixed now if you upgrade to StatsAPI 1.2.1.

2 Likes

It works, thanks for the help everyone!

Thanks everyone for fixing the issue!