Learn R Programming

parameters (version 0.14.0)

compare_parameters: Compare model parameters of multiple models

Description

Compute and extract model parameters of multiple regression models. See model_parameters for further details.

Usage

compare_parameters(
  ...,
  ci = 0.95,
  effects = "fixed",
  component = "conditional",
  standardize = NULL,
  exponentiate = FALSE,
  df_method = "wald",
  p_adjust = NULL,
  style = NULL,
  column_names = NULL,
  groups = NULL,
  verbose = TRUE
)

compare_models( ..., ci = 0.95, effects = "fixed", component = "conditional", standardize = NULL, exponentiate = FALSE, df_method = "wald", p_adjust = NULL, style = NULL, column_names = NULL, groups = NULL, verbose = TRUE )

Arguments

...

One or more regression model objects, or objects returned by model_parameters(). Regression models may be of different model types.

ci

Confidence Interval (CI) level. Default to 0.95 (95%).

effects

Should parameters for fixed effects ("fixed"), random effects ("random"), or both ("all") be returned? Only applies to mixed models. May be abbreviated.

component

Model component for which parameters should be shown. See documentation for related model class in model_parameters.

standardize

The method used for standardizing the parameters. Can be "refit", "posthoc", "smart", "basic", "pseudo" or NULL (default) for no standardization. See 'Details' in standardize_parameters. Important: Categorical predictors (i.e. factors) are never standardized by default, which may be a different behaviour compared to other R packages or other software packages (like SPSS). If standardizing categorical predictors is desired, either use standardize="basic" to mimic behaviour of SPSS or packages such as lm.beta, or standardize the data with effectsize::standardize(force=TRUE) before fitting the model. Robust estimation (i.e. robust=TRUE) of standardized parameters only works when standardize="refit".

exponentiate

Logical, indicating whether or not to exponentiate the the coefficients (and related confidence intervals). This is typical for logistic regression, or more generally speaking, for models with log or logit links. Note: Delta-method standard errors are also computed (by multiplying the standard errors by the transformed coefficients). This is to mimic behaviour of other software packages, such as Stata, but these standard errors poorly estimate uncertainty for the transformed coefficient. The transformed confidence interval more clearly captures this uncertainty. For compare_parameters(), exponentiate = "nongaussian" will only exponentiate coefficients from non-Gaussian families.

df_method

Method for computing degrees of freedom for p values, standard errors and confidence intervals (CI). See documentation for related model class in model_parameters.

p_adjust

Character vector, if not NULL, indicates the method to adjust p-values. See p.adjust for details. Further possible adjustment methods are "tukey", "scheffe", "sidak" and "none" to explicitly disable adjustment for emmGrid objects (from emmeans).

style

String, indicating which style of output is requested. Following templates are possible:

  • "ci": Estimate and confidence intervals, no asterisks for p-values.

  • "se": Estimate and standard errors, no asterisks for p-values.

  • "ci_p": Estimate, confidence intervals and asterisks for p-values.

  • "se_p": Estimate, standard errors and asterisks for p-values.

  • "ci_p2": Estimate, confidence intervals and numeric p-values, in two columns.

  • "se_p2": Estimate, standard errors and numeric p-values, in two columns.

column_names

Character vector with strings that should be used as column headers. Must be of same length as number of models in ....

groups

Named list, can be used to group parameters in the printed output. List elements may either be character vectors that match the name of those parameters that belong to one group, or list elements can be row numbers of those parameter rows that should belong to one group. The names of the list elements will be used as group names, which will be inserted as "header row". A possible use case might be to emphasize focal predictors and control variables, see 'Examples'. Parameters will be re-ordered according to the order used in groups, while all non-matching parameters will be added to the end.

verbose

Toggle warnings and messages.

Value

A data frame of indices related to the model's parameters.

Examples

Run this code
# NOT RUN {
data(iris)
lm1 <- lm(Sepal.Length ~ Species, data = iris)
lm2 <- lm(Sepal.Length ~ Species + Petal.Length, data = iris)
lm3 <- lm(Sepal.Length ~ Species * Petal.Length, data = iris)
compare_parameters(lm1, lm2, lm3)

data(mtcars)
m1 <- lm(mpg ~ wt, data = mtcars)
m2 <- glm(vs ~ wt + cyl, data = mtcars, family = "binomial")
compare_parameters(m1, m2)

# }
# NOT RUN {
# exponentiate coefficients, but not for lm
compare_parameters(m1, m2, exponentiate = "nongaussian")

# change column names
compare_parameters(m1, m2, column_names = c("linear model", "logistic reg."))
# }

Run the code above in your browser using DataLab