Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add coefnames(::ReMat) #709

Merged
merged 4 commits into from
Aug 20, 2023
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 v4.19.0 Release Notes
==============================
* New method `StatsAPI.coefnames(::ReMat)` returns the coefficient names associated with each grouping factor. [#709]

MixedModels v4.18.0 Release Notes
==============================
* More user-friendly error messages when a formula contains variables not in the data. [#707]
Expand Down Expand Up @@ -461,3 +465,4 @@ Package dependencies
[#698]: https://github.com/JuliaStats/MixedModels.jl/issues/698
[#703]: https://github.com/JuliaStats/MixedModels.jl/issues/703
[#707]: https://github.com/JuliaStats/MixedModels.jl/issues/707
[#709]: https://github.com/JuliaStats/MixedModels.jl/issues/709
2 changes: 1 addition & 1 deletion 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 <[email protected]>", "Douglas Bates <[email protected]>", "Jose Bayoan Santiago Calderon <[email protected]>"]
version = "4.18.0"
version = "4.19.0"

[deps]
Arrow = "69666777-d1a9-59fb-9406-91d4454c9d45"
Expand Down
2 changes: 1 addition & 1 deletion src/linearmixedmodel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ fixef(m::LinearMixedModel{T}) where {T} = fixef!(Vector{T}(undef, m.feterm.rank)

Return a (permuted and truncated in the rank-deficient case) vector of coefficient names.
"""
function fixefnames(m::LinearMixedModel{T}) where {T}
function fixefnames(m::LinearMixedModel)
Xtrm = m.feterm
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

return Xtrm.cnames[1:(Xtrm.rank)]
end
Expand Down
2 changes: 2 additions & 0 deletions src/remat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ nranef(A::ReMat) = size(A.adjA, 1)

LinearAlgebra.cond(A::ReMat) = cond(A.λ)

StatsAPI.coefnames(re::MixedModels.AbstractReMat) = re.cnames

"""
fname(A::ReMat)

Expand Down
1 change: 1 addition & 0 deletions test/FactorReTerm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ end
m2r = fit(MixedModel, term(:strength) ~ term(1) + (term(1)|term(:batch)) + (term(1)|term(:batch)&term(:cask)), psts; progress=false)

@test fnames(m) == fnames(m2) == fnames(m2r) == (Symbol("batch & cask"), :batch)
@test coefnames(first(m.reterms)) == ["(Intercept)"]
@test m.λ == m2.λ == m2r.λ
@test deviance(m) == deviance(m2) == deviance(m2r)
end
Expand Down