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.3 Release Notes
==============================
- `lowerbd(::MixedModel)` returns the _canonical_ lower bounds of a model's parameters, i.e. the expected bounds after rectification in unconstrained optimization. [#864]

MixedModels v5.0.2 Release Notes
==============================
- The default display and `confint` methods for bootstrap results from models without dispersion parameters has been fixed. [#861]
Expand Down Expand Up @@ -695,3 +699,4 @@ Package dependencies
[#858]: https://github.com/JuliaStats/MixedModels.jl/issues/858
[#860]: https://github.com/JuliaStats/MixedModels.jl/issues/860
[#861]: https://github.com/JuliaStats/MixedModels.jl/issues/861
[#864]: https://github.com/JuliaStats/MixedModels.jl/issues/864
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 <me@phillipalday.com>", "Douglas Bates <dmbates@gmail.com>"]
version = "5.0.2"
version = "5.0.3"

[deps]
Arrow = "69666777-d1a9-59fb-9406-91d4454c9d45"
Expand Down
8 changes: 8 additions & 0 deletions src/generalizedlinearmixedmodel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,14 @@
return accum - (mapreduce(u -> sum(abs2, u), +, m.u) + logdet(m)) / 2
end

"""
lowerbd(m::GeneralizedLinearMixedModel)

Return the vector of _canonical_ lower bounds on the parameters, `θ`.

Note that this method does not distinguish between constrained optimization and
unconstrained optimization with post-fit canonicalization.
"""
lowerbd(m::GeneralizedLinearMixedModel) = lowerbd(m.LMM)

# Base.Fix1 doesn't forward kwargs
Expand Down Expand Up @@ -733,7 +741,7 @@
io::IO, ::MIME"text/plain", m::GeneralizedLinearMixedModel{T,D}
) where {T,D}
if m.optsum.feval < 0
@warn("Model has not been fit")

Check warning on line 744 in src/generalizedlinearmixedmodel.jl

View workflow job for this annotation

GitHub Actions / Documentation

Model has not been fit
return nothing
end
nAGQ = m.LMM.optsum.nAGQ
Expand Down
11 changes: 10 additions & 1 deletion src/linearmixedmodel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,16 @@ function StatsAPI.loglikelihood(m::LinearMixedModel)
return -objective(m) / 2
end

lowerbd(m::LinearMixedModel) = foldl(vcat, lowerbd(c) for c in m.reterms)
"""
lowerbd(m::LinearMixedModel)

Return the vector of _canonical_ lower bounds on the parameters, `θ`.

Note that this method does not distinguish between constrained optimization and
unconstrained optimization with post-fit canonicalization.
"""
lowerbd(m::LinearMixedModel{T}) where {T} =
[(pm[2] == pm[3]) ? zero(T) : T(-Inf) for pm in m.parmap]

function mkparmap(reterms::Vector{<:AbstractReMat{T}}) where {T}
parmap = NTuple{3,Int}[]
Expand Down
2 changes: 1 addition & 1 deletion src/mixedmodel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Equality comparisons are used b/c small non-negative θ values are replaced by 0
function issingular(
m::MixedModel{T}, θ=m.θ; atol::Real=0, rtol::Real=atol > 0 ? 0 : √eps()
) where {T}
lb = [(pm[2] == pm[3]) ? zero(T) : T(-Inf) for pm in m.parmap]
lb = lowerbd(m)
return _issingular(lb, θ; atol, rtol)
end

Expand Down
1 change: 1 addition & 0 deletions test/pls.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ end
@test length(fm1.A) == 3
@test size(fm1.reterms) == (1,)
@test fm1.optsum.initial == ones(1)
@test lowerbd(fm1) == zeros(1)
fm1.θ = ones(1)
@test fm1.θ == ones(1)
@test islinear(fm1)
Expand Down
Loading