Learn R Programming

modelbased (version 0.7.0)

model_emmeans: Easy Creation of 'emmeans' Marginal Means Objects

Description

The model_emmeans function is a wrapper to facilitate the usage of emmeans::emmeans(), providing a somewhat simpler and smart API to find the variables of interest.

Usage

model_emmeans(
  model,
  levels = NULL,
  fixed = NULL,
  modulate = NULL,
  transform = "response",
  ...
)

Arguments

model

A statistical model.

levels

A character vector or formula specifying the names of the predicting factors over which to estimate means or contrasts.

fixed

A character vector indicating the names of the predictors to be "fixed" (i.e., maintained), so that the estimation is made at these values.

modulate

A character vector indicating the names of a numeric variable along which the means or the contrasts will be estimated. Other arguments from visualisation_matrix, such as length to adjust the number of data points.

transform

Is passed to the type argument in emmeans::emmeans(). See this vignette. Can be "none" (default for contrasts), "response" (default for means), "mu", "unlink", "log". "none" will leave the values on scale of the linear predictors. "response" will transform them on scale of the response variable. Thus for a logistic model, "none" will give estimations expressed in log-odds (probabilities on logit scale) and "response" in terms of probabilities.

...

Other arguments passed for instance to visualisation_matrix.

Value

An emmeans object.

Examples

Run this code
# NOT RUN {
library(modelbased)

model <- lm(Sepal.Length ~ Species + Petal.Width, data = iris)

# By default, 'levels' is set to "Species"
model_emmeans(model)

# One can estimate marginal means at several values of a 'modulate' variable
model_emmeans(model, modulate = "Petal.Width", length = 3)
# }

Run the code above in your browser using DataLab