12 Further Examples of Conditional Process Analysis
In this chapter [Hayes built] on the foundation laid by stepping through an analysis of a more complicated conditional process model that include[d] moderation of both the indirect effects in a simple mediation model. [He did] so by first using a piecemeal approach that focuse[d] on each pathway in the model. With some understanding gained by this examination of the components in the process, [he brought] the pieces together into an integrated conditional process analysis…
When an indirect effect of \(X\) on \(Y\) through \(M\) is moderated, we call this phenomenon moderated mediation. In such a scenario, the mechanism represented by the \(X \rightarrow M \rightarrow Y\) chain of events operates to varying degrees (or not at all) for certain people or in certain contexts. A similar-sounding phenomenon is mediated moderation, which refers to the scenario in which an interaction between X and some moderator \(W\) on \(Y\) is carried through a mediator \(M\). [We’ll see] in this chapter that a mediated moderation analysis is really nothing other than a mediation analysis with the product of two variables serving as the causal agent of focus. (Andrew F. Hayes, 2018, p. 432)
12.1 Revisiting the disaster framing study
Here we load a couple necessary packages, load the data, and take a glimpse()
.
library(tidyverse)
<- read_csv("data/disaster/disaster.csv")
disaster
glimpse(disaster)
## Rows: 211
## Columns: 5
## $ id <dbl> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 2…
## $ frame <dbl> 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0,…
## $ donate <dbl> 5.6, 4.2, 4.2, 4.6, 3.0, 5.0, 4.8, 6.0, 4.2, 4.4, 5.8, 6.2, 6.0, 4.2, 4.4, 5.8, 5.4, 3.4, 7.…
## $ justify <dbl> 2.95, 2.85, 3.00, 3.30, 5.00, 3.20, 2.90, 1.40, 3.25, 3.55, 1.55, 1.60, 1.65, 2.65, 3.15, 2.…
## $ skeptic <dbl> 1.8, 5.2, 3.2, 1.0, 7.6, 4.2, 4.2, 1.2, 1.8, 8.8, 1.0, 5.4, 2.2, 3.6, 7.8, 1.6, 1.0, 6.4, 3.…
Load brms.
library(brms)
At the top of page 433, Hayes fit a simple univariable model
\[Y = b_0 + b_1 X + e_Y,\]
where the \(X\) is frame
the \(Y\) is donate
. Here’s the model.
.1 <- brm(
model12data = disaster,
family = gaussian,
~ 1 + frame,
donate chains = 4, cores = 4,
file = "fits/model12.01")
Check the summary.
print(model12.1, digits = 3)
## Family: gaussian
## Links: mu = identity; sigma = identity
## Formula: donate ~ 1 + frame
## Data: disaster (Number of observations: 211)
## Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
## total post-warmup draws = 4000
##
## Population-Level Effects:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept 4.564 0.128 4.316 4.808 1.000 4275 3070
## frame 0.084 0.182 -0.279 0.444 1.000 4781 3193
##
## Family Specific Parameters:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sigma 1.326 0.066 1.207 1.463 1.003 4205 3053
##
## Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
Hayes interpreted the coefficient for frame
through the lens of a \(t\) statistic and accompanying \(p\)-value. We’ll just plot the posterior. For the figures in this chapter, we’ll take theme cues from the vignettes from Matthew Kay’s tidybayes package.
library(tidybayes)
theme_set(theme_tidybayes() + cowplot::panel_border())
as_draws_df(model12.1) %>%
ggplot(aes(x = b_frame, y = 0)) +
stat_halfeye() +
geom_vline(xintercept = 0, linetype = 2) +
scale_y_continuous(NULL, breaks = NULL)
Now we fit the moderation model
\[Y = b_0 + b_1 X + b_2 W + b_3 XW + e_Y,\]
where skeptic
is the \(W\) variable.
.2 <- brm(
model12data = disaster,
family = gaussian,
~ 1 + frame + skeptic + frame:skeptic,
donate chains = 4, cores = 4,
file = "fits/model12.02")
Our model12.2
summary matches nicely with the text.
print(model12.2, digits = 3)
## Family: gaussian
## Links: mu = identity; sigma = identity
## Formula: donate ~ 1 + frame + skeptic + frame:skeptic
## Data: disaster (Number of observations: 211)
## Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
## total post-warmup draws = 4000
##
## Population-Level Effects:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept 5.027 0.226 4.588 5.469 1.001 2394 2921
## frame 0.678 0.333 0.027 1.335 1.000 2095 2623
## skeptic -0.139 0.058 -0.253 -0.027 1.000 2351 2563
## frame:skeptic -0.172 0.085 -0.341 -0.007 1.000 2026 2607
##
## Family Specific Parameters:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sigma 1.241 0.062 1.128 1.371 1.002 3031 2750
##
## Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
Here’s our Figure 12.2.
<- crossing(frame = 0:1,
nd skeptic = seq(from = 0, to = 7, length.out = 30))
fitted(model12.2, newdata = nd) %>%
data.frame() %>%
bind_cols(nd) %>%
mutate(frame = ifelse(frame == 0, str_c("Natural causes (X = ", frame, ")"),
str_c("Climate change (X = ", frame, ")"))) %>%
mutate(frame = factor(frame,
levels = c("Natural causes (X = 0)",
"Climate change (X = 1)"))) %>%
ggplot(aes(x = skeptic, y = Estimate)) +
geom_ribbon(aes(ymin = Q2.5, ymax = Q97.5, fill = frame),
alpha = 1/3) +
geom_line(aes(color = frame)) +
scale_fill_brewer(palette = "Set2") +
scale_color_brewer(palette = "Set2") +
coord_cartesian(xlim = c(1, 6),
ylim = c(3.5, 5.5)) +
labs(x = expression(paste("Climate Change Skepticism (", italic(W), ")")),
y = "Willingness to Donate to Victims") +
theme(legend.direction = "horizontal",
legend.position = "top",
legend.title = element_blank())
In Hayes’s Figure 12.2, he emphasized the differences at the three levels of skeptic
. If you want the full difference score distributions in a pick-a-point-approach sort of way, you might plot the densities with tidybayes::stat_halfeye()
, which places coefficient plots at the base of the densities. In this case, we show the posterior medians with the dots, the 50% intervals with the thick horizontal lines, and the 95% intervals with the thinner horizontal lines.
<- crossing(frame = 0:1,
nd skeptic = quantile(disaster$skeptic, probs = c(.16, .5, .86)))
fitted(model12.2,
summary = F,
newdata = nd) %>%
data.frame() %>%
set_names(mutate(nd, label = str_c(frame, "_", skeptic)) %>% pull(label)) %>%
mutate(iter = 1:n()) %>%
pivot_longer(-iter) %>%
separate(name, into = c("frame", "skeptic"), sep = "_", convert = T) %>%
pivot_wider(names_from = frame, values_from = value) %>%
mutate(difference = `1` - `0`) %>%
ggplot(aes(x = difference, y = skeptic, fill = skeptic %>% as.character())) +
stat_halfeye(point_interval = median_qi, .width = c(0.95, 0.5)) +
scale_fill_brewer() +
scale_y_continuous(breaks = quantile(disaster$skeptic, probs = c(.16, .5, .86)),
labels = quantile(disaster$skeptic, probs = c(.16, .5, .86)) %>% round(2)) +
theme(legend.position = "none")
Here’s our simple mediation model, model12.3
, using the multivariate syntax right in the brm()
function.
.3 <- brm(
model12data = disaster,
family = gaussian,
bf(justify ~ 1 + frame) +
bf(donate ~ 1 + frame + justify) +
set_rescor(FALSE),
chains = 4, cores = 4,
file = "fits/model12.03")
print(model12.3, digits = 3)
## Family: MV(gaussian, gaussian)
## Links: mu = identity; sigma = identity
## mu = identity; sigma = identity
## Formula: justify ~ 1 + frame
## donate ~ 1 + frame + justify
## Data: disaster (Number of observations: 211)
## Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
## total post-warmup draws = 4000
##
## Population-Level Effects:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## justify_Intercept 2.801 0.089 2.626 2.974 1.004 6717 2862
## donate_Intercept 7.235 0.228 6.775 7.662 1.000 6596 3057
## justify_frame 0.135 0.130 -0.123 0.391 1.002 6215 2749
## donate_frame 0.212 0.139 -0.058 0.484 1.002 6520 3140
## donate_justify -0.953 0.075 -1.097 -0.802 1.000 7014 3043
##
## Family Specific Parameters:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sigma_justify 0.934 0.047 0.849 1.033 1.002 6432 3240
## sigma_donate 0.985 0.048 0.897 1.083 0.999 5757 3084
##
## Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
Consider the Bayesian \(R^2\) summaries.
bayes_R2(model12.3) %>% round(digits = 3)
## Estimate Est.Error Q2.5 Q97.5
## R2justify 0.010 0.012 0.000 0.042
## R2donate 0.449 0.039 0.364 0.517
If you want the indirect effect with its intervals, you use as_draws_df()
and data wrangle, as usual.
as_draws_df(model12.3) %>%
mutate(ab = b_justify_frame * b_donate_justify) %>%
mean_qi(ab)
## # A tibble: 1 × 6
## ab .lower .upper .width .point .interval
## <dbl> <dbl> <dbl> <dbl> <chr> <chr>
## 1 -0.128 -0.378 0.117 0.95 mean qi
12.2 Moderation of the direct and indirect effects in a conditional process model
Our conditional process model follows the form
\[\begin{align*} M & = i_M + a_1 X + a_2 W + a_3 XW + e_M \\ Y & = i_Y + c_1' X + c_2' W + c_3' XW + b M + e_Y. \end{align*}\]
We don’t need to do anything particularly special to fit a model like this with brms. It just requires we do a careful job specifying the formulas in our bf()
arguments. If you find this syntax a little too cumbersome, you can always specify the formulas outside of brm()
, save them as one or multiple objects, and plug those objects into brm()
.
.4 <- brm(
model12data = disaster,
family = gaussian,
bf(justify ~ 1 + frame + skeptic + frame:skeptic) +
bf(donate ~ 1 + frame + justify + skeptic + frame:skeptic) +
set_rescor(FALSE),
chains = 4, cores = 4,
file = "fits/model12.04")
Check the model summary.
print(model12.4, digits = 3)
## Family: MV(gaussian, gaussian)
## Links: mu = identity; sigma = identity
## mu = identity; sigma = identity
## Formula: justify ~ 1 + frame + skeptic + frame:skeptic
## donate ~ 1 + frame + justify + skeptic + frame:skeptic
## Data: disaster (Number of observations: 211)
## Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
## total post-warmup draws = 4000
##
## Population-Level Effects:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## justify_Intercept 2.453 0.149 2.166 2.746 1.000 3521 3162
## donate_Intercept 7.297 0.266 6.779 7.821 1.000 3780 3222
## justify_frame -0.565 0.219 -1.001 -0.122 1.000 3289 2664
## justify_skeptic 0.105 0.038 0.029 0.178 1.000 3660 3216
## justify_frame:skeptic 0.201 0.055 0.090 0.308 1.000 3335 2809
## donate_frame 0.156 0.263 -0.357 0.671 1.002 3344 3217
## donate_justify -0.923 0.083 -1.085 -0.756 1.001 4128 2837
## donate_skeptic -0.044 0.047 -0.139 0.049 1.001 3737 3006
## donate_frame:skeptic 0.017 0.067 -0.115 0.149 1.002 3194 2802
##
## Family Specific Parameters:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sigma_justify 0.817 0.040 0.741 0.900 1.001 5063 2902
## sigma_donate 0.989 0.050 0.898 1.095 1.000 5217 2370
##
## Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
Here are the Bayesian \(R^2\) summaries.
bayes_R2(model12.4)
## Estimate Est.Error Q2.5 Q97.5
## R2justify 0.2482236 0.04335464 0.1629624 0.3285198
## R2donate 0.4525392 0.03695545 0.3725687 0.5185562
12.2.2 Quantifying direct and indirect effects.
Here are summaries for \(a_1\) through \(a_3\).
fixef(model12.4)[c(3:5), ] %>% round(digits = 3)
## Estimate Est.Error Q2.5 Q97.5
## justify_frame -0.565 0.219 -1.001 -0.122
## justify_skeptic 0.105 0.038 0.029 0.178
## justify_frame:skeptic 0.201 0.055 0.090 0.308
This is \(b\).
fixef(model12.4)["donate_justify", ] %>% round(digits = 3)
## Estimate Est.Error Q2.5 Q97.5
## -0.923 0.083 -1.085 -0.756
We’ll need to employ as_draws_df()
to compute \((a_1 + a_3 W)b\), as shown in Table 12.2.
<- as_draws_df(model12.4) %>%
draws mutate(`indirect effect when W is 1.592` = (b_justify_frame + `b_justify_frame:skeptic` * 1.592) * b_donate_justify,
`indirect effect when W is 2.800` = (b_justify_frame + `b_justify_frame:skeptic` * 2.800) * b_donate_justify,
`indirect effect when W is 5.200` = (b_justify_frame + `b_justify_frame:skeptic` * 5.200) * b_donate_justify)
%>%
draws pivot_longer(starts_with("indirect")) %>%
group_by(name) %>%
median_qi(value, .width = .95) %>%
mutate_if(is.double, round, digits = 3)
## # A tibble: 3 × 7
## name value .lower .upper .width .point .interval
## <chr> <dbl> <dbl> <dbl> <dbl> <chr> <chr>
## 1 indirect effect when W is 1.592 0.222 -0.04 0.512 0.95 median qi
## 2 indirect effect when W is 2.800 0 -0.204 0.217 0.95 median qi
## 3 indirect effect when W is 5.200 -0.44 -0.73 -0.187 0.95 median qi
And if you really want that full-on Table 12.2 layout, try this.
%>%
draws transmute(a1 = b_justify_frame,
a3 = `b_justify_frame:skeptic`,
b = b_donate_justify,
c1 = b_donate_frame,
c3 = `b_donate_frame:skeptic`) %>%
expand_grid(w = c(1.592, 2.800, 5.200)) %>%
mutate(`a1 + a3w` = a1 + a3 * w,
`(a1 + a3w)b` = (a1 + a3 * w) * b,
`direct effect` = c1 + c3 * w) %>%
select(-(a1:a3), -(c1:c3)) %>%
pivot_longer(-w) %>%
group_by(w, name) %>%
summarise(mean = mean(value) %>% round(digits = 3)) %>%
pivot_wider(names_from = name,
values_from = mean) %>%
select(w, `a1 + a3w`, b, everything())
## # A tibble: 3 × 5
## # Groups: w [3]
## w `a1 + a3w` b `(a1 + a3w)b` `direct effect`
## <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1.59 -0.245 -0.923 0.226 0.184
## 2 2.8 -0.002 -0.923 0.002 0.205
## 3 5.2 0.481 -0.923 -0.444 0.247
12.2.2.1 The conditional direct effect of \(X\).
We already computed this in the last code block, above. But since we just focused on the posterior means, here’s a summary of their medians and 95% intervals.
<- draws %>%
draws mutate(`direct effect when W is 1.592` = b_donate_frame + `b_donate_frame:skeptic` * 1.592,
`direct effect when W is 2.800` = b_donate_frame + `b_donate_frame:skeptic` * 2.800,
`direct effect when W is 5.200` = b_donate_frame + `b_donate_frame:skeptic` * 5.200)
%>%
draws pivot_longer(starts_with("direct")) %>%
group_by(name) %>%
median_qi(value, .width = .95) %>%
mutate_if(is.double, round, digits = 3) %>%
select(name:.upper)
## # A tibble: 3 × 4
## name value .lower .upper
## <chr> <dbl> <dbl> <dbl>
## 1 direct effect when W is 1.592 0.185 -0.161 0.537
## 2 direct effect when W is 2.800 0.203 -0.069 0.481
## 3 direct effect when W is 5.200 0.248 -0.117 0.615
We can always plot, too.
<- c(1.592, 2.800, 5.200)
w
%>%
draws expand_grid(w = w) %>%
mutate(`conditional direct effect` = b_donate_frame + `b_donate_frame:skeptic` * w) %>%
ggplot(aes(x = `conditional direct effect`, y = w, fill = w %>% as.character())) +
stat_halfeye(point_interval = median_qi, .width = c(0.95, 0.5)) +
scale_y_continuous(breaks = w) +
scale_fill_brewer() +
theme(legend.position = "none")
12.2.3 Visualizing the direct and indirect effects.
We’ll need to do some draws
wrangling before we’re ready to make our Figure 12.7. We’ll save the results as effects
.
<- draws %>%
effects expand_grid(w = seq(from = 0, to = 6, length.out = 30)) %>%
mutate(`direct effect` = b_donate_frame + `b_donate_frame:skeptic` * w,
`indirect effect` = (b_justify_frame + `b_justify_frame:skeptic` * w) * b_donate_justify) %>%
pivot_longer(c(`direct effect`, `indirect effect`)) %>%
mutate(name = factor(name, levels = c("direct effect", "indirect effect"))) %>%
select(w:value)
head(effects)
## # A tibble: 6 × 3
## w name value
## <dbl> <fct> <dbl>
## 1 0 direct effect 0.349
## 2 0 indirect effect 0.342
## 3 0.207 direct effect 0.353
## 4 0.207 indirect effect 0.302
## 5 0.414 direct effect 0.356
## 6 0.414 indirect effect 0.261
Now we plot.
# we'll need this for `geom_text()`
<- tibble(
text x = c(4.2, 4.7),
y = c(.28, -.28),
angle = c(3.6, 335),
name = factor(c("direct effect", "indirect effect"), levels = c("direct effect", "indirect effect")))
# plot!
%>%
effects ggplot(aes(x = w, color = name, fill = name)) +
stat_lineribbon(aes(y = value),
.width = .95, alpha = 1/3) +
geom_text(data = text,
aes(x = x, y = y,
angle = angle,
label = name),
size = 5) +
scale_fill_brewer(type = "qual") +
scale_color_brewer(type = "qual") +
coord_cartesian(xlim = c(1, 5.5),
ylim = c(-.6, .4)) +
labs(x = expression(Climate~Change~Skepticism~(italic(W))),
y = "Effects of Disaster Frame on Willingness to Donate") +
theme(legend.position = "none")
Note how wide those 95% intervals are relative to the scale of the \(y\)-axis, which I specifically kept within the same range as Figure 12.7 in the text. To me the message is clear: include credible-interval ribbons in your regression slope plots. They help depict how uncertain the posterior is in a way a simple line slopes just don’t.
12.3 Statistical inference
12.3.1 Inference about the direct effect.
We’ve already computed the 95% intervals for the direct effect, \(\theta_{X \rightarrow Y}\), conditional on the three levels of \(W\). Here’s a different look at those intervals, superimposed on the 80% and 50% intervals, using the tidybayes::stat_interval()
function.
%>%
draws pivot_longer(starts_with("direct")) %>%
mutate(name = str_remove(name, "direct effect when W is ") %>% as.double()) %>%
ggplot(aes(x = name, y = value, group = name)) +
stat_interval(.width = c(.95, .80, .5)) +
scale_color_brewer("Interval") +
coord_cartesian(xlim = c(1, 5.5)) +
labs(x = expression(paste("Climate Change Skepticism (", italic(W), ")")),
y = "Conditional Direct Effect of Disaster Frame on\nWillingness to Donate")
12.3.2 Inference about the indirect effect.
12.3.2.1 A statistical test of moderated mediation.
To get a sense of \(a_3 b\), we just:
<- draws %>%
draws mutate(a3b = `b_justify_frame:skeptic` * b_donate_justify)
%>%
draws select(a3b) %>%
median_qi(a3b) %>%
mutate_if(is.double, round, digits = 3)
## # A tibble: 1 × 6
## a3b .lower .upper .width .point .interval
## <dbl> <dbl> <dbl> <dbl> <chr> <chr>
## 1 -0.185 -0.294 -0.083 0.95 median qi
Here we’ll combine stat_intervalh()
and stat_pointintervalh()
to visualize \(a_3 b\) with a coefficient plot.
%>%
draws ggplot(aes(x = a3b, y = 1)) +
stat_interval(.width = c(.95, .8, .5)) +
stat_pointinterval(point_interval = median_qi, .width = c(.95, .8, .5),
position = position_nudge(y = -.75)) +
scale_color_brewer("Interval") +
scale_y_discrete(NULL, breaks = NULL) +
coord_cartesian(xlim = c(-.5, 0)) +
labs(title = expression(paste("Coefficient plot for ", italic(a)[3], italic(b), " (i.e., the index of moderated mediation)")),
x = NULL) +
theme(legend.position = "none")
12.3.2.2 Probing moderation of mediation.
As we discussed in Chapter 11, our Bayesian version of the JN technique should be fine because HMC does not impose the normality assumption on the parameter posteriors. In this instance, I’ll leave the JN technique plot as an exercise for the interested reader. Here we’ll just follow along with the text and pick a few points.
We computed and inspected these 95% intervals, above. Here’s another way we might stat_halfeye()
to look at their entire densities.
%>%
draws pivot_longer(starts_with("indirect")) %>%
rename(`conditional indirect effect` = value) %>%
mutate(W = str_remove(name, "indirect effect when W is ") %>% as.double()) %>%
ggplot(aes(x = W, y = `conditional indirect effect`, fill = W %>% as.character())) +
geom_hline(yintercept = 0, linetype = 2) +
stat_halfeye(point_interval = median_qi, .width = 0.95) +
scale_fill_brewer() +
scale_x_continuous(breaks = c(1.592, 2.8, 5.2),
labels = c(1.6, 2.8, 5.2)) +
coord_cartesian(ylim = c(-1, 1)) +
theme(legend.position = "none",
panel.grid.minor.y = element_blank())
12.3.3 Pruning the model.
Fitting the model without the interaction term is just a small change to one of our formula
arguments.
.5 <- brm(
model12data = disaster,
family = gaussian,
bf(justify ~ 1 + frame + skeptic + frame:skeptic) +
bf(donate ~ 1 + frame + justify + skeptic) +
set_rescor(FALSE),
chains = 4, cores = 4,
file = "fits/model12.05")
Here are the results.
print(model12.5, digits = 3)
## Family: MV(gaussian, gaussian)
## Links: mu = identity; sigma = identity
## mu = identity; sigma = identity
## Formula: justify ~ 1 + frame + skeptic + frame:skeptic
## donate ~ 1 + frame + justify + skeptic
## Data: disaster (Number of observations: 211)
## Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
## total post-warmup draws = 4000
##
## Population-Level Effects:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## justify_Intercept 2.453 0.149 2.153 2.743 1.000 2756 2735
## donate_Intercept 7.256 0.224 6.822 7.696 1.001 5662 3546
## justify_frame -0.565 0.216 -0.998 -0.142 1.002 2411 2901
## justify_skeptic 0.105 0.038 0.031 0.180 1.000 2723 2672
## justify_frame:skeptic 0.201 0.054 0.098 0.307 1.002 2278 2474
## donate_frame 0.211 0.139 -0.062 0.484 1.001 4396 2667
## donate_justify -0.918 0.080 -1.072 -0.762 1.001 4079 2733
## donate_skeptic -0.036 0.037 -0.109 0.034 1.000 4244 3037
##
## Family Specific Parameters:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sigma_justify 0.817 0.040 0.740 0.905 1.002 4734 3006
## sigma_donate 0.985 0.049 0.894 1.087 1.001 4905 2826
##
## Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
Since we’re altering the model, we may as well use information criteria to compare the two versions.
.4 <- add_criterion(model12.4, criterion = "loo")
model12.5 <- add_criterion(model12.5, criterion = "loo")
model12
loo_compare(model12.4, model12.5) %>%
print(simplify = F)
## elpd_diff se_diff elpd_loo se_elpd_loo p_loo se_p_loo looic se_looic
## model12.5 0.0 0.0 -557.7 16.6 11.0 1.3 1115.4 33.2
## model12.4 -1.0 0.3 -558.7 16.6 12.0 1.5 1117.4 33.3
The difference in LOO-CV values for the two models was modest. There’s little predictive reason to choose one over the other. You could argue in favor of model12.5
because it’s simpler than model12.4
. Since we’ve got a complex model either way, one might also consider which one was of primary theoretical interest.
12.4 Mediated moderation
Mediation is moderated if the indirect effect of \(X\) on \(Y\) through one or more mediators is contingent on a moderator. With evidence of moderated mediation, one can claim that the \(X \rightarrow M \rightarrow Y\) chain of events functions differently or to varying degrees for different people, in different contexts or conditions, or whatever the moderator variable represents. Although similar in name and pronunciation to moderated mediation, the term mediated moderation refers to the phenomenon in which an interaction between \(X\) and a moderator \(W\) in a model of \(Y\) is carried through a mediator. (p. 459, emphasis in the original)
Hayes later opined:
Although there is an abundance of published examples of mediated moderation analysis, their frequency of occurrence in the literature should not be confused with meaningfulness of the procedure itself. I will argue toward the end of this section that rarely is the phenomenon of mediated moderation interesting when interpreted as such. It is almost always substantively more meaningful to conceptualize a mediated moderation process in terms of moderated mediation. But before doing this, I will describe how a mediated moderation analysis is undertaken. (p. 460)
12.4.1 Mediated moderation as the indirect effect of a product.
Hayes explains this in the next subsection, but we’ve already fit this model presented in this subsection. We called it model12.4
. Here’s the summary.
print(model12.4, digits = 3)
## Family: MV(gaussian, gaussian)
## Links: mu = identity; sigma = identity
## mu = identity; sigma = identity
## Formula: justify ~ 1 + frame + skeptic + frame:skeptic
## donate ~ 1 + frame + justify + skeptic + frame:skeptic
## Data: disaster (Number of observations: 211)
## Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
## total post-warmup draws = 4000
##
## Population-Level Effects:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## justify_Intercept 2.453 0.149 2.166 2.746 1.000 3521 3162
## donate_Intercept 7.297 0.266 6.779 7.821 1.000 3780 3222
## justify_frame -0.565 0.219 -1.001 -0.122 1.000 3289 2664
## justify_skeptic 0.105 0.038 0.029 0.178 1.000 3660 3216
## justify_frame:skeptic 0.201 0.055 0.090 0.308 1.000 3335 2809
## donate_frame 0.156 0.263 -0.357 0.671 1.002 3344 3217
## donate_justify -0.923 0.083 -1.085 -0.756 1.001 4128 2837
## donate_skeptic -0.044 0.047 -0.139 0.049 1.001 3737 3006
## donate_frame:skeptic 0.017 0.067 -0.115 0.149 1.002 3194 2802
##
## Family Specific Parameters:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sigma_justify 0.817 0.040 0.741 0.900 1.001 5063 2902
## sigma_donate 0.989 0.050 0.898 1.095 1.000 5217 2370
##
## Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
12.4.2 Why mediated moderation is neither interesting nor meaningful.
Mediated moderation and moderated mediation are statistically the same.
The only difference between them is how they are interpreted, and on what part of the model your attention is focused.
Moderated mediation focuses on the conditional nature of an indirect effect–how an indirect effect is moderated. If you think of the terms “mediation” and “indirect effect” as essentially synonymous conceptually, then moderated mediation means a moderated indirect effect. Interpretive focus in a moderated mediation analysis is directed at estimating the indirect effect and how that effect varies as a function of a moderator. Mediated moderation, by contrast, asks about the mechanism through which an interaction between \(X\) and a moderator \(W\) operates, where the product of \(X\) and \(W\) is construed as the causal agent sending its effect to \(Y\) through \(M\). Focus in mediated moderation is the estimation of the indirect effect of the product of \(X\) and \(W\). (p. 465)
Hayes later concluded that we should avoid
the articulation of hypotheses or research questions in terms of the mediation of the effect of a product, abandoning the term mediated moderation entirely, and instead [reframe] such hypotheses and research questions in terms of the contingencies of an indirect effect–moderated mediation. (p. 467, emphasis in the original)
Session info
sessionInfo()
## R version 4.2.2 (2022-10-31)
## Platform: x86_64-apple-darwin17.0 (64-bit)
## Running under: macOS Big Sur ... 10.16
##
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib
##
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] tidybayes_3.0.2 brms_2.18.0 Rcpp_1.0.9 forcats_0.5.1 stringr_1.4.1 dplyr_1.0.10
## [7] purrr_1.0.1 readr_2.1.2 tidyr_1.2.1 tibble_3.1.8 ggplot2_3.4.0 tidyverse_1.3.2
##
## loaded via a namespace (and not attached):
## [1] readxl_1.4.1 backports_1.4.1 plyr_1.8.7 igraph_1.3.4 svUnit_1.0.6
## [6] splines_4.2.2 crosstalk_1.2.0 TH.data_1.1-1 rstantools_2.2.0 inline_0.3.19
## [11] digest_0.6.31 htmltools_0.5.3 fansi_1.0.3 magrittr_2.0.3 checkmate_2.1.0
## [16] googlesheets4_1.0.1 tzdb_0.3.0 modelr_0.1.8 RcppParallel_5.1.5 matrixStats_0.63.0
## [21] vroom_1.5.7 xts_0.12.1 sandwich_3.0-2 prettyunits_1.1.1 colorspace_2.0-3
## [26] rvest_1.0.2 ggdist_3.2.1 haven_2.5.1 xfun_0.35 callr_3.7.3
## [31] crayon_1.5.2 jsonlite_1.8.4 lme4_1.1-31 survival_3.4-0 zoo_1.8-10
## [36] glue_1.6.2 gtable_0.3.1 gargle_1.2.0 emmeans_1.8.0 distributional_0.3.1
## [41] pkgbuild_1.3.1 rstan_2.21.8 abind_1.4-5 scales_1.2.1 mvtnorm_1.1-3
## [46] DBI_1.1.3 miniUI_0.1.1.1 xtable_1.8-4 bit_4.0.4 stats4_4.2.2
## [51] StanHeaders_2.21.0-7 DT_0.24 htmlwidgets_1.5.4 httr_1.4.4 threejs_0.3.3
## [56] RColorBrewer_1.1-3 arrayhelpers_1.1-0 posterior_1.3.1 ellipsis_0.3.2 pkgconfig_2.0.3
## [61] loo_2.5.1 farver_2.1.1 sass_0.4.2 dbplyr_2.2.1 utf8_1.2.2
## [66] labeling_0.4.2 tidyselect_1.2.0 rlang_1.0.6 reshape2_1.4.4 later_1.3.0
## [71] munsell_0.5.0 cellranger_1.1.0 tools_4.2.2 cachem_1.0.6 cli_3.6.0
## [76] generics_0.1.3 broom_1.0.2 evaluate_0.18 fastmap_1.1.0 processx_3.8.0
## [81] knitr_1.40 bit64_4.0.5 fs_1.5.2 nlme_3.1-160 mime_0.12
## [86] projpred_2.2.1 xml2_1.3.3 compiler_4.2.2 bayesplot_1.10.0 shinythemes_1.2.0
## [91] rstudioapi_0.13 gamm4_0.2-6 reprex_2.0.2 bslib_0.4.0 stringi_1.7.8
## [96] highr_0.9 ps_1.7.2 Brobdingnag_1.2-8 lattice_0.20-45 Matrix_1.5-1
## [101] nloptr_2.0.3 markdown_1.1 shinyjs_2.1.0 tensorA_0.36.2 vctrs_0.5.1
## [106] pillar_1.8.1 lifecycle_1.0.3 jquerylib_0.1.4 bridgesampling_1.1-2 estimability_1.4.1
## [111] cowplot_1.1.1 httpuv_1.6.5 R6_2.5.1 bookdown_0.28 promises_1.2.0.1
## [116] gridExtra_2.3 codetools_0.2-18 boot_1.3-28 colourpicker_1.1.1 MASS_7.3-58.1
## [121] gtools_3.9.4 assertthat_0.2.1 withr_2.5.0 shinystan_2.6.0 multcomp_1.4-20
## [126] mgcv_1.8-41 parallel_4.2.2 hms_1.1.1 grid_4.2.2 minqa_1.2.5
## [131] coda_0.19-4 rmarkdown_2.16 googledrive_2.0.0 shiny_1.7.2 lubridate_1.8.0
## [136] base64enc_0.1-3 dygraphs_1.1.1.6