Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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,
  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,
  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. Note that 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, say, logistic regressions, or more generally speaking: for models with log or logit link. Note: standard errors are also transformed (by multiplying the standard errors with the exponentiated coefficients), to mimic behaviour of other software packages, such as Stata. For compare_parameters(), exponentiate = "nongaussian" will only exponentiate coefficients for all models except those from Gaussian family.

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 ....

verbose

Toggle warnings and messages.

Value

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

Note

This function is in an early stage and does not yet cope with more complex models, and probably does not yet properly render all model components.

Examples

if (packageVersion("insight") >= "0.13.0") {
  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)

  # 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."))
}

parameters

Processing of Model Parameters

v0.13.0
GPL-3
Authors
Daniel Lüdecke [aut, cre] (<https://orcid.org/0000-0002-8895-3206>, @strengejacke), Dominique Makowski [aut] (<https://orcid.org/0000-0001-5375-9967>), Mattan S. Ben-Shachar [aut] (<https://orcid.org/0000-0002-4287-4801>), Indrajeet Patil [aut] (<https://orcid.org/0000-0003-1995-6531>, @patilindrajeets), Søren Højsgaard [aut], Zen J. Lau [ctb], Vincent Arel-Bundock [ctb] (<https://orcid.org/0000-0003-1995-6531>, @vincentab), Jeffrey Girard [ctb] (<https://orcid.org/0000-0002-7359-3746>, @jeffreymgirard)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.