- Learn
- Mathematics
- Statistics
- Intermediate Statistics – Regression and ANOVA
- Moderation and Mediation
Categorical Predictors, Moderation and Mediation
IntermediateLesson 3 of 10 in Intermediate Statistics – Regression and ANOVA Course
What you will learn
- Turn group membership into dummy or effect codes, read each coefficient as a group mean or a difference between means, and test whether the groups differ, with or without a covariate.
- Dummy-code a categorical predictorCreate k − 1 indicator variables around a reference group and read the intercept and slopes as a group mean and differences from it.
- Use effect coding and other coding schemesCode groups as deviations from the average of the group means, and see why every full coding scheme gives the same fit while its coefficients answer different questions.
- Test group differences with regressionTest the whole set of group codes with an F test, compare particular groups, adjust a group difference for a covariate and report the result.
- Dummy-code a categorical predictor
- Add a product term to test whether the effect of one predictor depends on another, interpret every coefficient correctly, use centering to make the coefficients meaningful, and test whether groups have different slopes.
- Build and interpret an interaction modelWrite a regression model with a product term, test it, and read the conditional meaning of each coefficient.
- Center predictors to make coefficients meaningfulMean-center continuous predictors before forming the product, and know what centering changes and what it leaves untouched.
- Test moderation by a categorical variableCombine dummy codes with a continuous predictor to test whether groups have different slopes, including moderators with more than two groups.
- Build and interpret an interaction model
- Follow an interaction with conditional effects at chosen moderator values, find the region where the effect is significant, draw an interaction plot and write a complete report.
- Calculate and test simple slopesEstimate the effect of the focal predictor at chosen values of the moderator, with standard errors, t tests and confidence intervals.
- Map regions of significance, plot and report an interactionUse the Johnson–Neyman technique, draw and read an interaction plot within the data, and write up a moderation analysis.
- Calculate and test simple slopes
- Split a total effect into a direct effect and an indirect effect through one mediator, test the indirect effect with a bootstrap confidence interval, and judge what the analysis can and cannot show.
- Specify a mediation model and its pathsWrite the two regressions of a simple mediation model and read the a, b, direct, indirect and total effects in the units of the variables.
- Test the indirect effectCompare the causal steps approach, the Sobel test and the percentile bootstrap, and draw a conclusion from a confidence interval for ab.
- Interpret and report a mediation analysisDescribe the size of an indirect effect, recognize inconsistent mediation, check the causal assumptions and write up the results.
- Specify a mediation model and its paths
Moderation and Mediation study guide
1Code categorical predictors and compare groups with regression
Group membership can explain differences in an outcome, but group labels need a suitable numerical representation. Start by building indicators and reading predictions for each group. Then change the coding to answer different comparison questions without changing the fitted model. Joint tests and individual comparisons let you separate evidence about the whole categorical predictor from evidence about one particular difference.
1.1 Dummy-code a categorical predictor
A group label tells you which category a case belongs to. It does not measure how much of something the case has. Giving control, video and coached learners the labels 1, 2 and 3 would impose equal steps along one line. The model would treat the move from control to video as the same change as the move from video to coached.
Build indicators around a reference
For three groups, create two dummy variables. Each is 1 for its named group and 0 otherwise. Choose control as the reference:
| Condition | Video dummy | Coached dummy |
|---|---|---|
| Control | 0 | 0 |
| Video | 1 | 0 |
| Coached | 0 | 1 |
The reference cases have zeros on every dummy. For a predictor with categories, use dummies with an intercept. Including all dummies creates perfect multicollinearity: every row of dummy values sums to 1, duplicating the intercept column. This is the dummy variable trap. There is then no unique set of coefficients.
Read a group mean from the equation
Suppose 40 learners have these test-score means: control 60 (10 learners), video 64 (10 learners), and coached 71 (20 learners). With group codes as the only predictors, the fitted model is
Substitute the code row for each group. Control gives 60; video gives ; coached gives . Every learner in a group receives that group’s fitted mean. The intercept is the reference mean, and each slope is a difference from that mean. The video coefficient 4 means four points above control. It is not a difference from the average of all groups, which is 65 here.
With just two groups, one dummy is enough. Its coefficient is the difference between their means. Under the equal-variance model, its coefficient test is the same independent-samples test, with residual degrees of freedom.
Choose a useful reference
A control or standard-treatment group often makes the comparisons easy to explain. A very small reference group gives imprecise comparisons because its mean enters every difference. Check the output labels: software may choose the first or last level by default.
Changing the reference changes the printed coefficients. With video as reference, the intercept becomes 64, control is , and coached is . The predicted group means, residuals, and overall stay unchanged. You have rewritten the same model.
For a two-group dummy, reversing 0 and 1 changes the sign of the difference and moves the intercept to the other group’s mean. Name the indicator after the group coded 1 and report the coding so that a reader can interpret the sign.
Key Takeaways
- Use k − 1 indicators with an intercept.
- The intercept is the reference mean in a groups-only model.
- Each dummy slope compares its group with the reference.
- Changing the reference preserves the model’s fit.
1.2 Use effect coding and other coding schemes
Coding determines the comparison a coefficient expresses. Effect coding compares each group mean with the plain average of the group means. It still represents every group, including the group whose coefficient is not printed.
Build and decode effect codes
For three groups, use two variables. Give video the codes (1, 0), coached (0, 1), and control (−1, −1). The fitted equation is
With means 60, 64 and 71, the intercept is . The video effect is and the coached effect is , giving
For control, substitute −1 into both variables: . Its effect is −5, the negative sum of the printed effects: . The group effects sum to zero.
Distinguish two averages
The effect-coded intercept gives every group equal weight. It is the unweighted grand mean, even if group sizes differ. Here control and video each contain 10 learners, while coached contains 20. The mean across all 40 cases is
That weighted mean is different from the intercept 65. Weighted effect coding is a separate scheme for comparisons with a mean weighted by group proportions.
| Scheme | Intercept in the groups-only model | Printed coefficients |
|---|---|---|
| Dummy | Reference group mean | Differences from the reference |
| Effect | Average of the group means | Deviations from that average |
Encode a planned comparison
Contrast codes can express a research comparison directly. Let one code be −2/3 for control and 1/3 for each trained group. Let the second code be 0 for control, −1/2 for video and 1/2 for coached. These give coefficients 7.5 for the average trained-group mean minus control, and 7 for coached minus video. The scaling matters: each code changes by exactly 1 between the sets compared, so the coefficient equals that mean difference.
A full set of independent codes gives the same fitted means, residuals, and overall as dummy coding. Choosing a coding scheme chooses which comparisons appear in the output; it does not improve fit. “Full” means that the codes retain all the distinctions among the groups.
Interactions make this choice especially visible. With a dummy moderator, the coefficient of another predictor is its slope in the reference group. With effect codes, it is the unweighted average of the group slopes. Read the codes before interpreting the lower-order coefficients. The −1 group remains fully included in the analysis; its effect is recoverable from the others.
Key Takeaways
- Effect codes compare groups with the unweighted mean of group means.
- The unprinted effect is minus the sum of the printed effects.
- Unequal group sizes separate weighted and unweighted means.
- Contrast scaling determines coefficient meaning.
- Full independent coding schemes preserve fitted values.
1.3 Test group differences with regression
A categorical predictor contributes several coefficients, but the question “do the groups differ?” concerns the set of codes together. Individual coefficient tests answer narrower questions about particular comparisons.
Test the whole categorical predictor
With group codes alone, the overall tests equal population group means. It is the same test as the one-way ANOVA because the fitted model is the same. If covariates are already present, compare a reduced model containing them with a full model that adds every group code. This asks about group differences after adjustment.
Here is the number of added predictors, counts all predictors in the full model, and is the sample size. The degrees of freedom are and . Both fits must use the same cases.
For the 40 learners, the between-group sum of squares is 890. A residual standard deviation of 8 gives a residual sum of squares . Thus and , with . The result supports some difference among the conditions; it does not identify every differing pair.
Estimate particular differences
For group against the reference, the standard error is under the common-variance model. Video minus control is 4, with . Its and . The 95% interval is about [−3.2, 11.2], spanning both zero and substantial positive differences. A nonsignificant test leaves uncertainty; it does not establish equal means.
Coached minus control is 11, with , and . To compare coached with video, make video the reference. The difference is 7, with and . Plan comparisons or adjust for multiple testing, for example with Holm or Bonferroni.
Keep all codes for the categorical predictor together. Removing a nonsignificant dummy merges its group with the reference. A joint test evaluates the predictor without making the conclusion depend on which group is the reference.
Adjust and report
In , the difference 5 compares coached and control learners with the same pretest score. This model gives both groups one common pretest slope. A group-by-pretest interaction tests that parallel-slopes assumption.
Inspect residuals by group for similar spread, along with independence and approximate residual normality for conventional inference. Unequal spreads combined with unequal group sizes can distort conventional standard errors; heteroscedasticity-consistent standard errors address unequal variance. Report coding, the joint test, relevant differences and intervals, and the covariates. For example: “Condition explained 27% of score variance, F(2, 37) = 6.95, p = .003; coached learners scored 11.00 points above control, 95% CI [4.72, 17.28].”
Key Takeaways
- Test the categorical predictor with a joint F test.
- A covariate-adjusted difference compares cases at the same covariate value.
- Keep all codes together.
- Plan comparisons or adjust for multiple testing.
- Report confidence intervals as well as p values.
- Inspect residual spread within groups.
2Model moderation with interaction terms
An association can depend on the setting or the people being studied. An interaction model captures that dependence by letting one predictor’s slope change with another predictor. Reading its coefficients requires careful attention to zero points. Work from the model equation to conditional slopes, then use centering and group codes to express the same fitted relationships in ways that answer useful research questions.
2.1 Build and interpret an interaction model
Moderation means that the association between a predictor and an outcome changes with a third variable. Social support might buffer the association between stress and wellbeing: the stress slope could be more negative among people with less support. A moderator answers “when?” or “for whom?”; a mediator concerns the pathway through which an effect occurs.
Let the slope change
The interaction model is
Compute the product for each case. Collecting the terms involving gives
So the slope of at a given moderator value is . Each one-unit increase in changes that slope by . The same equation gives the slope of as . Theory determines which predictor you call the moderator; the mathematics treats their interaction symmetrically.
Interpret the signs in context
For 200 adults, suppose stress ranges from 0 to 40, support from 0 to 20, and wellbeing from 0 to 100. The fitted model is
The stress slope is . At support 6 it is −1.4; at support 10 it is −1.0; at support 14 it is −0.6 wellbeing points per stress point. The positive interaction makes the stress slope less negative as support rises. A positive interaction need not mean that every slope is positive.
The support coefficient −0.5 describes its slope when stress is zero. At stress 20, the support slope is . Reading −0.5 as the overall association of support with wellbeing would miss this dependence. Likewise, −2 is the stress slope specifically at zero support. A zero point outside the data makes the corresponding coefficient an extrapolation.
Test the interaction
The moderation hypothesis is . With , the test is , . Adding the product increases from .25 to .28. The one-predictor change test gives . The interaction effect size is .
Keep both lower-order terms and in the model, even if their coefficient tests are nonsignificant. Omitting one imposes an extra restriction on the fitted lines and changes what the product term tests.
Correlation between the predictors is a different question. Two predictors can be uncorrelated yet interact, or correlated without interacting. Interaction tests often have low power, and measurement error in either predictor can weaken their product. A nonsignificant interaction leaves uncertainty about slope differences; inspect its estimate and confidence interval.
Key Takeaways
- The product coefficient tests changing slopes.
- Lower-order coefficients describe slopes at the other predictor’s zero.
- Keep both lower-order terms in the model.
- The sign of the interaction describes how a slope changes.
2.2 Center predictors to make coefficients meaningful
The zero point determines where a lower-order coefficient describes a slope. Centering moves that zero to a useful value while preserving the fitted interaction model.
Center before multiplying
Mean centering is and . The centered variables have mean zero, with unchanged standard deviations and distribution shapes. Form the product after these subtractions. Subtracting the mean of the raw product produces a different variable.
If stress has mean 20 and support mean 10, substitute and into the raw model:
Expanding the product adds . Collect constants and matching terms to obtain
The intercept 60 is predicted wellbeing at both predictor means. The stress coefficient −1 describes the stress slope at mean support. The support coefficient 1.5 describes the support slope at mean stress. These coefficients now answer different questions from the raw coefficients, so their standard errors and tests also change.
Identify what stays fixed
| Changes with centering | Stays the same |
|---|---|
| Intercept and lower-order coefficients | Interaction coefficient and its standard error |
| Questions tested by lower-order tests | Interaction t and p |
| Predictor zero points | Fitted values, residuals, R² and overall F |
Check a prediction to see why: raw stress 26 and support 14 are centered values 6 and 4. Both equations predict 62.4. Centering is a reparameterization, a different expression of the same fitted surface.
Centering often reduces correlations between a product and its components, but the joint distribution matters. Those correlations can remain high or even increase. The correlation between and themselves stays the same. Centering is useful for interpretation; it is not a way to make the interaction significant.
Choose the zero that answers your question
The mean is one choice. An age of 18, a scale midpoint or another meaningful value may serve the research question better. Subtract that value and rebuild the product. The other predictor’s lower-order coefficient is then its slope at the chosen value.
For a dummy-by-continuous interaction, leave the dummy coded 0/1 to retain a reference group. Centering only the continuous variable makes the dummy coefficient the group difference at its new zero.
Standardization needs the same attention to construction. The standardized score of a product is not the product of standardized scores. To express slope change per standard deviation of a moderator, standardize the component predictors first, form their product, and report the unstandardized coefficients of that fitted model. Standardize the outcome too if you want outcome standard-deviation units.
Key Takeaways
- Center components before forming their product.
- Choose zero points for useful coefficient interpretations.
- Centering leaves the interaction test and predictions unchanged.
- Centering does not always reduce product correlations.
- Standardize components before multiplying when interpreting change per SD.
2.3 Test moderation by a categorical variable
A categorical moderator gives a different regression line for each group. A product between a group code and a continuous predictor lets the slope vary across those lines.
Derive both group equations
Let for trained learners and 0 for untrained learners. The model is
where is weekly practice hours, observed from 0 to 12. Set to get the untrained line, . Set to get the trained line, . The product coefficient 1.5 is the trained slope minus the untrained slope. The dummy coefficient 5 is the group difference at zero hours.
Subtract the lines to get the group difference at any practice value:
At 6 hours the difference is 14 points, and at 10 hours it is 20. The model has no single group difference applying at every practice value.
Move the comparison to mean practice
Mean practice is 6 hours. With , the same model becomes
The dummy coefficient now gives the 14-point difference at six hours. Both group slopes and the slope difference remain unchanged. If the trained group becomes the reference, the continuous-predictor coefficient becomes 3.5, with its own standard error and test.
An effect-coded moderator gives another reading. With trained coded +1 and untrained −1, the coefficient of practice is the average slope, . The product coefficient is 0.75, half the slope difference. The two fitted lines are unchanged.
Test a difference directly
A significant slope in one group and a nonsignificant slope in the other do not establish different slopes. Each test compares one slope with zero. The interaction test compares the slopes with each other. A combined model supplies that direct test and pools residual variance, assuming similar residual spread across groups.
For a moderator with three groups, create two dummies and two products with . Include , both dummies and both products. Test the products as a block, because together they represent group differences in slopes. Individual product tests compare particular slopes with the reference slope.
For 120 cases, suppose the products raise from .40 to .43. The full model has five predictors, so residual degrees of freedom are . The change test is
with . It does not cross the .05 threshold. Retain the estimate and uncertainty instead of declaring all slopes equal. Group-by-covariate products also test the parallel-slopes assumption of a covariate-adjusted comparison. When slopes differ, report group differences at named covariate values.
Key Takeaways
- A dummy interaction coefficient is a difference in slopes.
- The group difference varies with the continuous predictor.
- Test slope differences directly.
- With k groups, jointly test k − 1 product terms.
- Effect coding changes the coefficient reading, not the fitted lines.
3Probe, plot and report interactions
A significant interaction tells you that slopes differ, but it leaves open how large they are at meaningful moderator values. Probing supplies those estimates and their uncertainty. A region of significance extends the calculation across a continuous moderator, while a plot shows the fitted pattern in the variables’ original units. Combine these views in a report that distinguishes a changing association from evidence about its cause.
3.1 Calculate and test simple slopes
A simple slope is the estimated change in the outcome for a one-unit increase in the focal predictor at a chosen moderator value. Its estimate and its uncertainty both depend on where you probe the interaction.
Choose meaningful values
Use values that answer the research question and lie within the observed data. The mean and one standard deviation below and above it are common choices. For a skewed moderator, percentiles such as the 16th, 50th and 84th stay inside its observed range. A categorical moderator is probed group by group. Splitting a continuous moderator at its median discards information and changes the model.
For the centered stress–support model,
the stress slope is . Support has mean 10 and standard deviation 4. Low support 6 corresponds to , giving a slope of −1.4. Mean support gives −1.0, and support 14 corresponds to , giving −0.6. Use the moderator’s centered scale in this equation: inserting 14 would evaluate a different support value.
Carry uncertainty through the combination
A slope combines two estimated coefficients. Its standard error must include their covariance:
Suppose , and . At high support, , so the terms inside the square root are .04, .0196 and .0112. Their sum is .0708, and . Leaving out covariance would give the wrong uncertainty even though the estimated slope stayed −0.6.
Divide the slope by its standard error: , with . Using the model’s residual degrees of freedom gives a 95% interval of approximately [−1.12, −0.08]. At low support the covariance contribution changes sign, giving and . At mean support, the standard error is .20 and the test statistic is −5.00.
Use a refit as a shortcut
Re-center support at 14, rebuild its product with stress, and fit the model again. The coefficient of stress now directly gives the stress slope at support 14, and the output supplies its standard error. This refit gives the same answer as the covariance formula.
A simple-slope test asks whether one slope differs from zero. The interaction test asks whether slopes differ across moderator values. Here the three probed slopes are all negative and significant, yet moderation is supported because their sizes differ. Do not use a difference in significance labels as a substitute for the interaction test.
Key Takeaways
- Probe values on the same scale used to fit the model.
- Simple-slope standard errors include coefficient covariance.
- Re-centering the moderator gives a direct simple-slope estimate.
- A slope test and an interaction test answer different questions.
3.2 Map regions of significance, plot and report an interaction
Picking a few moderator values makes an interaction understandable, but it can miss where statistical significance changes. The Johnson–Neyman technique searches the continuous moderator for that boundary. A plot then puts the changing slopes into the outcome’s units.
Find and interpret a boundary
At the boundary, the absolute simple-slope test statistic equals the critical value. Squaring both sides gives
This is a quadratic equation with zero, one or two real solutions. Check which intervals between solutions meet the significance criterion; do not assume significance must always lie above a root.
For the centered stress model, with 196 residual degrees of freedom. Using the coefficient variances and covariance gives roots near and . Add the support mean 10 to return to raw units: support is about 14.5 or 45.8. The second root is beyond the support scale’s 0–20 range and has no practical interpretation.
Within the example’s range, stress has a significant negative slope below support about 14.5. From about 14.5 to 20, its slope is not significantly different from zero. The boundary marks a change in evidence strength at the chosen significance level. It is not where a real-world process suddenly starts or stops. Sample size and precision affect its location. For categorical moderators, probe groups directly.
Draw predictions in original units
Plot predicted wellbeing against stress at support 6, 10 and 14. Across stress 14 to 26, predictions are:
| Support | Wellbeing at stress 14 | Wellbeing at stress 26 |
|---|---|---|
| 6 | 62.4 | 45.6 |
| 10 | 66.0 | 54.0 |
| 14 | 69.6 | 62.4 |
The low-support line falls most steeply. Label axes with raw stress, support and wellbeing units even if calculations use centered values. Nonparallel lines show the fitted interaction pattern; an inferential test assesses its uncertainty. Crossing lines indicate a reversal in which group has the higher prediction.
The support lines would meet at stress 5, where . That value is far below mean stress, with few cases in this example. Check data coverage in both variables, including whether plotted combinations are well represented. Extending a line far beyond observed combinations can create an unsupported story.
Report the evidence and design
State coding, centering, all coefficient estimates and their uncertainty, the interaction’s change in , named simple slopes, any meaningful boundary, and a plot. For the example, report the interaction as , , , , 95% CI [0.03, 0.17], with . With observational data, describe the association as weaker at higher support. Causal wording needs a design that supports it.
Key Takeaways
- Johnson–Neyman boundaries locate changes in statistical significance.
- Keep only boundaries supported by the data range.
- Plot predictions with axes in original units.
- A significance boundary is not a biological or behavioral switch.
- Report the interaction, conditional effects and design together.
4Estimate and interpret simple mediation
A proposed mechanism connects a predictor to an outcome through an intermediate variable. Simple mediation puts numbers on that proposal with two linked regressions. Follow the units through the paths, estimate the indirect effect, and use resampling to describe its uncertainty. Then consider the design and causal assumptions before deciding how strongly the evidence supports the proposed sequence of events.
4.1 Specify a mediation model and its paths
Mediation represents a proposed sequence: a predictor changes an intermediate variable, and that variable changes the outcome. The mediator carries an indirect pathway from through to . Estimating that pathway begins with two regressions.
Label the paths before calculating
Fit the mediator model and the outcome model . A third regression, , estimates the total effect.
| Path or effect | Meaning |
|---|---|
| a | Change in M per unit of X |
| b | Change in Y per unit of M, holding X constant |
| c′ | Change in Y per unit of X, holding M constant |
| ab | Indirect effect through M |
| c | Total effect of X on Y |
Path comes from the outcome model containing both and . Regressing on alone mixes their relationship with the association involving . Keep the label “path b” distinct from the general use of for any regression coefficient.
Follow the units through the product
Suppose 50 students are divided equally between workshop attendance and no attendance. Code attendance as 1 and nonattendance as 0. The mediator is weekly study hours and the outcome is an exam score from 0 to 100. The estimates are hours, path score points per hour, and points.
Attendance is associated with three additional study hours, and the outcome model associates each additional hour with 1.5 points at the same attendance status. Multiply along the pathway: points. Add the direct effect to obtain points.
The hour units cancel in the product. With binary attendance, 4.5 is the indirect score difference for the change from nonattendance to attendance. With a continuous predictor, the indirect effect is measured per one-unit increase in that predictor.
Understand the decomposition
For simple linear models fitted to the same cases with continuous mediator and outcome, holds exactly. Different case sets, such as those caused by missing data, can break the identity. Nonlinear outcome models also change the relationship.
The direct effect is the association remaining after adjustment for the measured mediator. Calling it a “pure” effect would overstate the result. Under a valid causal model it includes pathways other than the measured mediator, but its value can also reflect confounding, mediator measurement error or a misspecified model.
The arrows express time order: precedes , which precedes . Random assignment of followed by measurement of and then provides stronger evidence than measuring everything at once. Randomizing still leaves the mediator unrandomized, so common causes of and can distort path . The numerical decomposition alone cannot establish the causal sequence.
Key Takeaways
- Estimate path b while controlling for X.
- The indirect effect is the product ab.
- For the simple linear same-case model, c = c′ + ab.
- The units of ab are outcome units per predictor unit.
- A causal pathway needs evidence about time order and confounding.
4.2 Test the indirect effect
The indirect effect is a product of two estimated paths. Test that product directly and give its confidence interval. Separate tests of total and direct effects cannot describe its uncertainty.
Move beyond causal steps
The causal steps approach checks that predicts , predicts , and predicts controlling for , then looks for a reduction from to . Historically, a nonsignificant direct effect was called “full” mediation and a reduced but significant direct effect “partial” mediation.
This sequence requires several tests to succeed, lowering power, and requires a significant total effect. Direct and indirect effects can cancel, so a small total effect can hide a substantial indirect pathway. The steps also supply neither an estimate nor an interval for . Significant paths and together are a valid joint significance test, but an interval for the product adds information about magnitude and precision.
Calculate the Sobel approximation
The Sobel standard error is
For , , and , the variance contributions are and . Their sum is 2.88, giving and , with . The corresponding normal interval is about [1.17, 7.83].
The product’s sampling distribution is often skewed in finite samples. The symmetric normal approximation can therefore give inaccurate inference and has relatively low power. A bootstrap estimates the shape of the product distribution by resampling the cases.
Build a percentile bootstrap interval
- Draw a sample of cases with replacement from the original sample, retaining each case’s variables together.
- Fit both mediation regressions to that resample and store the product of the two path estimates.
- Repeat many times, commonly 5,000 or more.
- Use the 2.5th and 97.5th percentiles of the stored products for a 95% percentile interval.
Suppose the workshop estimate has an illustrative bootstrap interval [1.6, 8.3]. Zero lies outside it, supporting a nonzero indirect effect at the .05 level. Its unequal distances below and above 4.5 reflect the skewed distribution. An interval containing zero leaves a zero indirect effect compatible with the data; it does not establish absence.
Report the percentile method and resample count, and fix and report the seed for reproducibility. More resamples reduce random run-to-run variation in the endpoints. Bias-corrected intervals are an alternative, but can inflate false-positive rates in some small-sample settings. Monte Carlo intervals simulate path estimates from their estimates and standard errors. None of these interval methods resolves confounding or an incorrect causal sequence.
Key Takeaways
- Test the indirect product directly.
- The Sobel test uses a normal approximation.
- Resample whole cases and refit both regressions for each bootstrap sample.
- A percentile interval can be asymmetric.
- Report the method, resample count and seed.
- An interval containing zero indicates uncertainty.
4.3 Interpret and report a mediation analysis
A mediation report should describe the size and uncertainty of the pathways and the design that supports their interpretation. Significance labels alone lose information about both magnitude and causal credibility.
Recognize cancellation
If , and , then and . This is inconsistent mediation: the indirect and direct effects point in opposite directions. Requiring a significant total effect before examining the indirect pathway can miss this pattern.
Avoid basing the interpretation on “full” versus “partial” mediation. The significance of depends on sample size and precision. Report direct and indirect estimates with confidence intervals so that readers can judge their possible sizes.
Put the indirect effect on a useful scale
For a binary predictor, the partially standardized effect is . The workshop example has points and , giving outcome standard deviations for the attendance contrast. For a continuous predictor, the completely standardized effect is , expressing the pathway for a one-standard-deviation increase in .
The proportion mediated is . In the workshop example it is . This ratio becomes unstable when the total effect is close to zero; opposing effects can make it negative or greater than 1. Use it only with same-signed effects and a large sample.
Check the causal proposal
A causal interpretation needs the right time order and no unmeasured confounding of the predictor–mediator, predictor–outcome and mediator–outcome relations. Randomizing the predictor addresses its confounding, but does not randomize the mediator. Reliable measurement of the mediator also matters: measurement error tends to shrink path and the indirect effect, leaving some of the pathway in the estimated direct effect.
Simple mediation also assumes the mediator’s outcome slope does not depend on . Add to the outcome model to test that assumption, and check the regression assumptions in both equations. A bootstrap improves the interval calculation; it cannot repair an incorrect model.
With cross-sectional measurements, the temporal order of and remains unresolved. Describe a significant indirect estimate as consistent with the proposed mechanism. Successive measurements or a further experiment manipulating the mediator strengthen the design. A mediator follows in the causal proposal; a confounder is a common cause of and ; a moderator changes their association. Theory and design distinguish these roles.
Write a complete result
For the workshop analysis, report path , and path , , then the indirect effect of 4.50 points with its 95% percentile interval [1.6, 8.3] from 5,000 resamples. Report the direct estimate , , , , and the total estimate , , , . Include intervals for direct and total effects, the coding, software, seed, measurement timing and design limitations.
Key Takeaways
- Direct and indirect effects can oppose each other.
- Choose standardization to match a binary or continuous predictor.
- A near-zero total effect makes the proportion mediated unstable.
- Randomizing X leaves mediator–outcome confounding unresolved.
- Check both regression models and the no-interaction assumption.
- Report effect estimates and intervals instead of relying on full/partial labels.
Moderation and Mediation examples
1Turn group membership into fitted comparisons
13 steps
- 1IntroductionCompare three training conditions
A researcher records test scores after control, video or coached training. The group labels identify different conditions; they do not measure an amount. Regression handles such a categorical predictor with coded indicators, such as dummy codes that compare each group with a reference group. You will encode those labels, recover the fitted means, and distinguish an overall group test from an individual comparison.
- 2ExplanationChoose control as the reference
Use two indicators: video is 1 only for video learners, and coached is 1 only for coached learners. Control learners have zero on both. With an intercept, two codes preserve all three groups. A third indicator would sum with the others to the constant column and create perfect multicollinearity.
The case data stay in their original rows; only the two code columns are added. A control row therefore contributes to estimating the model even though both of its indicator entries are zero.
- 3ExampleRecover the reference mean
The fitted model is . For control, substitute zero for each indicator. Both group terms disappear, leaving a predicted score of 60. This is why the intercept is the reference mean in a model containing only group indicators.
The equation selects a group adjustment through the code row. It never adds both adjustments for the same learner, because a case belongs to only one of these conditions.
- 4ExampleRead the two group differences
For video, the code row is (1, 0), so the prediction is . For coached, it is (0, 1), so the prediction is . The slopes 4 and 11 describe differences from control. They are not the group means themselves or differences from an overall average.
- 5ChallengeMove the reference
If coached becomes the reference, what are the new intercept and the video coefficient?
---reveal---
The intercept is 71 and the video coefficient is 64 − 71 = −7. The video prediction is still 64. Changing the reference rewrites the comparisons while leaving the fitted group means and model fit unchanged.
- 6ExampleCompare with the average group
The plain average of the means is . Effect coding gives video (1, 0), coached (0, 1) and control (−1, −1). The equation becomes . Its coefficients compare video and coached with the average group mean.
For video, substitute (1, 0) to obtain 64; for coached, substitute (0, 1) to obtain 71. The new intercept changes what the coefficients compare, while preserving all three fitted means.
- 7Key InsightKeep the unprinted group in view
Control has no printed coefficient, but it remains in the fitted model. Its effect is the negative sum of the others: . Substituting its two −1 codes gives . “Unprinted” therefore describes the parameter display, not the cases included in the analysis.
- 8ChallengeSeparate the two averages
Control and video each have 10 learners; coached has 20. Is 65 also the mean across all cases?
---reveal---
No. The case-weighted mean is (10 × 60 + 10 × 64 + 20 × 71)/40 = 66.5. Ordinary effect coding gives each group equal weight, so its intercept remains 65 despite the larger coached group.
- 9ExplanationAsk whether any groups differ
The two indicators form one categorical predictor. Test them together. With no covariates, the overall tests equal population group means. Here and , . This supports a difference somewhere among the conditions, without establishing every pairwise difference.
The two numerator degrees of freedom correspond to the two indicators. The 37 residual degrees of freedom come from 40 cases minus the intercept and those two predictors.
- 10ExampleRead one comparison with uncertainty
Video minus control is 4 points. With residual SD 8 and 10 cases per group, . Thus , . The interval of about [−3.2, 11.2] includes both zero and a sizable positive difference, so the result leaves uncertainty about the population difference.
The uncertainty combines variation in both estimated means. A small reference group can therefore make several comparisons imprecise, because every one of them uses that same estimated reference mean.
- 11ChallengeChoose the adjusted test
Pretest score is added before the group indicators. What test now isolates the contribution of training condition?
---reveal---
Compare the covariate-only model with the model adding both indicators using the change F test. An overall test of all predictors also includes pretest. Keep both indicators together; deleting one would merge its group with control.
- 12TipReport what the comparisons mean
State the coding and any covariates, then report the joint test and the relevant differences with confidence intervals. Plan comparisons or adjust for multiple testing. Inspect residuals by group: uneven spreads can make conventional uncertainty estimates unreliable, especially with unequal group sizes.
- 13RecapMatch codes and tests to the question
Read coefficients through their coding: dummy codes compare with a reference; effect codes compare with the average group. Use a joint test for the categorical predictor and targeted comparisons for particular differences. Before reporting an adjusted difference, check whether the common-slope model is appropriate.
2Build an interaction and read its coefficients
14 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionLet an association depend on context
- 2ExplanationMake the slope depend on support
- 3ExampleRead a less negative slope
- 4ChallengeInterpret the support coefficient
- 5ExampleTest the changing slope
- 6ExplanationMove zero to the means
- 7ExampleTranslate the fitted equation
- 8ChallengePredict what changes
- 9TipChoose meaningful scales
- 10ExampleWrite a line for each group
- 11ChallengeMove the group comparison
- 12ConnectionExtend the moderator to three groups
- 13ChallengeCombine coding and moderation
- 14RecapRead the equation before the table
3Probe an interaction and draw the fitted pattern
12 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionGo beyond one interaction coefficient
- 2ExplanationChoose values within the data
- 3ExampleCalculate the high-support slope
- 4ExampleCalculate the uncertainty
- 5ChallengeForm the conditional test
- 6TipGet the slope directly from a refit
- 7ExplanationSearch for the significance boundary
- 8ExampleReturn the boundary to raw support
- 9ChallengeInterpret what a boundary means
- 10ExampleDraw the three prediction lines
- 11ChallengeConnect the plot with the test
- 12RecapBuild a report from complementary views
4Estimate and assess an indirect pathway
15 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionPut numbers on a proposed mechanism
- 2ExplanationFit the mediator regression
- 3ExampleFit the outcome regression
- 4ExampleMultiply along the pathway
- 5ChallengeDiagnose the wrong path estimate
- 6ConnectionTest the product directly
- 7ExampleInspect the normal approximation
- 8ExplanationResample whole cases
- 9ExampleRead the percentile interval
- 10ChallengeRead an interval that includes zero
- 11Key InsightAllow pathways to oppose each other
- 12ExampleChoose an effect-size scale
- 13ChallengeSeparate interval evidence from causal evidence
- 14TipCheck before writing the claim
- 15RecapReport the pathway and its evidence
Moderation and Mediation practice questions
Set 1: Read group codes and conditional effects10 Practice Questions
Question 1 of 10
Show answerHide answer
Question 2 of 10
Show answerHide answer
Question 3 of 10
Show answerHide answer
Question 4 of 10
Show answerHide answer
Question 5 of 10
Show answerHide answer
Question 6 of 10
Show answerHide answer
Question 7 of 10
Show answerHide answer
Question 8 of 10
Show answerHide answer
Question 9 of 10
Show answerHide answer
Question 10 of 10
Show answerHide answer
Set 2: Fit and test the models10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Set 3: Diagnose interpretation errors10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Set 4: Connect models, uncertainty and design10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Stuck on your own question? Homework Help
Key Terms
A
Adjusted group difference
B
Bootstrap resample
C
Categorical predictor
Change in R²
Coefficient covariance
Completely standardized indirect effect
Conditional group difference
Confounder
Contrast coding
Cross-sectional data
Crossover interaction
D
Direct effect
Dummy variable
Dummy variable trap
E
Effect coding
Extrapolation
I
Inconsistent mediation
Incremental f²
Indirect effect
Interaction plot
Interaction term
J
Johnson–Neyman technique
Joint F test
Joint significance test
L
Lower-order term
M
Mean centering
Median split
Mediator
Moderation
Moderator
Multiple testing
P
Parallel slopes
Partially standardized indirect effect
Path a
Path b
Percentile bootstrap
Pick-a-point analysis
Product block
Product of z scores
Proportion mediated
R
Random seed
Reference category
Region of significance
Reparameterization
Robust standard error
S
Simple slope
Slope difference
Sobel test
Standardization
Sum-to-zero constraint
T
Total effect
U
Unweighted grand mean
W
Weighted mean
About this lesson
Make your own Study Materials
Turn your notes, slides and documents into Study Guides, Practice Questions, Flashcards and 6 more tools.