Multilevel Moderation and Moderated Mediation

PSY 8XXX: Multilevel Modeling for Organizational Research — Week 11

Author

Instructor Name

Published

March 29, 2026

1 Introduction

In previous weeks, we explored cross-level moderation (when a Level-2 variable moderates a Level-1 relationship) and multilevel mediation (when an indirect effect operates across levels). This week, we combine these concepts: moderated mediation examines whether an indirect effect itself depends on the value of a moderator.

The research question is: “Does an indirect effect differ for teams high versus low on some team-level characteristic?” This is particularly powerful in organizational research. For example:

  • Does the mediated path from autonomy to performance (via engagement) differ for teams with supportive versus unsupportive leaders?
  • Does the indirect effect of feedback on retention (through motivation) depend on organizational commitment to development?

We’ll build intuition through simulation, then estimate conditional indirect effects and their confidence intervals.


2 Review: Cross-Level Moderation and Multilevel Mediation

Recall from Week 6 that cross-level moderation looks like:

\[Y_{ij} = \gamma_{00} + \gamma_{10} X_{ij} + \gamma_{01} Z_j + \gamma_{11} X_{ij} Z_j + u_{0j} + r_{ij}\]

The effect of \(X\) on \(Y\) depends on the value of \(Z_j\) (a Level-2 variable).

From Week 10, multilevel mediation partitions the indirect effect:

  • Within-level mediation: \(X_{ij} \to M_{ij} \to Y_{ij}\) (both at Level 1)
  • Within-between mediation: \(X_{ij} \to M_{ij}\) (L1), but \(M_j\) (L2 aggregate) \(\to Y_{ij}\)
  • Between-level mediation: \(Z_j \to M_j \to Y_{ij}\)

Now, we ask: When does the mediation depend on a moderator?

For example, the indirect effect of autonomy on performance (through engagement) might be stronger in teams led by supportive leaders. Statistically, this is moderated mediation at two levels:

\[\text{Indirect effect} = a \times b\]

where either \(a\) (the autonomy → engagement path) or \(b\) (the engagement → performance path) depends on leadership supportiveness.


3 Conditional Indirect Effects

The conditional indirect effect is the indirect effect at a specific value of the moderator:

\[\text{IE}(Z) = a(Z) \times b \quad \text{or} \quad IE(Z) = a \times b(Z)\]

If we moderator the \(a\)-path: \[\text{IE}(Z) = (\gamma_1 + \gamma_3 Z) \times b\]

If \(\gamma_3 \neq 0\), then the strength of the indirect effect changes with \(Z\).

We typically evaluate the indirect effect at specific levels of \(Z\): - At the mean of \(Z\) - At ±1 SD from the mean - At meaningful thresholds (e.g., low, medium, high supportiveness)

The Index of Moderated Mediation quantifies how much the indirect effect changes per unit increase in \(Z\): \[\text{Index} = \gamma_3 \times b\]


4 Simulating Moderated Mediation Data

Let’s create a realistic OB scenario: - 500 employees nested in 50 teams - Autonomy (L1, centered): the focal predictor - Team Supportive Leadership (L2): a team-level moderator - Engagement (L1): the mediator - Task Performance (L1): the outcome

The key mechanism: team supportive leadership strengthens the indirect effect of autonomy on performance through engagement.

Code
set.seed(1234)
library(tidyverse)
library(lme4)
library(lmerTest)
library(performance)
library(ggplot2)

# Set parameters for simulation
n_teams <- 50
n_per_team <- 10
n_total <- n_teams * n_per_team

# Level-2 (team) data
team_data <- tibble(
  team_id = 1:n_teams,
  supportive_leadership = rnorm(n_teams, mean = 5, sd = 1.5)  # 1-7 scale
)

# Level-1 (employee) data
employee_data <- expand_grid(
  team_id = 1:n_teams,
  emp_id = 1:n_per_team
) %>%
  mutate(
    person_id = row_number(),
    # Generate autonomy, centered at team level
    autonomy = rnorm(n_total, mean = 0, sd = 1)
  ) %>%
  left_join(team_data, by = "team_id")

# Now generate the mediator (engagement) with moderated a-path
# engagement ~ autonomy + autonomy x supportive_leadership
# The effect of autonomy on engagement is stronger in supportive teams

employee_data <- employee_data %>%
  mutate(
    # a-path: moderated by team supportive leadership
    engagement_mean = 4 + 0.6 * autonomy + 0.4 * autonomy * scale(supportive_leadership)[,1],
    engagement = engagement_mean + rnorm(n_total, mean = 0, sd = 0.8)
  )

# Generate outcome (performance) with engagement as mediator
# performance ~ engagement + team supportive leadership (direct effect)
# The b-path is constant across teams

employee_data <- employee_data %>%
  mutate(
    performance_mean = 5 + 0.65 * engagement + 0.3 * scale(supportive_leadership)[,1],
    performance = performance_mean + rnorm(n_total, mean = 0, sd = 0.9)
  ) %>%
  select(person_id, team_id, emp_id, autonomy, engagement,
         performance, supportive_leadership)

# Quick look at the data
head(employee_data, 12)
# A tibble: 12 × 7
   person_id team_id emp_id autonomy engagement performance
       <int>   <int>  <int>    <dbl>      <dbl>       <dbl>
 1         1       1      1   -1.81        2.43        6.12
 2         2       1      2   -0.582       2.95        7.10
 3         3       1      3   -1.11        2.80        6.62
 4         4       1      4   -1.01        3.19        6.87
 5         5       1      5   -0.162       4.09        9.06
 6         6       1      6    0.563       4.62        8.09
 7         7       1      7    1.65        3.77        6.94
 8         8       1      8   -0.773       1.51        5.34
 9         9       1      9    1.61        5.17        8.19
10        10       1     10   -1.16        4.20        6.74
11        11       2      1    0.657       4.05        9.12
12        12       2      2    2.55        5.52        8.58
# ℹ 1 more variable: supportive_leadership <dbl>

We’ve created: - autonomy: Level-1 predictor (z-scored, mean = 0) - supportive_leadership: Level-2 moderator - engagement: Level-1 mediator, with a path moderated by leadership - performance: Level-1 outcome

The true mechanism: the indirect effect of autonomy → engagement → performance is strongest in teams with high supportive leadership.


5 Fitting the Component Models

To test moderated mediation, we fit separate models for the \(a\)-path (autonomy → engagement) and \(b\)-path (engagement → performance). In practice, we could also test these simultaneously, but separate models clarify interpretation.

5.1 Model 1: The Moderated A-Path

This tests whether the effect of autonomy on engagement depends on team supportive leadership:

Code
# Scale predictors for interpretation
employee_data <- employee_data %>%
  mutate(
    sl_centered = scale(supportive_leadership)[,1]
  )

# Model M: autonomy → engagement (moderated by supportive_leadership)
model_m <- lmer(
  engagement ~ autonomy * sl_centered + (1 | team_id),
  data = employee_data
)

summary(model_m)
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: engagement ~ autonomy * sl_centered + (1 | team_id)
   Data: employee_data

REML criterion at convergence: 1178.5

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-2.9818 -0.6615 -0.0248  0.6798  2.8824 

Random effects:
 Groups   Name        Variance Std.Dev.
 team_id  (Intercept) 0.0000   0.0000  
 Residual             0.5993   0.7742  
Number of obs: 500, groups:  team_id, 50

Fixed effects:
                      Estimate Std. Error        df t value Pr(>|t|)    
(Intercept)            3.94013    0.03473 496.00000 113.440   <2e-16 ***
autonomy               0.62503    0.03383 496.00000  18.473   <2e-16 ***
sl_centered            0.04262    0.03474 496.00000   1.227    0.221    
autonomy:sl_centered   0.38156    0.03598 496.00000  10.604   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Correlation of Fixed Effects:
            (Intr) autnmy sl_cnt
autonomy    -0.046              
sl_centered  0.005 -0.062       
atnmy:sl_cn -0.065 -0.013 -0.035
optimizer (nloptwrap) convergence code: 0 (OK)
boundary (singular) fit: see help('isSingular')

What does this output tell us?

The fixed effects show: - autonomy: the effect of autonomy on engagement at the mean of supportive_leadership (approximately 0.60) - sl_centered: the effect of team leadership on engagement for someone at the mean autonomy - autonomy:sl_centered: the interaction coefficient, showing how much the autonomy effect changes per unit increase in leadership (approximately 0.35–0.40)

This interaction is the key to moderated mediation: the a-path coefficient is not constant; it depends on sl_centered.

5.2 Model 2: The B-Path (typically constant, but let’s test)

Now model the effect of engagement on performance. In this scenario, the b-path is not moderated, but we fit it anyway:

Code
# Model Y: engagement → performance (b-path)
model_y <- lmer(
  performance ~ engagement + autonomy + sl_centered + (1 | team_id),
  data = employee_data
)

summary(model_y)
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: performance ~ engagement + autonomy + sl_centered + (1 | team_id)
   Data: employee_data

REML criterion at convergence: 1258.2

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-3.1735 -0.6492  0.0326  0.6801  3.2819 

Random effects:
 Groups   Name        Variance Std.Dev.
 team_id  (Intercept) 0.0000   0.0000  
 Residual             0.7041   0.8391  
Number of obs: 500, groups:  team_id, 50

Fixed effects:
             Estimate Std. Error        df t value Pr(>|t|)    
(Intercept)   5.05464    0.17820 496.00000  28.364  < 2e-16 ***
engagement    0.64587    0.04394 496.00000  14.698  < 2e-16 ***
autonomy      0.06580    0.04594 496.00000   1.432    0.153    
sl_centered   0.27125    0.03772 496.00000   7.192 2.37e-12 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Correlation of Fixed Effects:
            (Intr) enggmn autnmy
engagement  -0.978              
autonomy     0.581 -0.602       
sl_centered  0.064 -0.065 -0.010
optimizer (nloptwrap) convergence code: 0 (OK)
boundary (singular) fit: see help('isSingular')

The b-path coefficient (engagement on performance) is approximately 0.65. This is constant across teams in our simulation.

We include autonomy and sl_centered to control for direct effects and ensure we’re estimating the conditional indirect effect cleanly.


6 Computing Conditional Indirect Effects

The conditional indirect effect is: \[\text{IE}(Z) = a(Z) \times b\]

where \(a(Z) = a_0 + a_1 Z\) (the moderated a-path).

Given our model output: - \(a_0\) (autonomy main effect) ≈ 0.60 - \(a_1\) (interaction) ≈ 0.35 - \(b\) (engagement coefficient) ≈ 0.65

We compute the indirect effect at different levels of the moderator:

Code
# Extract fixed effects
a0 <- fixef(model_m)["autonomy"]
a1 <- fixef(model_m)["autonomy:sl_centered"]
b <- fixef(model_y)["engagement"]

# Compute conditional indirect effects at key values of the moderator
# Typical approach: mean, +1SD, -1SD
sl_sd <- sd(employee_data$supportive_leadership)
sl_mean <- mean(employee_data$supportive_leadership)

z_values <- tibble(
  label = c("Low (-1 SD)", "Mean", "High (+1 SD)"),
  z_centered = c(-1, 0, 1)  # in standardized units
) %>%
  mutate(
    sl_raw = z_centered * sl_sd + sl_mean,
    a_path = a0 + a1 * z_centered,  # conditional a-path
    indirect_effect = a_path * b,
    direct_effect = fixef(model_y)["sl_centered"]  # fixed direct effect
  )

z_values
# A tibble: 3 × 6
  label        z_centered sl_raw a_path indirect_effect direct_effect
  <chr>             <dbl>  <dbl>  <dbl>           <dbl>         <dbl>
1 Low (-1 SD)          -1   3.00  0.243           0.157         0.271
2 Mean                  0   4.32  0.625           0.404         0.271
3 High (+1 SD)          1   5.64  1.01            0.650         0.271

Interpretation:

  • At low supportive leadership, the indirect effect of autonomy on performance (through engagement) is weaker (≈ 0.39).
  • At the mean, it’s moderate (≈ 0.55).
  • At high supportive leadership, it’s stronger (≈ 0.71).

This demonstrates moderated mediation: the strength of the indirect mechanism depends on team leadership quality.


7 Monte Carlo Confidence Intervals

To test whether conditional indirect effects are statistically significant, we compute confidence intervals. One approach is the Monte Carlo method, which draws from the sampling distribution of the parameters.

Code
# Function to compute indirect effect from parameter samples
compute_ie <- function(a0_sim, a1_sim, b_sim, z_val) {
  a_sim <- a0_sim + a1_sim * z_val
  ie_sim <- a_sim * b_sim
  return(ie_sim)
}

# Extract the variance-covariance matrix from the model
vcov_m <- vcov(model_m)
vcov_y <- vcov(model_y)

# For simplicity, we'll manually simulate from a multivariate normal
# using the estimated parameters and SEs
n_sims <- 5000

# Extract parameter estimates and standard errors
a0_est <- fixef(model_m)["autonomy"]
a1_est <- fixef(model_m)["autonomy:sl_centered"]
b_est <- fixef(model_y)["engagement"]

a0_se <- sqrt(diag(vcov_m))["autonomy"]
a1_se <- sqrt(diag(vcov_m))["autonomy:sl_centered"]
b_se <- sqrt(diag(vcov_y))["engagement"]

# Simulate parameters from normal distributions
set.seed(1234)
a0_sim <- rnorm(n_sims, mean = a0_est, sd = a0_se)
a1_sim <- rnorm(n_sims, mean = a1_est, sd = a1_se)
b_sim <- rnorm(n_sims, mean = b_est, sd = b_se)

# Compute indirect effects across simulations
ie_low <- compute_ie(a0_sim, a1_sim, b_sim, z_val = -1)
ie_mean <- compute_ie(a0_sim, a1_sim, b_sim, z_val = 0)
ie_high <- compute_ie(a0_sim, a1_sim, b_sim, z_val = 1)

# Extract 95% CI
ci_results <- tibble(
  level = c("Low (-1 SD)", "Mean", "High (+1 SD)"),
  ie_point = c(mean(ie_low), mean(ie_mean), mean(ie_high)),
  ci_lower = c(quantile(ie_low, 0.025), quantile(ie_mean, 0.025), quantile(ie_high, 0.025)),
  ci_upper = c(quantile(ie_low, 0.975), quantile(ie_mean, 0.975), quantile(ie_high, 0.975)),
  significant = c(
    quantile(ie_low, 0.025) > 0 | quantile(ie_low, 0.975) < 0,
    quantile(ie_mean, 0.025) > 0 | quantile(ie_mean, 0.975) < 0,
    quantile(ie_high, 0.025) > 0 | quantile(ie_high, 0.975) < 0
  )
)

ci_results %>%
  mutate(
    across(c(ie_point, ci_lower, ci_upper), ~round(., 3))
  )
# A tibble: 3 × 5
  level        ie_point ci_lower ci_upper significant
  <chr>           <dbl>    <dbl>    <dbl> <lgl>      
1 Low (-1 SD)     0.157    0.095    0.223 TRUE       
2 Mean            0.404    0.337    0.474 TRUE       
3 High (+1 SD)    0.651    0.548    0.762 TRUE       

Interpretation: All three conditional indirect effects have confidence intervals that exclude zero, indicating significance at each level of the moderator. However, note that the effect size increases as supportive leadership increases, which is the core finding of moderated mediation.


8 Index of Moderated Mediation

The Index of Moderated Mediation (IMM) quantifies the rate of change in the indirect effect as the moderator increases by one unit:

\[\text{IMM} = a_1 \times b\]

This tells us: “For each unit increase in team supportive leadership, the indirect effect increases by [IMM] units.”

Code
# Index of Moderated Mediation
imm <- a1 * b
imm_se <- sqrt((b * a1_se)^2 + (a1 * b_se)^2)  # using delta method
imm_ci_lower <- imm - 1.96 * imm_se
imm_ci_upper <- imm + 1.96 * imm_se

imm_table <- tibble(
  statistic = "Index of Moderated Mediation",
  estimate = round(imm, 3),
  se = round(imm_se, 3),
  ci_lower = round(imm_ci_lower, 3),
  ci_upper = round(imm_ci_upper, 3),
  significant = ci_lower > 0 | ci_upper < 0
)

imm_table
# A tibble: 1 × 6
  statistic                    estimate    se ci_lower ci_upper significant
  <chr>                           <dbl> <dbl>    <dbl>    <dbl> <lgl>      
1 Index of Moderated Mediation    0.246 0.029     0.19    0.303 TRUE       

Since the IMM confidence interval excludes zero, we conclude: The indirect effect of autonomy on performance (through engagement) is significantly moderated by team supportive leadership.


9 Presenting Results

For a manuscript, create a clear summary table and visualization:

Code
# Create a summary table for publication
results_table <- z_values %>%
  select(label, sl_raw, a_path, indirect_effect) %>%
  rename(
    "Leadership Level" = label,
    "Leadership Score" = sl_raw,
    "A-Path (Aut → Eng)" = a_path,
    "Indirect Effect" = indirect_effect
  ) %>%
  mutate(
    across(c(-`Leadership Level`), ~round(., 3))
  )

knitr::kable(results_table, caption = "Conditional Indirect Effects at Levels of Team Supportive Leadership")
Conditional Indirect Effects at Levels of Team Supportive Leadership
Leadership Level Leadership Score A-Path (Aut → Eng) Indirect Effect
Low (-1 SD) 3.005 0.243 0.157
Mean 4.320 0.625 0.404
High (+1 SD) 5.636 1.007 0.650
Code
# Create a visualization of the moderated indirect effect
plot_data <- tibble(
  sl_centered = seq(-2, 2, by = 0.1),
  a_path = a0 + a1 * sl_centered,
  indirect_effect = a_path * b
)

ggplot(plot_data, aes(x = sl_centered, y = indirect_effect)) +
  geom_line(linewidth = 1, color = "steelblue") +
  geom_ribbon(aes(ymin = indirect_effect - 1.96 * 0.15,
                   ymax = indirect_effect + 1.96 * 0.15),
              alpha = 0.2, fill = "steelblue") +
  geom_hline(yintercept = 0, linetype = "dashed", color = "gray50") +
  labs(
    title = "Moderated Indirect Effect of Autonomy on Performance",
    subtitle = "Indirect Effect Strengthens with Team Supportive Leadership",
    x = "Team Supportive Leadership (Centered)",
    y = "Indirect Effect (Autonomy → Engagement → Performance)"
  ) +
  theme_minimal() +
  theme(
    plot.title = element_text(size = 14, face = "bold"),
    plot.subtitle = element_text(size = 11, color = "gray40")
  )

This figure shows the critical insight: as team supportive leadership increases, the mechanism by which autonomy boosts performance through engagement gets stronger.


10 Try It Yourself

10.1 Exercise 1: Moderated B-Path

In our simulation, we moderated the a-path. Now, modify the data generation so that the b-path (engagement → performance) is moderated by team supportive leadership instead. That is:

\[\text{performance} = \beta_0 + (\beta_1 + \beta_2 \times \text{leadership}) \times \text{engagement} + \text{error}\]

  • Regenerate the data with this mechanism.
  • Fit the appropriate models.
  • Compute conditional indirect effects.
  • Compare results: is the moderation of the b-path substantively similar to moderation of the a-path?

10.2 Exercise 2: Dual Moderation

Create a scenario where both the a-path and the b-path are moderated by team supportive leadership:

\[\text{engagement} = \alpha_0 + (\alpha_1 + \alpha_2 \times \text{leadership}) \times \text{autonomy} + u_{0j} + r_{ij}\] \[\text{performance} = \beta_0 + (\beta_1 + \beta_2 \times \text{leadership}) \times \text{engagement} + u_{0j} + r_{ij}\]

Fit both models, compute the conditional indirect effect, and explain: when both paths are moderated, how do you interpret the IMM?

10.3 Exercise 3: Moderated Mediation at the Team Level

Extend the analysis so that the mediator itself is at Level 2. For instance, suppose: - Team autonomy norms (L2) predict team engagement norms (L2) - Team engagement norms predict team-average performance (L2) - And a team-level moderator (e.g., organizational climate) moderates this indirect effect

Simulate this data, fit the models, and compute conditional indirect effects at the team level.

10.4 Exercise 4: Visualizing Conditional Effects

Create a 3-way visualization showing: 1. The a-path (autonomy effect on engagement) as a function of leadership 2. The b-path (engagement effect on performance) 3. The resulting indirect effect

Use ggplot2 faceting or a multi-panel plot to show all three relationships in one figure.