
Inflammatory rheumatic diseases, such as ankylosing spondylitis (AS), are a major cause of work disability. Despite clinical progress in inflammation control and associated improvements in outcomes, work disability remains an issue for AS patients, and other underlying causes, such as fatigue, have been postulated. We have used data from an observational study, which followed a large cohort of AS patients in routine clinical practice for 12 months, to investigate the longitudinal relationship (data at baseline, 6 and 12 months) between fatigue and work disability in the presence of other recognised confounders. Initial results suggested possible inter-relationships between the effects of fatigue and anxiety/depression, leading to a post-hoc hypothesis that:
“The effect of fatigue on work productivity loss (WPL) is mediated by anxiety/depression (A/D).”
Observational analysis may identify an association between
and
, but that association may not explain how the relationship arises. Mediation analysis explores whether an intermediate variable is consistent with a possible mechanism. Rather than asking only whether
predicts
, mediation analysis examines whether, and to what extent, the relationship between
and
operates through a mediator variable
. This article explains direct effect, indirect effect and total effect in mediation analysis, using the AS study as a worked observational-study example.
'Direct vs indirect pathways' refers here to statistical pathways in mediation analysis, not basal ganglia movement-control circuits.
In this article, ‘direct vs indirect pathways’ refers to statistical pathways in mediation analysis. It is separate from the more common basal ganglia use of the phrase, where direct and indirect pathways describe movement-control circuits in neuroanatomy.
Variables involved:
: independent variable (e.g. exposure or treatment)
: dependent variable (e.g. outcome)
: mediator variable
To consider a simple illustrative scenario, say we investigate a relationship between exercise (
) and energy levels (
). Mediation analysis can help determine if exercise (
) is influencing energy levels (
) through a proposed mediator, say by improving sleep (
) which improves energy levels (
).
Mediation analysis can help investigate whether an observed association may operate through an intermediate variable. In observational studies, this can be useful when researchers want to explore a possible mechanism, but the findings still need cautious interpretation because treatment or exposure is not necessarily randomised.
In the ankylosing spondylitis study, fatigue was the independent variable or exposure (X), anxiety/depression was the proposed mediator (M), and work productivity loss was the outcome (Y). The mediation analysis, therefore, examined whether the relationship between fatigue and work productivity loss operated through anxiety/depression.

Within mediation analysis we have two pathways or effects. The direct and the indirect pathway/effect.
The direct effect shows the effect of
on
, having accounted for
. This is denoted by c’.
Here,
denotes the
-to-
path and
denotes the
-to-
path conditional on
.
The indirect effect or pathway shows how the effect of
on
flows through
. In a simple linear mediation this is estimated by
.
Our total effect is then those two pathways combined. In a simple linear mediation this is denoted by
=
’ +
. This decomposition may not hold in the same, simple form for nonlinear models, exposure–mediator interactions, or effects expressed on non-additive scales.

The pathways can be represented using three regression models. First, the total-effect model, second, the mediator model and third, the direct-effect outcome.
In these equations,
represents other measured covariates included in the models, such as potential confounders. The corresponding coefficient vectors describe the estimated association of each covariate with the mediator or outcome. Including these covariates aims to reduce confounding, although adjustment cannot remove bias from unmeasured or incorrectly modelled confounders. Confounding may affect any of the relevant relationships –
-to-
,
-to-
, or
-to-
- especially if there is no randomisation. Even when
is randomised,
is generally not, so mediator–outcome confounding may remain.
From the total-effect model, a one-unit increase in
is associated with an expected change of
units in
. This is the total effect.
From the direct-effect outcome model, a one-unit increase in
is associated with an expected change of
units in
, after accounting for
. This is the direct effect.
From the mediator model, a one-unit increase in
is associated with an expected change of
units in
.
The coefficient
represents the expected change in
for a one-unit increase in
, conditional on
. Therefore, the expected change in
operating through the mediator is: ![]()
This is the indirect effect. Under a simple linear mediation model without an exposure–mediator interaction: ![]()
The coefficients
,
,
, and
are obtained from the fitted regression models (using, for example, SAS PROC GLM). A confidence interval for the indirect effect
can then be estimated using bootstrap methods, discussed below.
A historically common approach is the Baron and Kenny causal-steps procedure, which evaluates the total effect, the
-to-
association, and the effects of
and
in a joint outcome model. However, this approach does not directly test the indirect effect
, and changes in statistical significance between models do not themselves establish mediation. Modern analyses therefore generally estimate the indirect effect directly and use a confidence interval, commonly obtained by bootstrapping.
The Sobel test may be used to assess whether the product of the two indirect-path coefficients,
, differs from zero. The test uses a normal approximation for the sampling distribution of
. However, this distribution is often asymmetric, particularly in small samples or when either pathway coefficient is close to zero, which can lead to inaccurate inference and limited power. The Sobel test is given by:

where,
is the estimated effect of X on M,
is the estimated effect of M on Y conditional on X, and
and
are their standard errors.
Another way to check for significance is to use bootstrap inference for the indirect effect. This method may provide greater power, as it does not rely on a normal approximation, when compared to the Sobel test.
Repeated random sampling of participant records with replacement is conducted from the dataset to compute a desired statistic via refitting the model for each bootstrap sample. The bootstrap distribution is then used to estimate uncertainty and construct the confidence interval for the indirect effect. Bootstrapping may, also, perform better than the Sobel test in small or moderate samples.
The simple product-of-coefficients approach is most straightforward when the mediator and outcome are continuous and modelled on compatible scales. In our AS example, however, the proposed mediator (anxiety/depression) was not continuous, requiring an adaptation of the standard approach.
Variables in our study:
Y = Work Productivity Loss: calculated as a percentage and so a continuous variable;
X = Fatigue: patient-assessed on a Visual Analogue Scale (VAS) and so a continuous variable; but
M = Anxiety/Depression: patient-assessed using the anxiety/depression dimension of the European Quality of Life 5 Dimensions (EQ-5D) questionnaire and so an ordinal variable (None/ Some/ Extreme problems). We dichotomised this variable as None (M=0) vs. Some/ Extreme (M=1) due to a low “Extreme” event count. As the mediator was binary,
represents the estimated change in the probability of anxiety/depression associated with a one-unit increase in fatigue under the identity-link model.
The model relating X to M then becomes:

To quantify the indirect effect, we need to estimate the difference in probability of anxiety/depression (P(M=1)) associated with a unit increase in fatigue (X),and then to estimate the expected change in work productivity loss (Y) due to this estimated change in the mediator (M). Logistic regression models model the log odds rather than probabilities (in the linear predictor) and so estimating the probability difference is not straight-forward as the coefficient a does not directly represent a probability difference directly
The solution was to model the probabilities (rather than log odds) using a binomial distribution and identity link1 implemented using SAS PROC GENMOD/GLIMMIX. In this model, the expected change in work productivity loss (Y) due to a unit change in fatigue (X) via the binary mediator is again given by the ab product. The 95% CI can again be found by bootstrapping. PROC GENMOD and PROC GLIMMIX give very similar results but the standard errors (and so 95% CI) tend to be more robust using PROC GLIMMIX.
The model relating X to M then becomes:
![]()
This approach retains a straightforward probability-scale interpretation for a, but it is approximate because an identity-link model does not constrain fitted probabilities to lie between 0 and 1. Predicted probabilities should therefore be checked, and the indirect-effect estimate should be interpreted with appropriate caution.
SAS macros were developed to calculate the direct and indirect effects (with 95% CIs) for all combinations of continuous/binary Y, X, and M. Where the mediator was binary, the above approximation method was used. This allowed all pathway strengths to be estimated with the 95% CIs indicating significance (at the 5% level) or not.
Because the method used for the binary mediator was an approximate method, an additional SAS macro was developed to implement a method by Dawn Iacobucci2 which tests the significance of the mediating effect. This method calculates a Z statistic based on the standardised coefficients of X in the model to M ((2) or (4)) and the standardised coefficients of M in the direct path model (3), which can be used to test significance; but it does not estimate the indirect effect (pathway strength).
All direct and indirect pathways from fatigue at baseline to work productivity loss at 12 months were then estimated. The estimated strengths of the pathways and significance levels were used to build a picture of the relationships between fatigue and work disability. Significance levels were corroborated via the Z statistic.
This analysis helped evaluate the hypothesised relationship between fatigue, anxiety/depression, and work productivity loss, but it should not be read as proof of a causal mechanism on its own. Interpretation should consider the balance of pathway strength, confidence intervals, the corroborating Z statistic, model assumptions, and potential confounding.
The identity-link approach used for the binary mediator is approximate because it does not constrain fitted probabilities to lie between 0 and 1. Predicted probabilities should therefore be checked, and the indirect-effect estimate should be interpreted with appropriate caution.
The method can be developed to use with multi-categorical variables.
There is no dedicated FDA, EMA or ICH guideline prescribing a specific mediation method. In practice, mediation analyses are often positioned as exploratory or supportive, and should be prospectively specified, linked to a clearly defined estimand, and accompanied by sensitivity analyses for mediator–outcome confounding.

The strongest pathways from fatigue to work productivity loss appeared to be direct. The estimated indirect pathway through anxiety/depression was weak, and the corroborating Z statistic did not provide clear evidence of mediation. Overall, the findings offered limited support for the hypothesis that anxiety/depression mediated the relationship between fatigue and work productivity loss.
The methodology has allowed us to evaluate the hypothesised relationships and specifically, to investigate and understand the mechanism by which fatigue affects work productivity loss.
The results suggest that the strongest pathways from fatigue to work productivity loss are direct and do not support the hypothesis of mediation through anxiety/depression.
It is an approximate method, which is why a second method was used to corroborate significance. It is important to use the balance of: (i) pathway strength; (ii) significance of pathway strength implied by the confidence interval estimated, and (iii) significance of the mediating effect assessed via the Z statistic to make inferences about causal relationships.
Quanticate's statistical consultancy team have performed statistical analysis and support for drug development companies on several observational studies. If you are interested in learning more about how we could support your observational study, request a consultation and a member of our team will be in touch with you.
References
1. SAS Usage Note 37228. Online at http://support.sas.com/kb/37/228.html#note1
2. Iacobucci D. Mediation analysis and categorical variables: the final frontier. Journal of Consumer Psychology 22 (2012) 582-594. Online at www.sciencedirect.com
Bring your drugs to market with fast and reliable access to experts from one of the world’s largest global biometric Clinical Research Organizations.
© 2026 Quanticate