Skip to content

Commit 6326eb5

Browse files
committed
fix lowerbd(::MixedModel) to work as singularity reference check
1 parent ec7b986 commit 6326eb5

File tree

5 files changed

+20
-3
lines changed

5 files changed

+20
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "MixedModels"
22
uuid = "ff71e718-51f3-5ec2-a782-8ffcbfa3c316"
33
author = ["Phillip Alday <me@phillipalday.com>", "Douglas Bates <dmbates@gmail.com>"]
4-
version = "5.0.2"
4+
version = "5.0.3"
55

66
[deps]
77
Arrow = "69666777-d1a9-59fb-9406-91d4454c9d45"

src/generalizedlinearmixedmodel.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,14 @@ function StatsAPI.loglikelihood(m::GeneralizedLinearMixedModel{T}) where {T}
523523
return accum - (mapreduce(u -> sum(abs2, u), +, m.u) + logdet(m)) / 2
524524
end
525525

526+
"""
527+
lowerbd(m::GeneralizedLinearMixedModel)
528+
529+
Return the vector of _canonical_ lower bounds on the parameters, `θ`.
530+
531+
Note that this method does not distinguish between constrained optimization and
532+
unconstrained optimization with post-fit canonicalization.
533+
"""
526534
lowerbd(m::GeneralizedLinearMixedModel) = lowerbd(m.LMM)
527535

528536
# Base.Fix1 doesn't forward kwargs

src/linearmixedmodel.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,15 @@ function StatsAPI.loglikelihood(m::LinearMixedModel)
787787
return -objective(m) / 2
788788
end
789789

790-
lowerbd(m::LinearMixedModel) = foldl(vcat, lowerbd(c) for c in m.reterms)
790+
"""
791+
lowerbd(m::LinearMixedModel)
792+
793+
Return the vector of _canonical_ lower bounds on the parameters, `θ`.
794+
795+
Note that this method does not distinguish between constrained optimization and
796+
unconstrained optimization with post-fit canonicalization.
797+
"""
798+
lowerbd(m::LinearMixedModel) = [(pm[2] == pm[3]) ? zero(T) : T(-Inf) for pm in m.parmap]
791799

792800
function mkparmap(reterms::Vector{<:AbstractReMat{T}}) where {T}
793801
parmap = NTuple{3,Int}[]

src/mixedmodel.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Equality comparisons are used b/c small non-negative θ values are replaced by 0
7171
function issingular(
7272
m::MixedModel{T}, θ=m.θ; atol::Real=0, rtol::Real=atol > 0 ? 0 : eps()
7373
) where {T}
74-
lb = [(pm[2] == pm[3]) ? zero(T) : T(-Inf) for pm in m.parmap]
74+
lb = lowerbd(m)
7575
return _issingular(lb, θ; atol, rtol)
7676
end
7777

test/pls.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ end
4343
@test length(fm1.A) == 3
4444
@test size(fm1.reterms) == (1,)
4545
@test fm1.optsum.initial == ones(1)
46+
@test lowerbd(fm1) == zeros(1)
4647
fm1.θ = ones(1)
4748
@test fm1.θ == ones(1)
4849
@test islinear(fm1)

0 commit comments

Comments
 (0)