From 3340bfb254189ff9e8b9c3089633955134db7527 Mon Sep 17 00:00:00 2001 From: Phillip Alday Date: Tue, 1 Oct 2024 01:00:40 +0000 Subject: [PATCH] fix flipped lower and upper in profile CI (#785) * fix flipped lower and upper in profile CI * news link * thinko * julia 1.8 compat * remove debug lines --- NEWS.md | 5 +++++ Project.toml | 2 +- src/profile/profile.jl | 15 +++++++++++++-- test/pls.jl | 6 ++++++ test/runtests.jl | 2 ++ 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 8fc431a7d..84cae83e9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +MixedModels v4.26.1 Release Notes +============================== +- lower and upper edges of profile confidence intervals for REML-fitted models are no longer flipped [#785] + MixedModels v4.26.0 Release Notes ============================== - `issingular` now accepts comparison tolerances through the keyword arguments `atol` and `rtol`. [#783] @@ -564,3 +568,4 @@ Package dependencies [#776]: https://github.com/JuliaStats/MixedModels.jl/issues/776 [#778]: https://github.com/JuliaStats/MixedModels.jl/issues/778 [#783]: https://github.com/JuliaStats/MixedModels.jl/issues/783 +[#785]: https://github.com/JuliaStats/MixedModels.jl/issues/785 diff --git a/Project.toml b/Project.toml index a49022ce7..a08cd0c5f 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "MixedModels" uuid = "ff71e718-51f3-5ec2-a782-8ffcbfa3c316" author = ["Phillip Alday ", "Douglas Bates ", "Jose Bayoan Santiago Calderon "] -version = "4.26.0" +version = "4.26.1" [deps] Arrow = "69666777-d1a9-59fb-9406-91d4454c9d45" diff --git a/src/profile/profile.jl b/src/profile/profile.jl index ff0b63ada..e3cd52abc 100644 --- a/src/profile/profile.jl +++ b/src/profile/profile.jl @@ -73,12 +73,23 @@ function StatsAPI.confint(pr::MixedModelProfile; level::Real=0.95) cutoff = sqrt(quantile(Chisq(1), level)) rev = pr.rev syms = sort!(collect(filter(k -> !startswith(string(k), 'θ'), keys(rev)))) - return DictTable(; + dt = DictTable(; par=syms, - estimate=[rev[s](false) for s in syms], + estimate=[rev[s](0) for s in syms], lower=[rev[s](-cutoff) for s in syms], upper=[rev[s](cutoff) for s in syms], ) + + # XXX for reasons I don't understand, the reverse spline for REML-models + # is flipped for the fixed effects, even though the table of interpolation + # points isn't. + for i in keys(dt.lower) + if dt.lower[i] > dt.upper[i] + dt.lower[i], dt.upper[i] = dt.upper[i], dt.lower[i] + end + end + + return dt end function Base.show(io::IO, mime::MIME"text/plain", pr::MixedModelProfile) diff --git a/test/pls.jl b/test/pls.jl index c0a540278..cc84b296e 100644 --- a/test/pls.jl +++ b/test/pls.jl @@ -662,6 +662,12 @@ end [265.130, 13.576, 28.858, 37.718, 8.753]; atol=1.e-3) @test first(only(filter(r -> r.p == :σ && iszero(r.ζ), pr.tbl)).σ) == last(models(:sleepstudy)).σ + + @testset "REML" begin + m = refit!(deepcopy(last(models(:sleepstudy))); progress=false, REML=true) + ci = @suppress confint(profile(m)) + @test all(splat(<), zip(ci.lower, ci.upper)) + end end @testset "confint" begin ci = confint(last(models(:sleepstudy))) diff --git a/test/runtests.jl b/test/runtests.jl index 71c82ce1e..e9413ab42 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -7,6 +7,8 @@ using Test import InteractiveUtils: versioninfo import LinearAlgebra: BLAS +using Base: splat # necessary for Julia 1.8 compat + # there seem to be processor-specific issues and knowing this is helpful @info sprint(versioninfo) @info BLAS.get_config()