Skip to content

Commit

Permalink
YAS
Browse files Browse the repository at this point in the history
  • Loading branch information
palday committed Jul 9, 2024
1 parent 4ddaa78 commit de88007
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
13 changes: 7 additions & 6 deletions ext/EffectsMixedModelsExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Check warning on line 44 in ext/EffectsMixedModelsExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/EffectsMixedModelsExt.jl#L44

Added line #L44 was not covered by tests
boot::MixedModelBootstrap;
eff_col=nothing, err_col=:err, typical=mean, invlink=identity,
lower_col=:lower, upper_col=:upper,
level=nothing)
Expand All @@ -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

Check warning on line 68 in ext/EffectsMixedModelsExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/EffectsMixedModelsExt.jl#L65-L68

Added lines #L65 - L68 were not covered by tests


# logic here is slightly different than for other methods
# because we can compute empirical CIs instead of relying on a Wald
# approximation
Expand Down Expand Up @@ -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;

Check warning on line 100 in ext/EffectsMixedModelsExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/EffectsMixedModelsExt.jl#L100

Added line #L100 was not covered by tests
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,

Check warning on line 107 in ext/EffectsMixedModelsExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/EffectsMixedModelsExt.jl#L104-L107

Added lines #L104 - L107 were not covered by tests
upper_col)
return grid

Check warning on line 109 in ext/EffectsMixedModelsExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/EffectsMixedModelsExt.jl#L109

Added line #L109 was not covered by tests
end

Expand Down
8 changes: 4 additions & 4 deletions test/mixedmodels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

0 comments on commit de88007

Please sign in to comment.