cell_means_q: Estimated values of a linear model.

View source: R/cell_means.R

cell_means_qR Documentation

Estimated values of a linear model.

Description

cell_means_q calculates the predicted values at specific points, given a fitted regression model (linear, generalized, or ANOVA).

Usage

cell_means_q(model, ...)

## S3 method for class 'lm'
cell_means_q(model, vars = NULL, levels = NULL, ...)

## S3 method for class 'aov'
cell_means_q(model, vars = NULL, levels = NULL, ...)

## S3 method for class 'glm'
cell_means_q(
  model,
  vars = NULL,
  levels = NULL,
  type = c("link", "response"),
  ...
)

Arguments

model

A fitted linear model of type 'lm', 'aov', or 'glm'.

...

Not currently implemented; used to ensure consistency with S3 generic.

vars

A vector or list with variable names to be added to the table.

levels

A list with element names corresponding to some or all of the variables in the model. Each list element should be a vector with the names of factor levels (for categorical variables) or numeric points (for continuous variables) at which to test that variable.

type

The type of prediction required. The default 'link' is on the scale of the linear predictors; the alternative 'response' is on the scale of the response variable. For more information, see predict.glm.

Details

By default, this function will provide means at -1 SD, the mean, and +1 SD for continuous variables, and at each level of categorical variables. This can be overridden with the levels parameter.

If there are additional covariates in the model other than what are selected in the function call, these variables will be set to their respective means. In the case of a categorical covariate, the results will be averaged across all its levels.

Note that in most cases it is easier to use cell_means and pass variable names in directly instead of strings of variable names. cell_means_q uses standard evaluation in cases where such evaluation is easier.

Value

A data frame with a row for each predicted value. The first few columns identify the level at which each variable in your model was set. After columns for each variable, the data frame has columns for the predicted value, the standard error of the predicted mean, and the 95% confidence interval.

Methods (by class)

  • cell_means_q(lm): Estimated values for a linear model.

  • cell_means_q(aov): Estimated means for ANOVA.

  • cell_means_q(glm): Estimated values for a generalized linear model.

See Also

cell_means

Examples

# iris data
model <- lm(Sepal.Length ~ Petal.Length + Petal.Width, iris)
summary(model)
cell_means_q(model, 'Petal.Length')

jeff-hughes/reghelper documentation built on Sept. 9, 2023, 1:52 p.m.