Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
MixedModels v5.0.1 Release Notes
==============================
- Fixes a method error with `Grouping()` contrasts when used with recent CategoricalArray releases. [#860]

MixedModels v5.0.0 Release Notes
==============================
- Optimization is now performed _without constraints_. In a post-fitting step, the Cholesky factor is canonicalized to have non-negative diagonal elements. [#840]
Expand Down Expand Up @@ -685,3 +689,4 @@ Package dependencies
[#856]: https://github.com/JuliaStats/MixedModels.jl/issues/856
[#857]: https://github.com/JuliaStats/MixedModels.jl/issues/857
[#858]: https://github.com/JuliaStats/MixedModels.jl/issues/858
[#860]: https://github.com/JuliaStats/MixedModels.jl/issues/860
6 changes: 4 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MixedModels"
uuid = "ff71e718-51f3-5ec2-a782-8ffcbfa3c316"
author = ["Phillip Alday <me@phillipalday.com>", "Douglas Bates <dmbates@gmail.com>"]
version = "5.0.0"
version = "5.0.1"

[deps]
Arrow = "69666777-d1a9-59fb-9406-91d4454c9d45"
Expand Down Expand Up @@ -46,6 +46,7 @@ MixedModelsPRIMAExt = ["PRIMA"]
Aqua = "0.8"
Arrow = "1, 2"
BSplineKit = "0.17, 0.18, 0.19"
CategoricalArrays = "0.10, 1"
Compat = "4.10"
DataAPI = "1"
DataFrames = "1"
Expand Down Expand Up @@ -84,6 +85,7 @@ julia = "1.10"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7"
FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41"
Expand All @@ -96,4 +98,4 @@ Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Aqua", "DataFrames", "ExplicitImports", "FiniteDiff", "ForwardDiff", "InteractiveUtils", "PRIMA", "StableRNGs", "Suppressor", "Test"]
test = ["Aqua", "CategoricalArrays", "DataFrames", "ExplicitImports", "FiniteDiff", "ForwardDiff", "InteractiveUtils", "PRIMA", "StableRNGs", "Suppressor", "Test"]
1 change: 1 addition & 0 deletions src/grouping.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ end
function StatsModels.ContrastsMatrix(
contrasts::Grouping, levels::AbstractVector
)
levels = convert(Vector, levels)
return StatsModels.ContrastsMatrix(zeros(0, 0), levels, levels, contrasts)
end

Expand Down
13 changes: 11 additions & 2 deletions test/grouping.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ using MixedModels
using StatsModels
using Test

using CategoricalArrays: categorical
using MixedModels: schematize
using StatsModels: ContrastsMatrix, FullDummyCoding

Expand All @@ -14,8 +15,6 @@ end
d = (; y=rand(2_000_000),
grp=string.([1:1_000_000; 1:1_000_000]),
outer=rand('A':'z', 2_000_000))
## OOM seems to result in the process being killed on Mac so this messes up CI
# @test_throws OutOfMemoryError schema(d)
sch = schema(d, Dict(:grp => Grouping()))
t = sch[term(:grp)]
@test t isa CategoricalTerm{Grouping}
Expand All @@ -27,6 +26,16 @@ end

@test all(t.contrasts.invindex[lev] == i for (i, lev) in enumerate(levs))
@test all(t.contrasts.levels[i] == lev for (i, lev) in enumerate(levs))

d = (; y=rand(20),
grp=categorical([1:10; 1:10]))
sch = schema(d, Dict(:grp => Grouping()))
t = sch[term(:grp)]
@test t isa CategoricalTerm{Grouping}
@test size(t.contrasts.matrix) == (0, 0)
@test length(t.contrasts.levels) == 10
@test_throws ErrorException StatsModels.modelcols(t, (a=1.0,))

end

@testset "Auto application of Grouping()" begin
Expand Down
Loading