Skip to contents

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

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.

Examples

# \donttest{
  mod <- lm(Sepal.Length ~ Species, data = iris)
  mod |> model_get_pairwise_contrasts(variables = "Species")
#> # A tibble: 3 × 10
#>   variable term         estimate std.error statistic  p.value conf.low conf.high
#>   <chr>    <chr>           <dbl>     <dbl>     <dbl>    <dbl>    <dbl>     <dbl>
#> 1 Species  versicolor …    0.93      0.103      9.03 3.39e-14    0.686     1.17 
#> 2 Species  virginica -…    1.58      0.103     15.4  3.00e-15    1.34      1.83 
#> 3 Species  virginica -…    0.652     0.103      6.33 8.29e- 9    0.408     0.896
#> # ℹ 2 more variables: contrasts <chr>, contrasts_type <chr>
  mod |>
    model_get_pairwise_contrasts(
      variables = "Species",
      contrasts_adjust = "none"
    )
#> # A tibble: 3 × 10
#>   variable term         estimate std.error statistic  p.value conf.low conf.high
#>   <chr>    <chr>           <dbl>     <dbl>     <dbl>    <dbl>    <dbl>     <dbl>
#> 1 Species  versicolor …    0.93      0.103      9.03 8.77e-16    0.727     1.13 
#> 2 Species  virginica -…    1.58      0.103     15.4  2.21e-32    1.38      1.79 
#> 3 Species  virginica -…    0.652     0.103      6.33 2.77e- 9    0.449     0.855
#> # ℹ 2 more variables: contrasts <chr>, contrasts_type <chr>
# }