diff --git a/src/MixedModelsMakie.jl b/src/MixedModelsMakie.jl index 22136e2..82e095f 100644 --- a/src/MixedModelsMakie.jl +++ b/src/MixedModelsMakie.jl @@ -37,7 +37,8 @@ export RanefInfo, zetaplot! # from https://github.com/MakieOrg/Makie.jl/issues/2992 -const Indexable = Union{Makie.Figure,Makie.GridLayout,Makie.GridPosition,Makie.GridSubposition} +const Indexable = Union{Makie.Figure,Makie.GridLayout,Makie.GridPosition, + Makie.GridSubposition} include("utilities.jl") include("shrinkage.jl") diff --git a/src/coefplot.jl b/src/coefplot.jl index 7cd7d21..b527bc9 100644 --- a/src/coefplot.jl +++ b/src/coefplot.jl @@ -37,11 +37,11 @@ function coefplot!(ax::Axis, x::Union{MixedModel,MixedModelBootstrap}; xvals = ci.estimate xlabel = @sprintf "Estimate and %g%% confidence interval" conf_level * 100 - attributes = merge((;xlabel), attributes) + attributes = merge((; xlabel), attributes) ax.xlabel = attributes.xlabel scatter!(ax, xvals, y; attributes...) - errorbars!(ax, xvals, y, xvals .- ci.lower, ci.upper .- xvals; + errorbars!(ax, xvals, y, xvals .- ci.lower, ci.upper .- xvals; direction=:x, attributes...) vline_at_zero && vlines!(ax, 0; color=(:black, 0.75), linestyle=:dash) diff --git a/src/ridge.jl b/src/ridge.jl index 770dd7e..d114fbd 100644 --- a/src/ridge.jl +++ b/src/ridge.jl @@ -19,7 +19,7 @@ The mutating methods return the original object. function ridgeplot(x::MixedModelBootstrap; show_intercept=true, kwargs...) # need to guarantee a min height of 200 fig = Figure(; size=(640, max(200, 100 * _npreds(x; show_intercept)))) - return ridgeplot!(fig, x,; show_intercept, kwargs...) + return ridgeplot!(fig, x; show_intercept, kwargs...) end """$(@doc ridgeplot)""" @@ -40,21 +40,23 @@ _color(p::Pair) = first(p) """$(@doc ridgeplot)""" function ridgeplot!(ax::Axis, x::MixedModelBootstrap; - conf_level=0.95, - vline_at_zero=true, - show_intercept=true, - attributes...) + conf_level=0.95, + vline_at_zero=true, + show_intercept=true, + attributes...) xlabel = if !ismissing(conf_level) - @sprintf "Normalized bootstrap density and %g%% confidence interval" (conf_level * 100) + @sprintf "Normalized bootstrap density and %g%% confidence interval" (conf_level * + 100) else "Normalized bootstrap density" end if !ismissing(conf_level) - coefplot!(ax, x; conf_level, vline_at_zero, show_intercept, color=:black, attributes...) + coefplot!(ax, x; conf_level, vline_at_zero, show_intercept, color=:black, + attributes...) end - attributes = merge((;xlabel, color=:black), attributes) + attributes = merge((; xlabel, color=:black), attributes) band_attributes = merge(attributes, (; color=(_color(attributes.color), 0.3))) ax.xlabel = attributes.xlabel @@ -77,7 +79,7 @@ function ridgeplot!(ax::Axis, x::MixedModelBootstrap; band!(ax, lower, upper; band_attributes...) lines!(ax, upper; attributes...) end - + # check conf_level so that we don't double print # if coefplot took care of it for us if ismissing(conf_level) diff --git a/test/runtests.jl b/test/runtests.jl index 54777e0..6831c67 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -44,8 +44,8 @@ g1 = fit(MixedModel, rng = MersenneTwister(0) x = rand(rng, 100) -data = (x = x, x2 = 1.5 .* x, y = rand(rng, [0,1], 100), z = repeat('A':'T', 5)) -mr = @suppress fit(MixedModel, @formula(y ~ x + x2 + (1|z)), data; progress) +data = (x=x, x2=1.5 .* x, y=rand(rng, [0, 1], 100), z=repeat('A':'T', 5)) +mr = @suppress fit(MixedModel, @formula(y ~ x + x2 + (1 | z)), data; progress) br = parametricbootstrap(MersenneTwister(42), 500, mr; progress, optsum_overrides=(; ftol_rel=1e-6))