Learn R Programming

broom.helpers (version 1.17.0)

model_get_pairwise_contrasts: Get pairwise comparison of the levels of a categorical variable

Description

It is computed with emmeans::emmeans().

Usage

model_get_pairwise_contrasts(
  model,
  variables,
  pairwise_reverse = TRUE,
  contrasts_adjust = NULL,
  conf.level = 0.95,
  emmeans_args = list()
)

Arguments

model

(a model object, e.g. glm)
A model object.

variables

(tidy-select)
Variables to add pairwise contrasts.

pairwise_reverse

(logical)
Determines whether to use "pairwise" (if TRUE) or "revpairwise" (if FALSE), see emmeans::contrast().

contrasts_adjust

optional adjustment method when computing contrasts, see emmeans::contrast() (if NULL, use emmeans default)

conf.level

(numeric)
Level of confidence for confidence intervals (default: 95%).

emmeans_args

(logical)
List of additional parameter to pass to emmeans::emmeans() when computing pairwise contrasts.

Details

[Experimental] For pscl::zeroinfl() and pscl::hurdle() models, pairwise contrasts are computed separately for each component, using mode = "count" and mode = "zero" (see documentation of emmeans) and a component column is added to the results. This support is still experimental.

See Also

Other model_helpers: model_compute_terms_contributions(), model_get_assign(), model_get_coefficients_type(), model_get_contrasts(), model_get_model(), model_get_model_frame(), model_get_model_matrix(), model_get_n(), model_get_nlevels(), model_get_offset(), model_get_response(), model_get_response_variable(), model_get_terms(), model_get_weights(), model_get_xlevels(), model_identify_variables(), model_list_contrasts(), model_list_higher_order_variables(), model_list_terms_levels(), model_list_variables()

Examples

Run this code
if (FALSE) { # interactive()
if (.assert_package("emmeans", boolean = TRUE)) {
  mod <- lm(Sepal.Length ~ Species, data = iris)
  mod |> model_get_pairwise_contrasts(variables = "Species")
  mod |>
    model_get_pairwise_contrasts(
      variables = "Species",
      contrasts_adjust = "none"
    )
}
}

Run the code above in your browser using DataLab