knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 4.5, fig.align = "center" )
A cross-level interaction occurs when a level-2 variable (e.g., school climate) moderates the relationship between a level-1 predictor (e.g., student SES) and the outcome (e.g., math achievement).
Formally, the two-level model is:
Level 1: $$math_{ij} = \beta_{0j} + \beta_{1j} \cdot SES_{ij} + e_{ij}$$
Level 2: $$\beta_{0j} = \gamma_{00} + \gamma_{01} \cdot Climate_j + u_{0j}$$ $$\beta_{1j} = \gamma_{10} + \gamma_{11} \cdot Climate_j + u_{1j}$$
Substituting gives the composite model: $$math_{ij} = \gamma_{00} + \gamma_{10} SES_{ij} + \gamma_{01} Climate_j + \gamma_{11} SES_{ij} \times Climate_j + u_{0j} + u_{1j} SES_{ij} + e_{ij}$$
The term $\gamma_{11}$ is the cross-level interaction: it captures how much the SES slope varies as a function of school climate.
library(mlmoderator) library(lme4) data(school_data)
For cross-level interactions, the recommended centering strategy is:
This separates within-school from between-school variance in SES, and makes the intercept interpretable as the school-average outcome at average climate.
dat <- mlm_center(school_data, vars = "ses", cluster = "school", type = "group") # within-school SES dat <- mlm_center(dat, vars = "climate", type = "grand") # grand-mean-centred climate # Check cat("Within-school SES mean (should be ~0):", round(mean(dat$ses_c), 4), "\n") cat("Grand-mean climate (should be ~0):", round(mean(dat$climate_c), 4), "\n")
Because we hypothesise that the SES slope varies across schools (hence the cross-level interaction), we include a random slope for SES.
mod <- lmer( math ~ ses_c * climate_c + gender + (1 + ses_c | school), data = dat, REML = TRUE ) summary(mod)
The ses_c:climate_c interaction is the cross-level interaction of interest.
probe <- mlm_probe(mod, pred = "ses_c", modx = "climate_c", modx.values = "mean-sd", conf.level = 0.95) probe
Interpretation: At schools with above-average climate (+1 SD), the positive effect of SES on math is amplified. At schools with below-average climate (−1 SD), the SES effect is weaker (and may not be significant).
The JN interval pinpoints the exact climate values where the SES effect transitions from non-significant to significant.
jn <- mlm_jn(mod, pred = "ses_c", modx = "climate_c") jn
mlm_plot( mod, pred = "ses_c", modx = "climate_c", modx.values = "mean-sd", interval = TRUE, x_label = "Student SES (group-mean centred)", y_label = "Mathematics Achievement", legend_title = "School Climate" )
mlm_summary(mod, pred = "ses_c", modx = "climate_c", modx.values = "mean-sd", jn = TRUE)
When reporting a cross-level interaction, include:
Example write-up:
There was a significant cross-level interaction between student SES and school climate, $\hat{\gamma}_{11}$ = [value], SE = [value], t([df]) = [value], p = [value]. Simple slope analysis indicated that the positive effect of SES on math achievement was significantly stronger at schools with high climate (+1 SD: $b$ = [value], 95% CI [lo, hi]) than at schools with low climate (−1 SD: $b$ = [value], 95% CI [lo, hi]). Johnson–Neyman analysis revealed that the SES slope was statistically significant for climate values above [JN boundary].
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.