Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harmonize ggeffects and modelbased #248

Open
strengejacke opened this issue Feb 15, 2024 · 0 comments
Open

Harmonize ggeffects and modelbased #248

strengejacke opened this issue Feb 15, 2024 · 0 comments

Comments

@strengejacke
Copy link
Member

@DominiqueMakowski This is a draft for ggeffects, WDYT? From the docs:

predict_response() is a wrapper around ggpredict(), ggeffect(),
ggemmeans() and ggaverage(). Depending on the value of the marginalize
argument, predict_response() calls one of those functions, sometimes with
different arguments. The marginalize argument indicates how to marginalize
over the non-focal predictors, i.e. those variables that are not specified
in terms. Possible values are:

  • "mean_reference": calls ggpredict(), i.e. non-focal predictors are set
    to their mean (numeric variables) or reference level (factors, or "lowest"
    value in case of character vectors).

  • "mean_mode": calls ggpredict(typical = c(numeric = "mean", factor = "mode")),
    i.e. non-focal predictors are set to their mean (numeric variables) or mode
    (factors, or "most common" value in case of character vectors).

  • "marginalmeans": calls ggemmeans(), i.e. non-focal predictors are
    set to their mean (numeric variables) or marginalized over the levels or
    "values" for factors and character vectors. Marginalizing over the factor
    levels of non-focal terms computes a kind of "weighted average" for the
    values at which these terms are hold constant.

  • "empirical" (or "counterfactual"): calls ggaverage(), i.e. non-focal
    predictors are marginalized over the observations in your sample. Technically,
    ggaverage() calculates predicted values for each observation in the data
    multiple times (the data is duplicated once for all unique values of the focal
    terms), each time fixing one unique value or level of the focal terms and
    then takes the average of these predicted values (aggregated/grouped by the
    focal terms). These kind of predictions are also called "counterfactual"
    predictions (Dickerman and Hernan 2020). There is a more detailed description
    in this vignette.

In marginaleffects, that would be something like:

predictions(newdata = "means", by = ...), predictions(by = ...), predictions(newdata = "marginalmeans", by = ...), avg_predictions(variables = ...)

This looks like the four most common "marginalization" methods?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant