@@ -76,7 +76,9 @@ get_marginalcontrasts <- function(
7676 # inequality effect summary, see Trenton D. Mize, Bing Han 2025
7777 # Inequality and Total Effect Summary Measures for Nominal and Ordinal Variables
7878 # Sociological Science February 5, 10.15195/v12.a7
79- # this requires a special handling, because we can only use it with avg_comparisons
79+ # this requires a special handling, because we can only use it with
80+ # `avg_comparisons()`, where we take the mean of multiple contrasts
81+ # --------------------------------------------------------------------------
8082 out <- .get_inequalitycontrasts(
8183 model ,
8284 model_data ,
@@ -88,6 +90,10 @@ get_marginalcontrasts <- function(
8890 )
8991 predict <- " response"
9092 } else if (isTRUE(my_args $ context_effects )) {
93+ # for contrasting two average slopes, we have an additional helper function
94+ # and don't use the usual machinery of `estimate_means()` here, which we
95+ # can use for other contrasts.
96+ # -------------------------------------------------------------------------
9197 out <- .get_contexteffects(model , my_args , predict , transform , model_info , ... )
9298 # set defaults, for proper printing
9399 if (is.null(predict )) {
@@ -97,8 +103,12 @@ get_marginalcontrasts <- function(
97103 }
98104 }
99105 } else if (my_args $ contrast_slopes ) {
100- # sanity check - contrast for slopes only makes sense when we have a "by" argument
106+ # Here, we are contrasting the slope of *one* predictor for different
107+ # levels of another *categorical* predictor
108+ # -------------------------------------------------------------------------
101109 if (is.null(my_args $ by )) {
110+ # sanity check - contrast for slopes only makes sense
111+ # when we have a "by" argument
102112 insight :: format_error(
103113 " Please specify the `by` argument to calculate contrasts of slopes."
104114 )
@@ -119,6 +129,7 @@ get_marginalcontrasts <- function(
119129 )
120130 } else {
121131 # for contrasts of categorical predictors, we call avg_predictions
132+ # -------------------------------------------------------------------------
122133 out <- estimate_means(
123134 model = model ,
124135 by = unique(c(my_args $ contrast , my_args $ by )),
0 commit comments