# StatsModels ArgumentError: collection must be non-empty

**URL:** <https://discourse.julialang.org/t/statsmodels-argumenterror-collection-must-be-non-empty/69604>\
**Category:** Statistics\
**Created:** [October 12, 2021, 4:05am UTC](https://discourse.julialang.org/t/statsmodels-argumenterror-collection-must-be-non-empty/69604 "2021-10-12T04:05:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)\
**Post date:** [October 12, 2021, 4:05am UTC](https://discourse.julialang.org/t/statsmodels-argumenterror-collection-must-be-non-empty/69604/1 "2021-10-12T04:05:17Z")

</div>

```julia
ERROR: LoadError: LoadError: ArgumentError: collection must be non-empty
Stacktrace:
  [1] _extrema_itr(f::typeof(identity), itr::Vector{Float64})
    @ Base ./operators.jl:483
  [2] _extrema_dims
    @ ./multidimensional.jl:1698 [inlined]
  [3] #extrema#486
    @ ./multidimensional.jl:1685 [inlined]
  [4] extrema
    @ ./multidimensional.jl:1685 [inlined]
  [5] concrete_term
    @ ~/.julia/packages/StatsModels/lqOhh/src/schema.jl:201 [inlined]
  [6] concrete_term(t::StatsModels.Term, xs::Vector{Float64}, #unused#::Nothing)
    @ StatsModels ~/.julia/packages/StatsModels/lqOhh/src/schema.jl:198
  [7] concrete_term(t::StatsModels.Term, dt::NamedTuple{(
    @ StatsModels ~/.julia/packages/StatsModels/lqOhh/src/schema.jl:184
  [8] (::StatsModels.var"#52#53"{NamedTuple{(
    @ StatsModels ./none:0
  [9] iterate
    @ ./generator.jl:47 [inlined]
 [10] Dict{StatsModels.Term, StatsModels.AbstractTerm}(kv::Base.Generator{Vector{StatsModels.Term}, StatsModels.var"#52#53"{NamedTuple{(
    @ Base ./dict.jl:103
 [11] Schema
    @ ~/.julia/packages/StatsModels/lqOhh/src/schema.jl:37 [inlined]
 [12] schema
    @ ~/.julia/packages/StatsModels/lqOhh/src/schema.jl:123 [inlined]
 [13] schema(f::StatsModels.FormulaTerm{StatsModels.Term, Tuple{StatsModels.FunctionTerm{typeof(|), var"#39#42",
    @ StatsModels ~/.julia/packages/StatsModels/lqOhh/src/schema.jl:126
 [14] LinearMixedModel(f::StatsModels.FormulaTerm{StatsModels.Term, Tuple{StatsModels.FunctionTerm{typeof(|), 
    @ MixedModels ~/.julia/packages/MixedModels/DCOiy/src/linearmixedmodel.jl:57
 [15] fit(::Type{LinearMixedModel}, f::Stats

```

I’m not sure if this is a MixedModels.jl question (@dmbates) or a StatsModels.jl question (@dave.f.kleinschmidt )but I’m wondering what the error means and/or how to fix it.

---

<div class="post-metadata">

**Author:** ![dmbates](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dmbates/32/44_2.png) [@dmbates](https://discourse.julialang.org/u/dmbates)\
**Post date:** [October 12, 2021, 1:30pm UTC](https://discourse.julialang.org/t/statsmodels-argumenterror-collection-must-be-non-empty/69604/2 "2021-10-12T13:30:12Z")

</div>

It looks as if something in one of the columns used in an expression in the model formula, probably a random-effects term, is not evaluated as expected. I would check those.

You can see in [14] that it is evaluating the schema for an expression with `|` in it and by [1] it is looking for the extrema on a vector of Float64 which turns out to be empty.

If you are unable to isolate the problem could you show the formula and the structure of the data that you are using?

---

<div class="post-metadata">

**Author:** ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)\
**Post date:** [October 13, 2021, 12:31am UTC](https://discourse.julialang.org/t/statsmodels-argumenterror-collection-must-be-non-empty/69604/3 "2021-10-13T00:31:04Z")

</div>

Thanks. It turned out the dataframe was empty.

---

<div class="post-metadata">

**Author:** ![dave.f.kleinschmidt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dave.f.kleinschmidt/32/55_2.png) [@dave.f.kleinschmidt](https://discourse.julialang.org/u/dave.f.kleinschmidt)\
**Post date:** [October 29, 2021, 4:37pm UTC](https://discourse.julialang.org/t/statsmodels-argumenterror-collection-must-be-non-empty/69604/4 "2021-10-29T16:37:24Z")

</div>

Since StatsModels 0.6.28 (released a few days ago) you should get a more informative error message in these situations 🙂 [https://github.com/JuliaStats/StatsModels.jl/pull/248](https://github.com/JuliaStats/StatsModels.jl/pull/248)
