Skip to content

Commit 06fd2eb

Browse files
committed
fix display and confint of bootstrap for models without dispersion parameter (#861)
* fix display and confint of bootstrap for models without dispersion parameter * NEWS * patch not minor (cherry picked from commit ec7b986)
1 parent 2974509 commit 06fd2eb

File tree

4 files changed

+60
-16
lines changed

4 files changed

+60
-16
lines changed

NEWS.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1+
MixedModels v5.0.2 Release Notes
2+
==============================
3+
- The default display and `confint` methods for bootstrap results from models without dispersion parameters has been fixed. [#861]
4+
5+
MixedModels v5.0.1 Release Notes
6+
==============================
7+
- Fixes a method error with `Grouping()` contrasts when used with recent CategoricalArray releases. [#860]
8+
9+
MixedModels v5.0.0 Release Notes
10+
==============================
11+
- Optimization is now performed _without constraints_. In a post-fitting step, the Cholesky factor is canonicalized to have non-negative diagonal elements. [#840]
12+
- The default optimizer has changed to NLopt's implementation of NEWUOA where possible. NLopt's implementation fails on 1-dimensional problems, so in the case of a single, scalar random effect, BOBYQA is used instead. In the future, the default optimizer backend will likely change to PRIMA and NLopt support will be moved to an extension. Blocking this change in backend is an issue with PRIMA.jl when running in VSCode's built-in REPL on Linux. [#840]
13+
- [BREAKING] Support for constrained optimization has been completely removed, i.e. the field `lowerbd` has been removed from `OptSummary`. [#849]
14+
- [BREAKING] The deprecated `use_threads` kwarg has been dropped from `parametricbootstrap`. It had been a no-op since v4.10.0. [#841]
15+
- [BREAKING] The deprecated `hide_progress` kwarg has been dropped from `parametricbootstrap`. It had been replaced by `progress` since v4.22.0. [#841]
16+
- [BREAKING] A fitlog is always kept -- the deprecated keyword argument `thin` has been removed as has the `fitlog` keyword argument. [#850]
17+
- The fitlog is now stored as Tables.jl-compatible column table. [#850]
18+
- Internal code around the default optimizer has been restructured. In particular, the NLopt backend has been moved to a submodule, which will make it easier to move it to an extension if we promote another backend to the default. [#853]
19+
- Internal code around optimization in profiling has been restructuring so that fitting done during calls to `profile` respect the `backend` and `optimizer` settings. [#853]
20+
- The `prfit!` convenience function has been removed. [#853]
21+
- The `dataset` and `datasets` functions have been removed. They are now housed in `MixedModelsDatasets`.[#854]
22+
- The local implementation of `fulldummy` and the nesting syntax has been removed and a dependency on RegressionFormulae.jl for their implementation has been added. [#855]
23+
- One argument `predict(::GeneralizedLinearMixedModel)`, i.e. prediction on the original data, now supports the `type` keyword argument. [#856]
24+
- `isnested(A::ReMat, B::ReMat)` is now a method of `StatsModels.isnested`.[#858]
25+
- [BREAKING ]`likelihoodratiotest` has been reworked to be a thin wrapper around `StatsModels.lrtest`. The historical difference in behavior in terms of nesting checks created some confusion. Users advanced enough to create models with non-obvious nesting are assumed to be advanced enough to manually compute the likelihood ratio test. The function `likelihoodratiotest` and associated `LikelihoodRatioTest` type (now with a type parameter for number of models) has been kept to enable printing of test results with model formulae. Most users should not notice a difference in behavior, but the display has been slightly changed and the internal field structure has changed.[#858]
26+
- Failures to fit a spline in profiling now generates a more helpful error message. [#857]
27+
28+
MixedModels v4.48.1 Release Notes
29+
==============================
30+
- [BACKPORT] The default display and `confint` methods for bootstrap results from models without dispersion parameters has been fixed. [#861]
31+
132
MixedModels v4.38.0 Release Notes
233
==============================
334
- Experimental support for evaluating `FiniteDiff.finite_difference_gradient` and `FiniteDiff.finite_difference_hessian of the objective of a fitted `LinearMixedModel`. [#842]
@@ -655,5 +686,16 @@ Package dependencies
655686
[#828]: https://github.com/JuliaStats/MixedModels.jl/issues/828
656687
[#829]: https://github.com/JuliaStats/MixedModels.jl/issues/829
657688
[#836]: https://github.com/JuliaStats/MixedModels.jl/issues/836
689+
[#840]: https://github.com/JuliaStats/MixedModels.jl/issues/840
658690
[#841]: https://github.com/JuliaStats/MixedModels.jl/issues/841
659691
[#842]: https://github.com/JuliaStats/MixedModels.jl/issues/842
692+
[#849]: https://github.com/JuliaStats/MixedModels.jl/issues/849
693+
[#850]: https://github.com/JuliaStats/MixedModels.jl/issues/850
694+
[#853]: https://github.com/JuliaStats/MixedModels.jl/issues/853
695+
[#854]: https://github.com/JuliaStats/MixedModels.jl/issues/854
696+
[#855]: https://github.com/JuliaStats/MixedModels.jl/issues/855
697+
[#856]: https://github.com/JuliaStats/MixedModels.jl/issues/856
698+
[#857]: https://github.com/JuliaStats/MixedModels.jl/issues/857
699+
[#858]: https://github.com/JuliaStats/MixedModels.jl/issues/858
700+
[#860]: https://github.com/JuliaStats/MixedModels.jl/issues/860
701+
[#861]: https://github.com/JuliaStats/MixedModels.jl/issues/861

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 = "4.38.0"
4+
version = "4.38.1"
55

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

src/bootstrap.jl

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -368,14 +368,16 @@ function StatsBase.confint(
368368
tbl = Table(bsamp.tbl)
369369
lower = T[]
370370
upper = T[]
371-
v = similar(tbl.σ)
372-
par = sort!(
373-
collect(
374-
filter(
375-
k -> !(startswith(string(k), 'θ') || string(k) == "obj"), propertynames(tbl)
376-
),
377-
),
378-
)
371+
v = similar(tbl.σ, T)
372+
par = filter(collect(propertynames(tbl))) do k
373+
k = string(k)
374+
# σ is missing in models without a dispersion parameter
375+
if k == "σ" && Missing <: eltype(tbl.σ)
376+
return false
377+
end
378+
return !startswith(k, 'θ') && k != "obj"
379+
end
380+
sort!(par)
379381
tails = [(1 - level) / 2, (1 + level) / 2]
380382
for p in par
381383
if method === :shortest
@@ -643,6 +645,8 @@ push! `σ` times the row lengths (σs) and the inner products of normalized rows
643645
"""
644646
function σρ!(v::AbstractVector{<:Union{T,Missing}}, t::LowerTriangular, σ) where {T}
645647
dat = t.data
648+
# for models without a dispersion parameter, σ is missing, but for the math below we can treat it as 1
649+
σ = coalesce(σ, one(T))
646650
for i in axes(dat, 1)
647651
ssqr = zero(T)
648652
for j in 1:i

test/bootstrap.jl

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,15 +200,13 @@ end
200200
bs = parametricbootstrap(StableRNG(42), 100, gm0; progress=false)
201201
# make sure we're not copying
202202
@test length(bs.lowerbd) == length(gm0.θ)
203-
bsci = filter!(:type => ==("β"), DataFrame(shortestcovint(bs)))
204-
ciwidth = 2 .* stderror(gm0)
205-
waldci = DataFrame(coef=fixefnames(gm0),
206-
lower=fixef(gm0) .- ciwidth,
207-
upper=fixef(gm0) .+ ciwidth)
203+
bsci = confint(bs)
204+
waldci = confint(gm0)
208205

209206
# coarse tolerances because we're not doing many bootstrap samples
210-
@test all(isapprox.(bsci.lower, waldci.lower; atol=0.5))
211-
@test all(isapprox.(bsci.upper, waldci.upper; atol=0.5))
207+
# end-1 because the bootstrap CIs include the variance component
208+
@test all(isapprox.(collect(bsci.lower)[1:end-1], collect(waldci.lower); atol=0.5))
209+
@test all(isapprox.(collect(bsci.upper)[1:end-1], collect(waldci.upper); atol=0.5))
212210

213211
σbar = mean(MixedModels.tidyσs(bs)) do x; x.σ end
214212
@test σbar 0.56 atol=0.1

0 commit comments

Comments
 (0)