Skip to content

Commit

Permalink
esrtimate_means(backend = "marginaleffects") not calculating margin…
Browse files Browse the repository at this point in the history
…al means

Fixes #273
  • Loading branch information
strengejacke committed Dec 13, 2024
1 parent e269425 commit 9e47d1b
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions R/get_marginalmeans.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,13 @@
datagrid <- datagrid[insight::find_predictors(model, effects = "fixed", flatten = TRUE)]
at_specs <- attributes(datagrid)$at_specs

if (marginal) {
means <- marginaleffects::predictions(model,
newdata = insight::get_data(model),
by = at_specs$varname,
conf_level = ci
)
} else if (insight::is_mixed_model(model)) {
means <- marginaleffects::predictions(model,
newdata = datagrid,
by = at_specs$varname,
conf_level = ci,
re.form = NA
)
} else {
means <- marginaleffects::predictions(model,
newdata = datagrid,
by = at_specs$varname,
conf_level = ci
)
}
## TODO: extract correct type argument
means <- marginaleffects::avg_predictions(
model,
by = at_specs$varname,
conf_level = ci
)

attr(means, "at") <- my_args$by
attr(means, "by") <- my_args$by
means
Expand Down

0 comments on commit 9e47d1b

Please sign in to comment.