View source: R/tidy_add_pairwise_contrasts.R
tidy_add_pairwise_contrasts | R Documentation |
Computes pairwise contrasts with emmeans::emmeans()
and add them to the
results tibble. Works only with models supported by emmeans
, see
vignette("models", package = "emmeans")
.
tidy_add_pairwise_contrasts(
x,
variables = all_categorical(),
keep_model_terms = FALSE,
pairwise_reverse = TRUE,
contrasts_adjust = NULL,
conf.level = attr(x, "conf.level"),
emmeans_args = list(),
model = tidy_get_model(x),
quiet = FALSE
)
x |
( |
variables |
include ( |
keep_model_terms |
( |
pairwise_reverse |
( |
contrasts_adjust |
( |
conf.level |
( |
emmeans_args |
( |
model |
(a model object, e.g. |
quiet |
( |
If the contrasts
column is not yet available in x
,
tidy_add_contrasts()
will be automatically applied.
For multi-components models, such as zero-inflated Poisson or beta regression, support of pairwise contrasts is still experimental.
Other tidy_helpers:
tidy_add_coefficients_type()
,
tidy_add_contrasts()
,
tidy_add_estimate_to_reference_rows()
,
tidy_add_header_rows()
,
tidy_add_n()
,
tidy_add_reference_rows()
,
tidy_add_term_labels()
,
tidy_add_variable_labels()
,
tidy_attach_model()
,
tidy_disambiguate_terms()
,
tidy_identify_variables()
,
tidy_plus_plus()
,
tidy_remove_intercept()
,
tidy_select_variables()
if (.assert_package("emmeans", boolean = TRUE)) {
mod1 <- lm(Sepal.Length ~ Species, data = iris)
mod1 |>
tidy_and_attach() |>
tidy_add_pairwise_contrasts()
mod1 |>
tidy_and_attach() |>
tidy_add_pairwise_contrasts(pairwise_reverse = FALSE)
mod1 |>
tidy_and_attach() |>
tidy_add_pairwise_contrasts(keep_model_terms = TRUE)
mod1 |>
tidy_and_attach() |>
tidy_add_pairwise_contrasts(contrasts_adjust = "none")
if (.assert_package("gtsummary", boolean = TRUE)) {
mod2 <- glm(
response ~ age + trt + grade,
data = gtsummary::trial,
family = binomial
)
mod2 |>
tidy_and_attach(exponentiate = TRUE) |>
tidy_add_pairwise_contrasts()
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.