Learn R Programming

marginaleffects (version 0.17.0)

plot_cme: plot_slopes() is an alias to plot_slopes()

Description

This alias is kept for backward compatibility.

Usage

plot_cme(...)

Value

A ggplot2 object or data frame (if draw=FALSE)

Arguments

...

Additional arguments are passed to the predict() method supplied by the modeling package.These arguments are particularly useful for mixed-effects or bayesian models (see the online vignettes on the marginaleffects website). Available arguments can vary from model to model, depending on the range of supported arguments by each modeling package. See the "Model-Specific Arguments" section of the ?marginaleffects documentation for a non-exhaustive list of available arguments.

Model-Specific Arguments

Some model types allow model-specific arguments to modify the nature of marginal effects, predictions, marginal means, and contrasts. Please report other package-specific predict() arguments on Github so we can add them to the table below.

https://github.com/vincentarelbundock/marginaleffects/issues

PackageClassArgumentDocumentation
brmsbrmsfitndrawsbrms::posterior_predict
re_formulabrms::posterior_predict
lme4merModre.formlme4::predict.merMod
allow.new.levelslme4::predict.merMod
glmmTMBglmmTMBre.formglmmTMB::predict.glmmTMB
allow.new.levelsglmmTMB::predict.glmmTMB
zitypeglmmTMB::predict.glmmTMB
mgcvbamexcludemgcv::predict.bam
robustlmmrlmerModre.formrobustlmm::predict.rlmerMod
allow.new.levelsrobustlmm::predict.rlmerMod
MCMCglmmMCMCglmmndraws

Prediction types

The type argument determines the scale of the predictions used to compute quantities of interest with functions from the marginaleffects package. Admissible values for type depend on the model object. When users specify an incorrect value for type, marginaleffects will raise an informative error with a list of valid type values for the specific model object. The first entry in the list in that error message is the default type.

The invlink(link) is a special type defined by marginaleffects. It is available for some (but not all) models and functions. With this link type, we first compute predictions on the link scale, then we use the inverse link function to backtransform the predictions to the response scale. This is useful for models with non-linear link functions as it can ensure that confidence intervals stay within desirable bounds, ex: 0 to 1 for a logit model. Note that an average of estimates with type="invlink(link)" will not always be equivalent to the average of estimates with type="response".

Some of the most common type values are:

response, link, E, Ep, average, class, conditional, count, cum.prob, cumprob, density, disp, ev, expected, expvalue, fitted, invlink(link), latent, linear.predictor, linpred, location, lp, mean, numeric, p, ppd, pr, precision, prediction, prob, probability, probs, quantile, risk, scale, survival, unconditional, utility, variance, xb, zero, zlink, zprob

Examples

Run this code
mod <- lm(mpg ~ hp + wt, data = mtcars)
plot_predictions(mod, condition = "wt")

mod <- lm(mpg ~ hp * wt * am, data = mtcars)
plot_predictions(mod, condition = c("hp", "wt"))

plot_predictions(mod, condition = list("hp", wt = "threenum"))

plot_predictions(mod, condition = list("hp", wt = range))

Run the code above in your browser using DataLab