Get pairwise comparison of the levels of a categorical variable
Source:R/model_get_pairwise_contrasts.R
model_get_pairwise_contrasts.Rd
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"
(ifTRUE
) or"revpairwise"
(ifFALSE
), seeemmeans::contrast()
.- contrasts_adjust
optional adjustment method when computing contrasts, see
emmeans::contrast()
(ifNULL
, useemmeans
default)- conf.level
(
numeric
)
Level of confidence for confidence intervals (default: 95%).- emmeans_args
(
logical
)
List of additional parameter to pass toemmeans::emmeans()
when computing pairwise contrasts.
Details
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
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"
)
}
}