diff --git a/ext/EffectsMixedModelsExt.jl b/ext/EffectsMixedModelsExt.jl index 0ef5e87..99e87da 100644 --- a/ext/EffectsMixedModelsExt.jl +++ b/ext/EffectsMixedModelsExt.jl @@ -41,7 +41,8 @@ Use the results of a bootstrap to compute empirical error estimates This method is experimental and may change in its defaults or disappear entirely in a future release! """ -function Effects.effects!(reference_grid::DataFrame, model::MixedModel, boot::MixedModelBootstrap; +function Effects.effects!(reference_grid::DataFrame, model::MixedModel, + boot::MixedModelBootstrap; eff_col=nothing, err_col=:err, typical=mean, invlink=identity, lower_col=:lower, upper_col=:upper, level=nothing) @@ -66,7 +67,6 @@ function Effects.effects!(reference_grid::DataFrame, model::MixedModel, boot::Mi reference_grid[!, something(eff_col, _responsename(model))] = eff reference_grid[!, err_col] = err - # logic here is slightly different than for other methods # because we can compute empirical CIs instead of relying on a Wald # approximation @@ -98,13 +98,14 @@ Use the results of a bootstrap to compute empirical error estimates disappear entirely in a future release! """ function Effects.effects(design::AbstractDict, model::MixedModel, boot::MixedModelBootstrap; - eff_col=nothing, err_col=:err, typical=mean, - lower_col=:lower, upper_col=:upper, invlink=identity, - level=nothing) + eff_col=nothing, err_col=:err, typical=mean, + lower_col=:lower, upper_col=:upper, invlink=identity, + level=nothing) grid = expand_grid(design) dv = something(eff_col, _responsename(model)) level = isnothing(level) ? 0.68 : level - effects!(grid, model, boot; eff_col=dv, err_col, typical, invlink, level, lower_col, upper_col) + effects!(grid, model, boot; eff_col=dv, err_col, typical, invlink, level, lower_col, + upper_col) return grid end diff --git a/test/mixedmodels.jl b/test/mixedmodels.jl index a74c42d..d3f0654 100644 --- a/test/mixedmodels.jl +++ b/test/mixedmodels.jl @@ -26,7 +26,7 @@ eff = effects(design, model) @test eff.y + eff.err ≈ eff.upper β = fixef(model) -@test only(eff.y) ≈ β[1] + 2 * β[2] + β[3] +@test only(eff.y) ≈ β[1] + 2 * β[2] + β[3] # there is one bit of weirdness -- the removed coefficients behave like any other # variable in the "design" that is missing from the model. @@ -50,9 +50,9 @@ bootdf = unstack(DataFrame(boot.β), :coefname, :β) # now make sure the bootstrap gives approximately the same results eff_boot = effects(design, model, boot) @test eff_boot.y ≈ eff.y -@test eff_boot.err ≈ eff.err atol=0.005 +@test eff_boot.err ≈ eff.err atol = 0.005 eff95 = effects(design, model; level=0.95) eff_boot95 = effects(design, model, boot; level=0.95) -@test eff_boot95.lower ≈ eff95.lower atol=0.1 -@test eff_boot95.upper ≈ eff95.upper atol=0.1 +@test eff_boot95.lower ≈ eff95.lower atol = 0.1 +@test eff_boot95.upper ≈ eff95.upper atol = 0.1