Skip to content

Commit b09fe96

Browse files
authored
fix lowerbd(::MixedModel) to work as singularity reference check (#864)
* fix lowerbd(::MixedModel) to work as singularity reference check * NEWS * missing type parameter
1 parent ec7b986 commit b09fe96

File tree

6 files changed

+26
-3
lines changed

6 files changed

+26
-3
lines changed

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
MixedModels v5.0.3 Release Notes
2+
==============================
3+
- `lowerbd(::MixedModel)` returns the _canonical_ lower bounds of a model's parameters, i.e. the expected bounds after rectification in unconstrained optimization. [#864]
4+
15
MixedModels v5.0.2 Release Notes
26
==============================
37
- The default display and `confint` methods for bootstrap results from models without dispersion parameters has been fixed. [#861]
@@ -695,3 +699,4 @@ Package dependencies
695699
[#858]: https://github.com/JuliaStats/MixedModels.jl/issues/858
696700
[#860]: https://github.com/JuliaStats/MixedModels.jl/issues/860
697701
[#861]: https://github.com/JuliaStats/MixedModels.jl/issues/861
702+
[#864]: https://github.com/JuliaStats/MixedModels.jl/issues/864

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: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,16 @@ 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{T}) where {T} =
799+
[(pm[2] == pm[3]) ? zero(T) : T(-Inf) for pm in m.parmap]
791800

792801
function mkparmap(reterms::Vector{<:AbstractReMat{T}}) where {T}
793802
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)