Skip to content

Commit

Permalink
BACKPORT: mimeshow RE without FE (#502)
Browse files Browse the repository at this point in the history
* update mime show for RE without FE (#501)
(cherry picked from commit 7b6dd31)

* patch bump
  • Loading branch information
palday authored Apr 9, 2021
1 parent 8d41758 commit efe8ec2
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
MixedModels v3.5.1 Release Notes
========================
* Fix MIME show methods for models with random-effects not corresponding to a fixed effect [#501].

MixedModels v3.5.0 Release Notes
========================
* The Progressbar for `parametricbootstrap` and `replicate` is not displayed
Expand Down Expand Up @@ -170,3 +174,4 @@ Package dependencies
[#484]: https://github.com/JuliaStats/MixedModels.jl/issues/484
[#493]: https://github.com/JuliaStats/MixedModels.jl/issues/493
[#495]: https://github.com/JuliaStats/MixedModels.jl/issues/495
[#501]: https://github.com/JuliaStats/MixedModels.jl/issues/501
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 <[email protected]>", "Douglas Bates <[email protected]>", "Jose Bayoan Santiago Calderon <[email protected]>"]
version = "3.5.0"
version = "3.5.1"

[deps]
Arrow = "69666777-d1a9-59fb-9406-91d4454c9d45"
Expand Down
16 changes: 16 additions & 0 deletions src/mimeshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,22 @@ function _markdown(m::MixedModel)
push!(rows, newrow)
end

re_without_fe = setdiff(mapfoldl(x -> Set(getproperty(x, :cnames)), , m.reterms), coefnames(m))

for bname in re_without_fe
newrow = [bname, "", "", "", ""]
bname = Symbol(bname)

for (j, sig) in enumerate(m.σs)
if bname in keys(sig)
push!(newrow, Ryu.writefixed(getproperty(sig, bname),digits))
else
push!(newrow, " ")
end
end
push!(rows, newrow)
end

if dispersion_parameter(m)
newrow = [_dname(m), Ryu.writefixed(dispersion(m),digits), "", "", ""]
for rr in fnames(m)
Expand Down
21 changes: 20 additions & 1 deletion test/mime.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@ include("modelcache.jl")
gm3 = GeneralizedLinearMixedModel(only(gfms[:verbagg]), dataset(:verbagg), Bernoulli())
pirls!(setβθ!(gm3, βθ))

fm0θ = [ 1.1656121258575225]
fm0θ = [1.1656121258575225]
fm0 = updateL!(setθ!(first(models(:sleepstudy)), fm0θ))

fm1θ = [0.9292213288149662, 0.018168393450877257, 0.22264486671069741]
fm1 = updateL!(setθ!(last(models(:sleepstudy)), fm1θ))

fmreθ = [0.32352483854887326, 0.4715395478019364, 0.0,
0.43705610601403755, 0.016565641868150047, 0.17732248078617097]
# this is a junk model, but it stresses parts of the display code
fmre = LinearMixedModel(@formula(rt_trunc ~ 1+(0+spkr|subj)+(1+load|item)), MixedModels.dataset(:kb07))
updateL!(setθ!(fmre, fmreθ))
fmre.optsum.feval = 1

lrt = likelihoodratiotest(fm0, fm1)

@testset "markdown" begin
Expand All @@ -43,6 +50,18 @@ lrt = likelihoodratiotest(fm0, fm1)
"""
end

@testset "re without fe" begin
@test sprint(show, mime, fmre) == """
| | Est. | SE | z | p | σ_subj | σ_item |
|:----------- | ---------:| -------:| -----:| ------:| --------:| --------:|
| (Intercept) | 2092.3713 | 76.9426 | 27.19 | <1e-99 | | 349.7858 |
| spkr: old | | | | | 377.3837 | |
| spkr: new | | | | | 258.9242 | |
| load: yes | | | | | | 142.5331 |
| Residual | 800.3224 | | | | | |
"""
end

@testset "glmm" begin
@test sprint(show, mime, gm3) in ("""
| | Est. | SE | z | p | σ_subj | σ_item |
Expand Down

2 comments on commit efe8ec2

@palday
Copy link
Member Author

@palday palday commented on efe8ec2 Apr 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/33957

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v3.5.1 -m "<description of version>" efe8ec2db393df35a7b5425509a5285ffd7b6cef
git push origin v3.5.1

Please sign in to comment.