Abstract
Mediation analysis is an important analytic tool commonly used in a broad range of scientific applications. In this article, we study the problem of mediation analysis when there are multivariate and conditionally dependent mediators, and when the variables are observed over multiple time points. The problem is challenging, because the effect of a mediator involves not only the path from the treatment to this mediator itself at the current time point, but also all possible paths pointed to this mediator from its upstream mediators, as well as the carryover effects from all previous time points. We propose a novel multivariate dynamic mediation analysis approach. Drawing inspiration from the Markov decision process model that is frequently employed in reinforcement learning, we introduce a Markov mediation process paired with a system of time-varying linear structural equation models to formulate the problem. We then formally define the individual mediation effect, built upon the idea of simultaneous interventions and intervention calculus. We next derive the closed-form expression, propose an iterative estimation procedure under the Markov mediation process model and develop a bootstrap method to infer the individual mediation effect. We study both the asymptotic property and the empirical performance of the proposed methodology, and further illustrate its usefulness with a mobile health application.
Key words and phrases. Longitudinal data, Markov process, mediation analysis, mobile health, reinforcement learning
MSC2020 subject classifications: 62L10
1. Introduction.
Mediation analysis is an important analytic tool, which seeks to explain the mechanism or pathway that underlies an observed relationship between a treatment and an outcome variable, through the inclusion of an intermediary variable known as a mediator. It decomposes the effect of the treatment on the outcome into a direct effect and an indirect effect, the latter of which indicates whether the mediator is on a pathway from the treatment to the outcome (Baron and Kenny (1986)). Mediation analysis is widely employed in a range of scientific applications, including psychology (MacKinnon (2008), Rucker et al. (2011)), genomics (Huang and Pan (2016), Bi et al. (2017)), economics (Celli (2022)), social science (Kaufman and Kaufman (2001)), neuroscience (Zhao and Luo (2022)), among many others. See VanderWeele (2016) for a comprehensive review and the references therein.
Mediation analysis has seen considerable progress in recent years. There are two lines of research of particular interest, mediation analysis with multivariate mediators and mediation analysis with time-varying variables. The first line targets the scenario where there are multiple mediators, and one central goal is to evaluate and quantify the contribution of the treatment on the outcome attributed to each individual mediator. There are three main categories of solutions. One category explicitly imposes that the multivariate mediators are conditionally independent given the treatment, which substantially simplifies the analysis (Boca et al. (2014), Huang and Pan (2016), Zhang et al. (2016), Guo et al. (2023), Shuai et al. (2023), Yuan and Qu (2024)). Another category does not impose such a condition, but instead marginalizes each individual mediator, which in effect neglects any potential interaction and dependency among the mediators (Sampson et al. (2018), Djordjilović, Hemerik and Thoresen (2022), Zhao, Li and Initiative (2022), Zhao and Luo (2022)). The last category does allow correlated mediators, characterizes their dependency through some unknown directed acyclic graph (DAG), then carries out mediation analysis based on the estimated DAG (Maathuis, Kalisch and Bühlmann (2009), Chakrabortty, Nandy and Li (2018), Cai, Song and Lu (2021), Shi and Li (2022), Wei et al. (2024)). The second line targets the scenario where the treatment, mediator and outcome are observed over multiple time points or stages. There have been some pioneering works along this line (Selig and Preacher (2009), Preacher (2015), VanderWeele and Tchetgen Tchetgen (2017), Lin et al. (2017), Huang and Yuan (2017), Zheng and van der Laan (2017), Zhao et al. (2018), Hejazi et al. (2023), Cai et al. (2022), Díaz, Williams and Rudolph (2023), Ge et al. (2023)). Nevertheless, they all focus on the case where there is only a single mediator, and most only consider the case where the number of time points, or the time horizon is finite.
In this article, we study the problem of mediation analysis when there are multivariate and conditionally dependent mediators, and when the variables are observed over multiple time points. Our motivation is a mobile health application from the Intern Health Study (IHS, NeCamp et al. (2020)). It is a 26-week prospective longitudinal randomized trial targeting first-year training physicians in the United States (NeCamp et al. (2020)). A key objective of this study is to investigate the effectiveness of in-the-moment mobile prompts in improving an intern’s mood score while minimizing user burden and expense. The prompts, delivered through a customized mobile app, consist of practical tips and life insights, such as reminders to have a break, take a walk or prioritize sleep that aim at promoting healthy behaviors among interns. These prompts not only affect an intern’s mood, but also influence other physiological measurements, including physical activity, sleep duration and heart rate variability, which are closely associated with an individual’s mental state. We can naturally formulate this problem in the framework of mediation analysis, where the treatment is the binary variable that encodes receiving a prompt or not, regardless of the prompt type, the mediators consist of measurements of physical activities, sleep duration and heart rate variability, and the outcome is the mood score. Given the presence of multiple mediators and the longitudinal nature of the data, it calls for a mediation analysis approach that tackles both multivariate mediators and multiple time points.
However, the problem is challenging, for several reasons. First, multivariate and conditionally correlated mediators introduce considerable complexity. Unlike the single mediator or conditionally independent mediator case, the indirect effect of each individual mediator involves not only the path from the treatment to this mediator itself, but also all possible paths pointed to this mediator from its upstream mediators. The total number of potential paths that go through any mediator is superexponential in the number of mediators. It is thus crucial to carefully disentangle the individual mediation effect when the multivariate mediators are interrelated with unknown dependency. Second, time-varying variables introduce another layer of complexity, as there are carryover effects along time. Unlike the single time-point case, the mediator at a given time point could affect both the current and future outcomes, and thus it is crucial to learn both the immediate effect and the delayed effect. Infinite time horizon further complicates the analysis when the mediator effect accumulates over infinite time.
To address those challenges, we propose a novel multivariate dynamic mediation analysis approach. Our proposal consists of four key components. First, drawing inspiration from the Markov decision process (MDP, Puterman (1994)) model that is frequently employed in reinforcement learning (RL, Sutton and Barto (2018)) to handle the carryover effects over time, we introduce a Markov mediation process (MMP) framework to formulate the dynamic mediation analysis problem. We then introduce a system of time-varying linear structural equation models (SEMs) to specifically characterize the relations among the treatment, mediator and outcome variables. Second, within the framework of MMP, we formally define the individual mediation effect, which is built upon the idea of simultaneous interventions and intervention calculus (Pearl (2000)). This individual mediation effect can be further decomposed into a sum of the immediate effect and the delayed effect, the latter of which quantifies the carryover effects of the past treatments and mediators. Third, under the proposed MMP and the linear SEMs, we derive the closed-form expression for the individual mediation effect; see Theorems 1 and 2. These theorems form the basis of our proposed procedure, allow us to express the individual mediation effect using a set of within-stage and cross-stage intermediate quantities that can be estimated through some recursive formulations and consist of the main contributions of our proposal. We next propose to estimate those within-stage quantities through linear regressions with backdoor covariate adjustment, and estimate those cross-stage quantities through the transition equations under SEMs. Finally, we study the asymptotic property of our proposed estimator of the individual mediation effect, develop a bootstrap method to construct its confidence interval (CI) and conduct extensive numerical studies to demonstrate the effectiveness of our method. In summary, our approach allows us to separately evaluate the contribution of each individual mediator, where multiple mediators are interrelated with unknown dependency and are observed over multiple time points.
The rest of the article is organized as follows. We present the Markov mediation process, the structural equation models, and the definition of the individual mediation effect in Section 2. We derive the intermediate quantities, the recursive formulation of the individual mediation effect, and the estimation algorithms in Section 3. We establish the asymptotic properties in Section 3.5. We carry out the simulations in Section 4, and revisit the IHS example in Section 5. We relegate all technical proofs to the Supplementary Material (Luo et al. (2025)).
2. Model and definition.
In this section, we first present our model setup, then formally define the mediation effect of interest in the multivariate dynamic mediation analysis setting.
2.1. Markov mediation process and structural equation models.
We first introduce a Markov mediation process framework to formulate the problem we target; see Figure 1(b) for a graphical illustration. Consider the treatment-mediator-outcome triplets over time, where denotes the number of time points or stages. At each time point or stage , a random treatment is administered, which subsequently affects a -dimensional vector of potential mediators , and an outcome variable . We assume they satisfy the Markov assumption, in that
| (1) |
where denotes statistical independence. We remark the Markov condition like (1) is widely imposed in sequential data problems (Sutton and Barto (2018)). Suppose the observed data consists of independent and identically distributed (i.i.d.) realizations of the triplets . We allow the data to be either densely or sparsely observed. Moreover, for simplicity, we assume that all subjects have the same . Nevertheless, our proposed method can be adapted to accommodate the setting when varies among subjects, and when the time lags between two time points differ. See Section 6.4 for more details.
Fig. 1.

(a) Diagram of Markov decision process (MDP), where treatments depend on current states only, and () represents the state-treatment-reward triplet; (b) Diagram of the proposed Markov mediation process (MMP), where current mediators depend on previous mediator-reward pairs, and () represents the treatment-mediator-outcome triplet.
In addition to the Markov condition, we further assume that the random treatment assignment is independent of the prior information, in that
| (2) |
Condition (2) holds in the sequentially randomized trials naturally, including our IHS example, which is the main setting we target in this article. Meanwhile, our framework can also be extended to the setting that involves certain static baseline confounders that may influence the treatment selection, thus accommodating the data from observational studies. Specifically, letting denote the baseline confounders, Condition (2) can be relaxed to , for any . The individual mediation effect that we define later can be similarly derived by incorporating into the model. For presentation simplicity, however, we choose not to include those confounders in this article.
We next introduce a system of time-varying structural equation models,
| (3) |
where is the condition mean function, is the weight matrix, such that if and only if mediator is a parent of , that is, is in the parent set, and is a vector of mean zero random errors. In model (3), the weight matrix models the interactions among the mediators at each time point, and the conditional mean characterizes the dynamic dependence over time.
We then consider the linear models for and , in that
| (4) |
for some , and for and some mean zero errors independent over time, respectively. In model (4), characterizes the effect of on . All random variables in (4) are assumed to have finite second moments. Let collect all the parameters for , and collect all the parameters for .
We make a few remarks. First, we draw a connection between the proposed MMP and MDP commonly studied in RL—a powerful machine learning technique for optimal sequential decision making (Murphy (2003), Mnih et al. (2015), Silver et al. (2017), Qin, Zhu and Ye (2021), Zhang, Chen and Yang (2023)). Both capture the carryover effects over time. MDP achieves this by introducing a sequence of time-varying feature variables, referred to as the states. It then models the carryover effects through state transitions, allowing past treatments to affect future outcomes through their impact on future states; see Figure 1(a) for an illustration. This approach has gained substantial attention for policy evaluation, serving to model both immediate and long-term effects of a target policy (Luckett et al. (2020), Hao et al. (2021), Liao, Klasnja and Murphy (2021), Kallus and Uehara (2022), Hu and Wager (2022), Liao et al. (2022), Ramprasad et al. (2023), Shi et al. (2022), Liu et al. (2023), Wang, Qi and Wong (2023)). In a similar vein, our MMP operates by modeling the indirect influence of a preceding mediator via the transitions of mediator-outcome pairs. In essence, a past mediator influences future outcomes by exerting its effects on both the prior outcome and the subsequent mediator; see Figure 1(b) for an illustration. Second, the relation in (3) should be understood as a data generating mechanism, rather than as a mere association. It corresponds to a directed acyclic graph (DAG). Third, to keep the presentation simple, we do not include any time-varying confounders, which may be incorporated into our solution in a relatively straightforward fashion. We do not consider any unobserved confounders either, because we consider random treatment assignments. We leave the case with unobserved confounders as future research. Finally, we consider linear type models in both (3) and (4). The analysis of mediation has been dominated by linear regression paradigms and such linearity assumption is commonly adopted in existing work; see, for example, Nandy, Maathuis and Richardson (2017), Chakrabortty, Nandy and Li (2018), Shi and Li (2022). It is possible to extend to nonlinear type models, under which the definition of individual mediation effect we give later still holds, but is more difficult to evaluate.
In this article, we consider two different settings: the finite-horizon and the infinitehorizon, borrowing the concepts from the RL literature (Sutton and Barto (2018)). For the finite-horizon setting, the number of time points is fixed and finite. It usually corresponds to the traditional longitudinal studies, where subjects receive a finite number of treatments over a predetermined time period. For the infinite-horizon setting, approaches infinity theoretically. It often applies to the applications involving continuous monitoring systems such as wearable devices, where the data is densely collected at high frequencies, for example, every second or minute. For the finite-horizon setting, we allow the process to be nonstationary. However, for the infinite-horizon setting, we require the process to be stationary over time, that is, the parameters and are constant over time. Without stationarity, we need to extrapolate to infer system dynamics beyond the observed time.
In summary, we believe that our model framework provides a reasonable starting point for multivariate dynamic mediation analysis. The methodology under our setting is already complex enough, and deserves a careful investigation.
2.2. Total, direct and indirect effects.
Before we formally define the individual mediation effect, which is the main target of interest in this article, we first introduce the notions of total effect, natural direct effect and natural indirect effect in the finite-horizon setting. This is to facilitate the understanding of our target, and also to establish the connection with the classical mediation analysis literature.
For the total effect, consider a hypothetical intervention applied to the system, where we set all treatments to some value uniformly over the entire population. This can be realized through Pearl’s do-operator, , which generates an interventional distribution by removing the edges leading into in the corresponding DAG (Pearl (2000)). We denote the post-interventional expectation of by . We then define the total effect over time points as
| (5) |
We make two remarks. First, each summand on the right-hand side of (5) measures the total effect of treatment on at time . Second, when the treatment takes a discrete value, the derivative in those terms can be substituted by the difference operator. For instance, if the treatment is binary, we obtain that
Next, we decompose the total effect into the sum of the natural direct effect and the natural indirect effect. Specifically, at each time point , we define the direct effect to be the portion of the total effect of a sequence of treatment variables on the outcome that does not go through . To measure such an effect, we consider the joint intervention on () through , and denote the post-interventional expectation of by . We then define the natural direct effect over time points as
where denotes the interventional probability density function of () under the assumption that all treatments are set to , and the term corresponds to the interventional effect of on when setting the interventional values of to constants.
We then define the natural indirect effect as the difference between TE and DE, that is, , which quantifies the portion of the effect of the treatment sequence on the outcome that goes through the mediator sequence.
We remark that the definitions of TE, DE and IE do not require linear structural equation models like (4). However, imposing such models greatly simplify the analysis. More specifically, in a general Markov mediation process, both and can depend on in a very complex manner, as also mentioned in Chakrabortty, Nandy and Li (2018). However, (4) simplifies these expressions to be functions of the regression coefficients that are independent of specific values of or ; see Section 3 for more details. As a result, DE is equivalent to
| (6) |
for any , where (6) is the controlled direct effect, computed by setting all values of mediators to . Correspondingly, by (5) and (6), the natural indirect effect becomes
| (7) |
In other words, the linear structural equation model avoids the need to estimate the interventional probability density function , thus substantially simplifying the forms of DE, IE and their subsequent estimation and inference procedures.
2.3. Individual mediation effect.
We now formally define the individual mediation effect, the main target in our dynamic mediation analysis. We begin with the finite-horizon setting.
Definition 1 (Individual mediation effect in finite-horizon). In a finite-horizon setting, the individual mediation effect of the th mediator over time points is defined as
When the treatment is binary, can be defined as
| (8) |
We again make a few remarks. First, our definition of the individual mediation effect is related to the definition of IE in (7), and is defined as the difference between the total effect and the interventional effect over time. However, the key difference is that, whereas IE measures the mediation effect of all mediators, focuses on quantifying the portion of the effect that specifically passes through the individual th mediator. As such, we only intervene the th mediator as opposed to all mediators in the intervention, and we refer to it as an individual mediation effect.
Second, our definition is consistent with the existing literature. Specifically, when there is only one mediator and a single time point, our definition aligns with the classical definition of Baron and Kenny (1986), , where the first term is the regression coefficient by regressing on , and the second term is the partial regression coefficient by further including in the regression. This difference measuring the reduction in the total effect due to controlling for is widely used to quantify the effect mediated through ; see also Pearl (2012). When there is a single time point, our definition is consistent with the one proposed by Chakrabortty, Nandy and Li (2018). When there is a single mediator, (8) is similar to the definitions proposed by VanderWeele and Tchetgen Tchetgen (2017) and Ge et al. (2023) under a potential outcome framework.
Third, under the linear structural equation model (4), is a constant function with respect to and . It can depend on () in a more general Markov mediation process, for example, when either the transition model from a given time point to the next or the DAG structural equation model at a given time point is nonlinear. In addition, we observe that, under (4), the second post-interventional expectation term, , may be analyzed by the path method (Wright (1921)). That is, it can be calculated by summing up the effects along all directed paths from to that do not pass through . However, this approach can be computationally expensive, since the number of paths grows exponentially fast as the number of time points increases.
Finally, in Definition 1 measures the cumulative effect mediated through the th mediator across all stages. Alternatively, one may be interested in the incremental effect,
which measures the individual mediation effect attributed to at time . By definition, we see that this incremental effect is related to the cumulative effect, in that .
To better understand our definition of the individual mediation effect, we further decompose into the sum of the immediate individual mediation effect (IIME) and the delayed individual mediation effect (DIME), as defined next.
Definition 2 (Immediate and delayed individual mediation effects in finite-horizon). Define the immediate individual mediation effect (IIME) and the delayed individual mediation effect (DIME) as
At a given time point can be interpreted as the change in the total effect of on when is knocked out, whereas captures the individual mediation effect of the th mediator that is carried over from all previous stages up to time .
We next turn to the infinite-horizon setting. In this setting, the individual mediation effect is defined as the average effect over time, so to prevent it from being unbounded.
Definition 3 (Individual mediation effect in infinite-horizon). In an infinite-horizon setting, the individual mediation effect of the th mediator is defined as , provided that the limit exists.
We comment that all above definitions are natural and agree with the intuitions. We next discuss how to evaluate and estimate the individual mediation effect given the data.
3. Evaluation of individual mediation effect.
In this section, we propose approaches to estimate and infer the individual mediation effects given in Definitions 1 and 3. The problem, however, is very challenging, as we have to deal with both the multiple mediators with unknown correlation structure, as well as the carryover effects from the upstream treatments and mediators. Our proposed solution involves deriving a closed-form expression for the individual mediation effect, as detailed in Theorems 1 and 2. This expression is dependent on several intermediate quantities that are computable through a set of recursive relations. Leveraging these theoretical findings, we develop an efficient recursive computation algorithm to estimate these intermediate quantities, which subsequently facilitate both the estimation and inference of the individual mediation effect.
3.1. An illustrative example.
To illustrate our theory, we first consider a simple example as shown in Figure 2, in which there are only mediators and time stages. We then extend our observations to more general cases with mediators and stages.
Fig. 2.

An illustrative example with two mediators and two time stages. The left panel shows the DAG in the first stage, and the right panel the first two stages. The dashed lines highlight the paths that go through the intervened mediator, that is, the second mediator.
Suppose we focus on the individual mediation effect for the second mediator, that is, . We begin with the first stage , as shown in Figure 2, left panel. By Definition 1,
| (9) |
where we use to denote the total effect from to , and use to denote the total effect from to when the second mediator is intervened in the first stage.
We compute by summing up the effects along all directed paths from to , namely and . Meanwhile, we compute by eliminating all paths that go from to through . This corresponds to subtracting the effects along and , which leads to
| (10) |
where we use and to denote the effect from to , and from to , respectively. The relation in (10) has an intuitive interpretation: to evaluate the total effect from to when is intervened, we subtract from the effects along the paths that go through . Plugging (10) into (9), we obtain that , which coincides with the classical product type representation of the individual mediation effect in a single-stage analysis (Nandy, Maathuis and Richardson (2017)).
We next move to the second stage , as in Figure 2, right panel. By Definition 1,
| (11) |
where we use to denote the cumulative total effect of () on , and use to denote the cumulative total effect of on when the second mediator is intervened in both the first and second stages.
Because the treatments are randomly assigned and their parent sets are empty, we have
| (12) |
where we use and to denote the total effects from to , and from to , respectively, use to denote the effect from to when the second mediator is intervened in the second stage, and use to denote the effect from to when the second mediator is intervened in both stages.
We compute and similarly as that for . We compute similarly as in (10), that is, . Also, similar to (10), we have
| (13) |
where we use and to denote the effects from to , and from to , when the second mediator is intervened in the second stage. Intuitively, can be interpreted as the carryover effect of the second mediator on the outcome from the first stage to the second stage when it is intervened. We again compute similar to (10), that is, . In addition, we compute by eliminating all paths that go from to through , which leads to
| (14) |
where we use and to denote the effects from to , from to and from to , respectively.
Based on the derivations so far, we see that to evaluate the individual mediation effect, it is crucial to calculate those intermediate quantities, such as , among others. Next, we briefly discuss how to evaluate those intermediate quantities after imposing the linear structural equation models (3) and (4). We also discuss some recursive relation that facilitates both the computational and statistical efficiencies.
First, we note that, under (3) and (4), we can estimate those intermediate quantities through linear regressions. For instance, we can estimate as the coefficient of by linearly regressing onto . Meanwhile, we can estimate as the coefficient of by linearly regressing onto , however, with some additional covariate adjustment. This is because, unless the two mediators () are conditionally independent given (), we need to adjust for a set of covariates that satisfy Pearl’s backdoor criterion (Pearl (2000)). In other words, we should block the effects flowing from () to . Therefore, we need to adjust for the covariate set in this regression.
Second, we note that the set of intermediate quantities involve both within-stage quantities such as , as well as cross-stage quantities such as . There is some useful recursive relation between the within-stage and cross-stage quantities under the linear structural equation models (3) and (4). For instance,
| (15) |
where , and . This suggests that the cross-stage carryover effect from to is a combination of its within-stage effect on and on , respectively, whereas the coefficients can be viewed as the weights for such a cross-stage transition. In our estimation algorithm, we first estimate the within-stage quantities via linear regressions, then update the cross-stage quantities following (15). As we show later, the relation such as (15) not only expedites the computation, but also improves the estimation efficiency by leveraging more information from the conditional model (4).
In summary, this simple example reveals a number of important relations. First, we see that those intermediate quantities form the building blocks for our evaluation of the individual mediation effect. Second, (10), (13) and (14) suggest some useful recursive representations that in effect reduce the number of mediators in the superscript that are intervened upon. Third, under models (3) and (4), we can estimate those intermediate quantities through linear regressions, with possibly backdoor adjustment. Finally, we can further improve both the computational and statistical efficiencies through another set of recursive relations between the within-stage and cross-stage quantities. All these observations are crucial for our derivation of the expression for the individual mediation effect.
3.2. Intermediate quantities.
We now formally define the set of all intermediate quantities that are needed for the evaluation of the individual mediation effect. We then discuss how to estimate those quantities.
For any , and , define
| (16) |
These intermediate quantities in (16) can be obtained through linear regressions, either directly, or by some backdoor covariate adjustment. In particular, can be obtained as the coefficient of by linearly regressing onto with an intercept, and we write this coefficient as . Similarly, can be obtained as the coefficient of by linearly regressing onto , denoted as . Meanwhile, can be obtained as the coefficient of by linearly regressing onto , along with the adjusted covariate set, . Similarly, can be obtained as the coefficient of by linearly regressing onto , along with the adjusted covariate set, . Putting together, we have
| (17) |
Moreover, similar to (15), we obtain the following recursive relations between the within-stage quantities and the cross-stage quantities. That is, under models (3) and (4),
| (18) |
In our implementation, we first estimate the within-stage quantities, , using (17), then estimate the cross-stage quantities, , for , using (18). This helps to improve both the estimation efficiency and the computation efficiency.
3.3. Individual mediation effect in a finite-horizon setting.
We next derive the expression of the individual mediation effect through the intermediate quantities in (16) under the finite-horizon setting.
We first sketch the key ideas of the derivation here, and relegate more details to the Supplementary Material. By Definition 1, the individual mediation effect of the th mediator across stages, , can be expressed as
| (19) |
Because all the treatments () are randomly assigned, and thus are independent of each other and all other covariates, similar to (12), we have
| (20) |
Then, similar to (10), (13) and (14), we obtain the following recursive relations that help reduce the number of mediators being intervened upon. That is, for any ,
| (21) |
| (22) |
Combining (19), (20), (21) and (22), we obtain the following theorem with respect to the identification of individual mediation effect in finite-horizon settings. We relegate a more detailed derivation to the Supplementary Material.
Theorem 1 (Individual mediation effect for finite-horizon). Suppose are randomly assigned treatments and satisfy (2), and follow (3) and (4). Then
| (23) |
where is computed following (22), and we set .
As for estimation, based on Theorem 1, we estimate the individual mediation effect in a recursive manner. That is, for stage , we first estimate the weight matrix in (3), and the parameters in (4) for stage . Estimation of is needed for determining the parent set of each mediator, which in turn is used for backdoor covariate adjustment. There are multiple algorithms available to estimate , including those developed in single time-point settings (Zheng et al. (2018), Yuan et al. (2019), Bello, Aragam and Ravikumar (2022)), and those developed in time-varying settings (Hyvärinen et al. (2010), Malinsky and Spirtes (2018), Pamfil et al. (2020)). We employ the DAGMA algorithm recently proposed by Bello, Aragam and Ravikumar (2022) for its simplicity and effectiveness. Recall that, in the finite-horizon setting, we allow the DAG to be nonstationary over time. We thus estimate the time-specific DAGs using DAGMA, with data pooled over multiple subjects but restricted to that time point only. We then estimate the within-stage quantities using (17), and estimate the cross-stage quantities, , for , using (18). Finally, we plug-in these estimators into (23) to estimate the individual mediation effect.
As for inference, based on Theorem 3 in Section 3.5, our plug-in estimator is asymptotically normal. This motivates us to employ the nonparametric bootstrap approach (Efron (1979)) to conduct statistical inference. Specifically, we first sample trajectories from the observed data with replacement. We next refit the weight matrix and reestimate the within-stage and cross-stage quantities using the bootstrap samples. During the refitting, there are two options. One is to use the bootstrap samples to refit the coefficients of the nonzero entries in the weight matrix only, without reestimating the structure of . The other is to refit both the structure of and its nonzero entries. When the structure learning algorithm is consistent, the two solutions are asymptotically equivalent. For finite samples, the former is computationally more efficient, while the latter is expected to be more accurate. In our implementation, we adopt the first option due to its simplicity, and our numerical experiments suggest that it works well empirically. We next construct the plug-in estimators using these refitted parameters. Finally, we use the empirical lower and upper quantiles of the plug-in estimators to construct the confidence interval under a given significance level .
Algorithm 1 summarizes our estimation and inference procedure.
3.4. Individual mediation effect in an infinite-horizon setting.
We next derive the expression of the individual mediation effect under the infinite-horizon setting. Unlike the finite-horizon setting, we now require the Markov mediation process to be stationary. This is to ensure the existence of the limit in Definition 3. Correspondingly, the parameters in (3) and (4) remain the same across different time stages, which leads to the following relations. For any , and ,
Based on this observation, we obtain a simplified representation for as
By dividing the right-hand side by and taking the limit , we obtain the following theorem for identifying the individual mediation effect in infinite-horizon settings. We relegate a more detailed derivation to the Supplementary Material.
Algorithm 1.
Estimation and inference for the finite-horizon setting
| Input: Observed data , the number of bootstrap samples , and the significance level . | |
| Output: Individual mediation effect , for and their CIs. | |
| 1: | Estimate within-stage quantities and compute . |
| 2: | for do |
| 3: | Estimate parameters in models (3) and (4). |
| 4: | Estimate within-stage quantities , |
| 5: | for do |
| 6: | Estimate cross-stage quantities () using (18). |
| 7: | end for |
| 8: | Compute using (23). |
| 9: | end for |
| 10: | for do |
| 11: | Sample trajectories from the observed data with replacement. |
| 12: | Repeat Lines 1 to 9 to compute using the bootstrap samples. |
| 13: | end for |
| 14: | for do |
| 15: | Construct the CI for , where and are the empirical lower and upper quantiles of , respectively. |
| 16: | end for |
Theorem 2 (Individual mediation effect for infinite-horizon). Suppose are randomly assigned treatments and satisfy (2), follow (3) and (4), the Markov process is stationary, and the parameters in (3) and (4) are time-invariant. Then
| (24) |
where are the th element of , respectively,
| (25) |
As for estimation, based on Theorem 2, we pool the data across all stages to estimate the model parameters . Recall that, in the infinite-horizon setting, we require the DAG to be stationary over time. We thus apply DAGMA to the data pooled across all time points to learn this time-invariant DAG. This is different from the finite-horizon setting where the model parameters can differ from one stage to another, while in the infinite-horizon setting, they remain the same. We then estimate the quantities to in (25) by plugging in the estimates of the corresponding model parameters, and we estimate the individual mediation effect using (24). As for inference, we adopt a similar nonparametric bootstrap procedure as in the finite-horizon setting. Algorithm 2 summarizes our estimation and inference procedure.
3.5. Asymptotic theory.
We establish the asymptotic properties of our estimator of the individual mediation effect. We first present a set of regularity conditions.
Assumption 1 (Invertibility). Let . There exists some constant , such that for any , where denotes the minimum eigenvalue of a given matrix.
Algorithm 2.
Estimation for the infinite-horizon setting
| Input: Observed data , the number of bootstrap samples , and the significance level . | |
| Output: Estimated individual mediation effect , for . | |
| 1: | Pool data across all stages, . |
| 2: | Estimate parameters using the pooled data. |
| 3: | Estimate and using the pooled data. |
| 4: | Compute to using (25). |
| 5: | Compute using (24). |
| 6: | for do |
| 7: | Sample trajectories from the observed data with replacement. |
| 8: | Repeat Lines 1 to 5 to compute using the bootstrap samples. |
| 9: | end for |
| 10: | Construct the CI for , where and are the empirical lower and upper quantiles of , respectively. |
Assumption 2 (Error residuals). (i) The error terms in (3) are jointly normally distributed and independent, for . In addition, their variances are constant, in that . (ii) The error terms in (4) satisfy that , for .
Assumption 3 (Structure learning consistency). The estimated DAG is a consistent estimator of the true underlying DAG; that is, (i) for the finite-horizon setting, for as , where is the true DAG in stage ; (ii) for the infinite-horizon setting, as , where is the true time-invariant DAG.
Assumption 4 (Stationarity). For the infinite-horizon setting, the process is a strictly stationary -mixing process.
We give some remarks about these conditions. Assumption 1 guarantees the identifiability of model parameters in (4). Assumption 2(i) is commonly imposed for identifying DAG structures; see, for example, Peters and Bühlmann (2014), Nandy, Maathuis and Richardson (2017), Yuan et al. (2019), Shi and Li (2022). Assumption 2(ii) requires the fourth moments of the errors to be finite, which is mild. Assumption 3 holds for numerous DAG estimation algorithms, including the one by Bello, Aragam and Ravikumar (2022) that we use in our implementation. Assumption 4 is required for the infinite-horizon setting only, and the -mixing condition is again commonly imposed; see, for example, Bradley (2005). Overall, these regularity conditions are reasonable.
We next establish the asymptotic normality of our individual mediation effect estimator for both the finite-horizon and infinite-horizon settings.
Theorem 3 (Asymptotic distribution for finite-horizon). Suppose Assumptions 2 and 3(i) hold. Then, for ,
where denotes the asymptotic variance of . Its form is given in the Supplementary Material, and it can be consistently estimated via the bootstrap method.
Theorem 4 (Asymptotic distribution for infinite-horizon). Suppose Assumptions 2, 3(ii) and 4 hold. Then
where denotes the asymptotic variance of . Its definition is given in the Supplementary Material, and it can be consistently estimated using the bootstrap method.
We briefly remark that Theorem 3 requires the number of realizations of () to diverge to infinity for every , with being finite. Meanwhile, Theorem 4 requires either or the number of time points or both to diverge to infinity.
4. Simulations.
In this section, we investigate the empirical performance of our proposed method through intensive simulations. We also compare with some baseline methods.
4.1. Simulation setup.
We generate copies of random samples following models (3) and (4), that is,
We generate the sequence of treatments , , and the error terms and from a standard normal distribution. Let and collect the model parameters, and we generate the entries of from a uniform distribution on (−0.5, 0.5). For the finite-horizon setting, we generate different for different time points , whereas for the infinite-horizon setting, we only generate one copy of , and keep them fixed across all time points. We fix , and generate the matrix in two steps. We first begin with a zero matrix, then replace every entry , by the product of two random variables , where is a Bernoulli variable with probability 0.9, indicating a random directed edge is added from mediator to , and is the edge weight, which is randomly drawn from a uniform distribution on . Following this generation process, we obtain . We set the initial values of mediators and outcome all equal to 0.
We recognize that there is no existing solution in the literature for this problem. Instead, we compare with two baseline solutions. One method is termed “independent time points,” which ignores all temporal dependence across different time points. That is, it estimates the individual mediation effect at every single time stage with stage-specific data, without taking into account the dependence to prior stages nor the carryover effects. The other method is termed “independent mediators,” which ignores all dependence among the multivariate mediators, and essentially treats as a zero matrix. We evaluate all estimation methods using three criteria: the estimation bias, the empirical standard error (SE) and the coverage probability (CP). For inference, we set the number of bootstrapped samples to be 500 and the significance level to be 0.05. We employ DAGMA with linear models for structural learning, and the corresponding hyperparameters, w_threshold and lambda1, are set to 0.1 and 0.0, respectively.
4.2. Finite-horizon setting.
For the finite-horizon setting, we consider the number of time points and the sample size . Note that the true individual mediation effect cannot be derived analytically in our setting, and is computed numerically based on 10 million Monte Carlo samples. Table 1 reports the results based on 500 replications. We observe that, when the number of subjects increases, the estimation bias and standard error both decrease for our proposed method, which agrees with our theory. Moreover, our method achieves the desired coverage probability across all scenarios. The same is not true for the two baseline methods. For instance, for the independent mediators method, the estimation bias of and does not decrease. This is because is in the parent set of and for all , and ignoring the effects along the paths and lead to a larger bias and invalid coverage probability in estimating and . On the contrary, the estimation bias of is much smaller, since the parent set of is empty given () in our simulation example.
Table 1.
Simulations for the finite-horizon setting: the bias, the empirical standard error (SE) and the coverage probability (CP) between the estimated and true individual mediator effects with varying number of time points T and number of subjects n
| 100 | 250 | 500 | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Method | Param | Bias | SE | CP | Bias | SE | CP | Bias | SE | CP | |
| Proposed method | 10 | 0.000 | 0.594 | 0.972 | 0.003 | 0.351 | 0.966 | 0.008 | 0.249 | 0.960 | |
| −0.016 | 0.533 | 0.960 | −0.036 | 0.283 | 0.970 | −0.006 | 0.209 | 0.952 | |||
| 0.007 | 0.696 | 0.964 | 0.023 | 0.420 | 0.962 | 0.011 | 0.312 | 0.950 | |||
| 20 | −0.046 | 1.960 | 0.950 | 0.008 | 1.215 | 0.946 | −0.023 | 0.840 | 0.950 | ||
| −0.037 | 1.134 | 0.970 | −0.018 | 0.717 | 0.944 | −0.021 | 0.490 | 0.948 | |||
| 0.027 | 1.236 | 0.956 | 0.012 | 0.721 | 0.954 | −0.003 | 0.491 | 0.972 | |||
| 30 | 0.044 | 2.655 | 0.948 | −0.078 | 1.691 | 0.938 | 0.055 | 1.159 | 0.940 | ||
| −0.067 | 1.610 | 0.962 | −0.002 | 0.915 | 0.964 | −0.020 | 0.651 | 0.954 | |||
| −0.067 | 1.838 | 0.958 | −0.055 | 1.122 | 0.960 | 0.051 | 0.783 | 0.946 | |||
| Independent time points | 10 | −0.577 | 0.373 | 0.712 | −0.558 | 0.204 | 0.370 | −0.569 | 0.131 | 0.132 | |
| 0.199 | 0.759 | 0.962 | 0.171 | 0.447 | 0.926 | 0.175 | 0.308 | 0.888 | |||
| −0.768 | 1.472 | 0.896 | −0.762 | 0.861 | 0.866 | −0.716 | 0.656 | 0.806 | |||
| 20 | 0.823 | 1.301 | 0.882 | 0.844 | 0.665 | 0.724 | 0.852 | 0.441 | 0.580 | ||
| 6.158 | 4.075 | 0.636 | 6.071 | 2.479 | 0.286 | 6.075 | 1.797 | 0.066 | |||
| 0.694 | 3.095 | 0.952 | 0.665 | 1.804 | 0.936 | 0.683 | 1.315 | 0.914 | |||
| 30 | 1.662 | 1.491 | 0.854 | 1.626 | 0.831 | 0.598 | 1.607 | 0.530 | 0.370 | ||
| −10.111 | 6.992 | 0.700 | −9.898 | 4.801 | 0.410 | −9.989 | 3.207 | 0.126 | |||
| −2.352 | 1.880 | 0.860 | −2.446 | 1.081 | 0.374 | −2.392 | 0.715 | 0.144 | |||
| Independent mediators | 10 | 0.000 | 0.594 | 0.972 | 0.003 | 0.351 | 0.954 | 0.008 | 0.249 | 0.964 | |
| −0.139 | 0.640 | 0.944 | −0.175 | 0.342 | 0.944 | −0.142 | 0.263 | 0.904 | |||
| 0.164 | 0.603 | 0.942 | 0.178 | 0.368 | 0.938 | 0.172 | 0.276 | 0.892 | |||
| 20 | −0.045 | 1.959 | 0.948 | 0.008 | 1.215 | 0.950 | −0.023 | 0.840 | 0.952 | ||
| −0.159 | 1.370 | 0.956 | −0.135 | 0.814 | 0.950 | −0.157 | 0.576 | 0.930 | |||
| −0.764 | 1.390 | 0.926 | −0.728 | 0.830 | 0.882 | −0.779 | 0.602 | 0.772 | |||
| 30 | 0.044 | 2.656 | 0.946 | −0.078 | 1.691 | 0.932 | 0.055 | 1.159 | 0.948 | ||
| −1.286 | 2.087 | 0.922 | −1.154 | 1.114 | 0.872 | −1.227 | 0.864 | 0.692 | |||
| −0.741 | 2.128 | 0.934 | −0.724 | 1.279 | 0.892 | −0.632 | 0.920 | 0.884 | |||
4.3. Infinite-horizon setting.
For the infinite-horizon setting, we consider the number of time points and the sample size . Again, the true individual mediation effect cannot be derived analytically in our setting, and is computed numerically based on 10 million Monte Carlo samples with 3000 time points. We also drop the first five steps as a warm up to mitigate the potential influence of the initial conditions. Table 2 reports the results based on 500 data replications. We again observe that the estimation bias and standard error both decrease for our method as increases, and the desired coverage probability is achieved, across all scenarios. On the other hand, the bias increases sharply for the independent time points method, because ignoring the carryover effects becomes exaggerated with a large . Moreover, the estimation bias of the independent mediators method is much larger than the proposed method for and . Both baseline methods fail to achieve the desired coverage probability in most cases, except for the independent mediators method with . This is due to the specific simulation setting with an empty parent set given the history. In general, these results demonstrate the importance of taking into account both the dependence among multiple time points and among multiple mediators.
Table 2.
Simulations for the infinite-horizon setting: the bias, the empirical standard error (SE) and the coverage probability (CP) between the estimated and true individual mediator effects with varying number of time points T and number of subjects n
| 20 | 50 | 100 | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Method | T | Param | Bias | SE | CP | Bias | SE | CP | Bias | SE | CP |
| Proposed method | 100 | 0.002 | 0.070 | 0.918 | 0.002 | 0.046 | 0.928 | 0.001 | 0.029 | 0.934 | |
| 0.003 | 0.045 | 0.924 | 0.001 | 0.029 | 0.932 | 0.001 | 0.020 | 0.940 | |||
| 0.003 | 0.036 | 0.924 | 0.002 | 0.021 | 0.946 | 0.000 | 0.015 | 0.946 | |||
| 250 | −0.001 | 0.042 | 0.932 | −0.002 | 0.026 | 0.946 | −0.001 | 0.019 | 0.930 | ||
| −0.003 | 0.029 | 0.914 | −0.001 | 0.019 | 0.938 | 0.001 | 0.012 | 0.958 | |||
| 0.001 | 0.020 | 0.938 | 0.000 | 0.014 | 0.938 | −0.001 | 0.010 | 0.950 | |||
| 500 | 0.000 | 0.029 | 0.944 | 0.000 | 0.018 | 0.956 | −0.001 | 0.014 | 0.932 | ||
| 0.000 | 0.020 | 0.928 | −0.001 | 0.012 | 0.954 | 0.000 | 0.009 | 0.942 | |||
| 0.000 | 0.016 | 0.924 | −0.001 | 0.010 | 0.932 | 0.000 | 0.007 | 0.928 | |||
| Independent time points | 100 | 0.371 | 0.047 | 0.000 | 0.370 | 0.030 | 0.000 | 0.371 | 0.021 | 0.000 | |
| −0.065 | 0.076 | 0.818 | −0.070 | 0.049 | 0.658 | −0.071 | 0.034 | 0.404 | |||
| 0.132 | 0.086 | 0.628 | 0.133 | 0.060 | 0.314 | 0.132 | 0.040 | 0.076 | |||
| 250 | 0.372 | 0.027 | 0.000 | 0.371 | 0.018 | 0.000 | 0.371 | 0.013 | 0.000 | ||
| −0.075 | 0.048 | 0.616 | −0.073 | 0.030 | 0.300 | −0.073 | 0.020 | 0.052 | |||
| 0.134 | 0.055 | 0.286 | 0.135 | 0.034 | 0.028 | 0.133 | 0.024 | 0.000 | |||
| 500 | 0.370 | 0.021 | 0.000 | 0.371 | 0.013 | 0.000 | 0.371 | 0.010 | 0.000 | ||
| −0.073 | 0.035 | 0.368 | −0.074 | 0.021 | 0.058 | −0.073 | 0.015 | 0.002 | |||
| 0.131 | 0.039 | 0.074 | 0.131 | 0.024 | 0.000 | 0.134 | 0.018 | 0.000 | |||
| Independent mediators | 100 | 0.002 | 0.070 | 0.918 | 0.002 | 0.046 | 0.934 | 0.001 | 0.029 | 0.936 | |
| 0.322 | 0.031 | 0.000 | 0.324 | 0.019 | 0.000 | 0.325 | 0.015 | 0.000 | |||
| −0.264 | 0.038 | 0.000 | −0.266 | 0.024 | 0.000 | −0.265 | 0.016 | 0.000 | |||
| 250 | −0.001 | 0.042 | 0.934 | −0.002 | 0.026 | 0.934 | −0.001 | 0.019 | 0.942 | ||
| 0.324 | 0.019 | 0.000 | 0.324 | 0.012 | 0.000 | 0.325 | 0.009 | 0.000 | |||
| −0.265 | 0.024 | 0.000 | −0.265 | 0.014 | 0.000 | −0.265 | 0.010 | 0.000 | |||
| 500 | 0.000 | 0.029 | 0.936 | 0.000 | 0.018 | 0.952 | −0.001 | 0.014 | 0.936 | ||
| 0.324 | 0.014 | 0.000 | 0.325 | 0.009 | 0.000 | 0.324 | 0.006 | 0.000 | |||
| −0.265 | 0.017 | 0.000 | −0.265 | 0.011 | 0.000 | −0.265 | 0.007 | 0.000 | |||
5. Data application.
In this section, we revisit the motivating Intern Health Study (NeCamp et al. (2020)). The IHS is a 26-week sequentially randomized trial with the objective of understanding the biological mechanisms of depression, and the ultimate goal of improving the mental health outcomes of medical interns in the United States. The study developed and deployed a mobile app to deliver prompt notifications, such as reminders to have a break, take a walk or prioritize sleep, which aims to improve the well-being of interns who often work under stressful environments. In each week, each intern was randomized into receiving the notifications or not. Meanwhile, wearable devices (Fitbit) recorded daily measurements of step count (Step), sleep duration (Sleep, minutes), resting heart rate (RHR, beats per minute) and heart rate variability (HRV, milliseconds). Interns also self-reported a daily mood score in the app (Shaffer and Ginsberg (2017)). We formulate the problem in the framework of multivariate dynamic mediation analysis, with the binary status of receiving the notification or not as the treatment, the transformed measurements, that is, the cubic-root of step count, the square-root of sleep duration, RHR and HRV as potential mediators and the mood score as the outcome. We average all the measurements within each week, resulting in weeks of data, for interns undergoing the sequential randomization.
We apply our method to this data adopting the finite-horizon setting. This is partly because we have a relatively limited number of time points in this study, and partly because the data is likely to be nonstationary over time (NeCamp et al. (2020), Li et al. (2022), Wang, Shi and Wu (2023)). Our analysis, as shown in Figure 4, also confirms that the individual mediation effect varies over time. Figure 3(a) shows the estimated DAG structure among the four mediators, while Figures 3(b) and (c) show the estimated individual mediation effects over time, along with the associated 95% confidence intervals, that are smoothed with a natural cubic spline and further decomposed as the immediate and delayed effects.
Fig. 4.

Analysis of IHS mobile health data: the estimated effects from the treatment to the four individual mediators, decomposed as the immediate (first row) and delayed (second row) effects, respectively.
Fig. 3.

Analysis of IHS mobile health data: (a) the estimated DAG among the four mediators, dashed/solid arrows represent negative/positive effects; (b) the estimated immediate individual mediation effects over time; (c) the estimated delayed individual mediation effects over time. The shaded area indicates the 95% confidence interval.
We make a number of observations. First of all, we see from Figure 3(a) that, the four mediators have complex relationships between each other, indicating the importance of accounting for the dependence structure among the mediators. Second, we see from Figure 3(b) and (c) that the magnitude of the delayed effects is generally greater than that of the immediate effects, indicating the importance of accounting for the carryover effects in our understanding of the effects of push notification to intern’s mood. Third, most individual mediation effects are insignificant. This could potentially be attributed to the relatively weak treatment effect, as also noted by NeCamp et al. (2020). Fourth, there is a significantly negative carryover effect from the push notification to mood score mediated by the RHR around week 10. Meanwhile, this carryover effect is predominantly negative across most weeks. To illustrate this effect, Figure 4 further plots the smoothed estimated effects from the treatment to the four individual mediators, decomposed as the immediate and delayed effects, respectively. We see that the push notification leads to an increased RHR after week five, suggesting that the push notification can lead to a lower mood score by increasing the RHR. This agrees with our prior knowledge that an increased RHR usually indicates a more tired and stressful state, thus a worse mood. Finally, the carryover effect from the push notification to sleep duration is mostly negative, and is nearly significant between weeks 15 and 20. As seen in Figure 4, the push notification generally results in reduced sleep hours, aligning with our knowledge that fewer sleep hours lead to poorer mood, too.
6. Conclusion and discussion.
In this section, we discuss the relation between our individual mediation effect and the Granger causality, numerous other mediation effects that may be of potential interest and some additional extensions.
6.1. Connection to Granger causality.
The Granger causality is a concept that leverages the temporal ordering inherent to time series so to draw causal statements restricted to the “past” causing the “future” (Granger (1969)). A variable is said to Granger-cause the other, if including this variable’s past values provides valuable information for forecasting the other variable’s future behavior. The proposed models in (3) and (4) are mathematically similar to those under the Granger causality framework, since may be predicted by its past value and and also depends on its past value and .
However, our notion of individual mediation effect differs from the concept of Granger causality, in that a mediator’s individual mediation effect and its ability to Granger-cause the outcome is not equivalent. On the one hand, a mediator can have a zero individual mediation effect, but still Granger-causes the outcome, if it is not influenced by the treatment. Figure 5, Case 1, gives an illustrative example. In this case, we have a single mediator that impacts the outcome at each time point, thereby Granger-causing the outcome. However, since the mediator is unaffected by the treatment, there is no direct causal pathway from the treatment through the mediator to the outcome, resulting in a zero individual mediation effect. On the other hand, a mediator with a nonzero individual mediation effect might not necessarily Granger-cause the outcome, if it does not improve the forecast accuracy of the outcome beyond other mediators. Figure 5, Case 2, gives another example. In this case, the first set of mediators and directly influence the outcome, thus Granger-causing the outcome. The second mediator , however, affects the outcome indirectly through its influence on the first mediator , resulting in a nonzero individual mediation effect. Despite this, does not Granger-cause the outcome or , as its influence is mediated indirectly.
Fig. 5.

An illustration of the difference between the individual mediation effect and the Granger causality.
6.2. Sequential mediation effect.
As discussed in Section 2.3, the individual mediation effect measures the cumulative effect mediated through the th mediator across all the upstream mediators and all time points. Meanwhile, it may be of separate interest to analyze the portion of the individual mediation effect of that is attributed to its upstream mediator . We denote this effect as , and call it the sequential mediation effect, as it quantifies the effect that is sequentially transmitted from the treatment, through the th mediator, to the th mediator, then to the outcome.
We next formally define the sequential mediation effect. Toward that end, we require the DAG structure to remain stationary over time. That is, if the th mediator is an ancestor of the th mediator at any time , that is, there exists a direct path from to , then the same relation holds at all time points. For the finite-horizon setting, we define the sequential mediation effect over time points as
if the th mediator is an ancestor of the th mediator, and set otherwise. In this definition, the first term corresponds to the total treatment effect, the second and third terms measure the effects that do not go through the th or the th mediator, respectively, and the last term quantifies the effect that does not simultaneously pass both the th and th mediators. Then, by the principle of inclusion-exclusion, measures the desired sequential mediation effect. For the infinite-horizon setting, we define , provided the limit exists.
To further illustrate this definition, we revisit the examples in Figure 2. For the single-stage example in Figure 2, left panel, the mediator is a child of and is affected by . Its individual mediation effect that passes through is
It is clear to see that the term corresponds to the effect along the path , which coincides with the results from the path analysis. Similarly, for the two-stage example in Figure 2, right panel, we have that
where the terms in the last two lines of the above equation can be calculated recursively with the formulas in equations (21) and (22), allowing for the estimation and inference of the sequential mediation effect.
Finally, we extend beyond the above illustrative examples to outline the estimation and inference procedure for the sequential mediation effect under a general setting involving mediators across time points. As for estimation, we begin by applying an existing structural learning algorithm to the observed data to learn the DAG structure. From the estimated DAG, if the th mediator is not an ancestor of the th mediator, we set the estimated sequential effect to zero. Otherwise, we obtain the estimated through the quantities , and , which in turn can be recursively updated following the method developed in Section 3. As for inference, we again apply the bootstrap approach in Section 3 to quantify the uncertainty of this plug-in estimator .
6.3. Direct, indirect and conditional effects.
We discuss the direct effect DE and indirect effect IE in Section 2.2. We now briefly discuss their estimation and inference, which may be of separate interest. Recall DE in (6) under linear SEMs. It satisfies a recursive equation,
for , with . Here, we add the superscript to DE to indicate the direct effect across time points. This recursive formulation allows us to employ a similar plug-in method as in Section 3 to estimate DE, as well as a similar bootstrap approach for inference. To estimate IE, we first compute the total effect as a byproduct of the proposed procedure in Section 3. We then estimate IE as the difference between the estimated total effect and DE. Again, we can employ the bootstrap approach to infer IE.
Our definition of the individual mediation effect is concerned with the marginal effect,
which marginalizes over the history for all . This marginalization is appropriate because our interventions on the treatment and mediator at time do not causally influence those historical variables. Henceforth, the distribution of those historical variables remains unchanged before and after the intervention. Meanwhile, it may be of separate interest to study the conditional effect,
given the history. Nevertheless, we note that, under the linear structural model, the conditional effect is equivalent to the marginal effect that we target in this article. We next sketch a few lines to show the equivalence. Specifically, the first term is in our current definition. It is the partial coefficient of by linearly regressing on given the historical variables that could affect the distribution of . Under the linear model structures (3) and (4), the effects of and the historical variables on are additive. Consequently, the resulting conditional effect remains the same as the marginal effect, regardless of the values of the historical variables. The second term is . Again, the value remains the same whether or not conditioning on the historical variables. Similarly, under (3) and (4), the effects of and the historical variables on are additive. Consequently, the value of the product remains the same, regardless of whether the history is included in the conditioning set or not.
6.4. Extension to varying and time lags.
Finally, we remark that our method can be adapted to accommodate the setting when the number of time points varies among subjects, and when the time lags between two time points differ.
For the finite-horizon setting, can be different for different subjects, because the model parameters and intermediate quantities at any given time are estimated by pooling the data across subjects who have observations available at that time point. Besides, Theorem 3 remains valid when varies across subjects, provided that the sample size at each time point is sufficiently large. Meanwhile, for the time lag between two time points, we require it to follow the same distribution across all subjects, but it does not need to follow the same distribution across all time points, since we allow the data generating process to be nonstationary over time.
For the infinite-horizon setting, again can be different, because the data are pooled across both subjects and time points. Similarly, Theorem 4 remains valid when varies across subjects, provided that the total sample size is sufficiently large. Meanwhile, the time lag between two time points needs to follow the same distribution, due to the requirement for stationarity for the infinite-horizon setting. However, this requirement does not extend to between subjects, and the distributions can vary among different subjects. In that case, we can use each subject’s own data to estimate their subject-specific mediation effects.
Supplementary Material
Supplement to “Multivariate dynamic mediation analysis under a reinforcement learning framework” (DOI: 10.1214/24-AOS2475SUPP; .pdf). The supplement provides the proofs of the main theorems in the paper.
Acknowledgments.
Lan Luo, Chengchun Shi and Jitao Wang contributed equally. The authors are grateful for the contributions of the researchers, administrators and participants involved in the Intern Health Study (https://clinicaltrials.gov/study/NCT03972293). The authors also thank the Editor, Associate Editor and reviewers for their comments, which have led to substantial improvements of the manuscript.
Funding.
Luo’s research was partly supported by NIH Grant R21AG083364.
Shi’s research was supported in part by the EPSRC Grant EP/W014971/1.
Wu’s work was partly supported by NIH Grants R01 MH101459 and R01 NR013658.
Li’s research was partially supported by NSF Grant CIF-2102227, and NIH Grants R01AG062542 and R01AG080043.
REFERENCES
- Baron RM and Kenny DA (1986). The moderator-mediator variable distinction in social psychological research: Conceptual, strategic, and statistical considerations. J. Pers. Soc. Psychol 51 1173–1182. 10.1037//0022-3514.51.6.1173 [DOI] [PubMed] [Google Scholar]
- Bello K, Aragam B and Ravikumar P (2022). DAGMA: Learning DAGs via M-matrices and a log-determinant acyclicity characterization. arXiv preprint. Available at arXiv:2209.08037. [Google Scholar]
- Bi X, Yang L, Li T, Wang B, Zhu H and Zhang H (2017). Genome-wide mediation analysis of psychiatric and cognitive traits through imaging phenotypes. Hum. Brain Mapp 38 4088–4097. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Boca SM, Sinha R, Cross AJ, Moore SC and Sampson JN (2014). Testing multiple biological mediators simultaneously. Bioinformatics 30 214–220. 10.1093/bioinformatics/btt633 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Bradley RC (2005). Basic properties of strong mixing conditions. A survey and some open questions. Probab. Surv 2 107–144. Update of, and a supplement to, the 1986 original MR2178042 10.1214/154957805100000104 [DOI] [Google Scholar]
- CAI H, Song R and Lu W (2021). ANOCE: Analysis of causal effects with multiple mediators via constrained structural learning. In International Conference on Learning Representations. [Google Scholar]
- Cai X, Coffman DL, Piper ME and Li R (2022). Estimation and inference for the mediation effect in a time-varying mediation model. BMC Med. Res. Methodol 22 113. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Celli V (2022). Causal mediation analysis in economics: Objectives, assumptions, models. J. Econ. Surv 36 214–234. [Google Scholar]
- Chakrabortty A, Nandy P and Li H (2018). Inference for individual mediation effects and interventional effects in sparse high-dimensional causal graphical models. arXiv preprint. Available at arXiv:1809.10652. [Google Scholar]
- Díaz I, Williams N and Rudolph KE (2023). Efficient and flexible mediation analysis with time-varying mediators, treatments, and confounders. J. Causal Inference 11 Paper No. 20220077, 17. MR4610658 10.1515/jci-2022-0077 [DOI] [Google Scholar]
- Djordjilović V, Hemerik J and Thoresen M (2022). On optimal two-stage testing of multiple mediators. Biom. J 64 1090–1108. MR4476372 10.1002/bimj.202100190 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Efron B (1979). Bootstrap methods: Another look at the jackknife. Ann. Statist 7 1–26. MR0515681 [Google Scholar]
- Ge L, Wang J, Shi C, Wu Z and Song R (2023). A reinforcement learning framework for dynamic mediation analysis. arXiv preprint. Available at arXiv:2301.13348. [Google Scholar]
- Granger CW (1969). Investigating causal relations by econometric models and cross-spectral methods. Econometrica 424–438. [Google Scholar]
- Guo X, Li R, Liu J and Zeng M (2023). Statistical inference for linear mediation models with high-dimensional mediators and application to studying stock reaction to COVID-19 pandemic. J. Econometrics 235 166–179. MR4580425 10.1016/j.jeconom.2022.03.001 [DOI] [Google Scholar]
- Hao B, Ji X, Duan Y, Lu H, Szepesvari C and Wang M (2021). Bootstrapping fitted q-evaluation for off-policy inference. In International Conference on Machine Learning 4074–4084. PMLR. [Google Scholar]
- Hejazi NS, Rudolph KE, van der Laan MJ and Díaz I (2023). Nonparametric causal mediation analysis for stochastic interventional (in)direct effects. Biostatistics 24 686–707. MR4615248 10.1093/biostatistics/kxac002 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Hu Y and Wager S (2022). Switchback experiments under geometric mixing. arXiv preprint. Available at arXiv:2209.00197. [Google Scholar]
- Huang J and Yuan Y (2017). Bayesian dynamic mediation analysis. Psychol. Methods 22 667–686. [DOI] [PubMed] [Google Scholar]
- Huang Y-T and Pan W-C (2016). Hypothesis test of mediation effect in causal mediation model with high-dimensional continuous mediators. Biometrics 72 402–413. MR3515767 10.1111/biom.12421 [DOI] [PubMed] [Google Scholar]
- Hyvärinen A, Zhang K, Shimizu S and Hoyer PO (2010). Estimation of a structural vector autoregression model using non-Gaussianity. J. Mach. Learn. Res 11 1709–1731. MR2653353 [Google Scholar]
- Kallus N and Uehara M (2022). Efficiently breaking the curse of horizon in off-policy evaluation with double reinforcement learning. Oper. Res 70 3282–3302. MR4538517 [Google Scholar]
- Kaufman JS and Kaufman S (2001). Assessment of structured socioeconomic effects on health. Epidemiology 12 157–167. 10.1097/00001648-200103000-00006 [DOI] [PubMed] [Google Scholar]
- Li M, Shi C, Wu Z and Fryzlewicz P (2022). Testing stationarity and change point detection in reinforcement learning. arXiv preprint. Available at arXiv:2203.01707. [Google Scholar]
- Liao P, Klasnja P and Murphy S (2021). Off-policy estimation of long-term average outcomes with applications to mobile health. J. Amer. Statist. Assoc 116 382–391. MR4227701 10.1080/01621459.2020.1807993 [DOI] [Google Scholar]
- Liao P, Qi Z, Wan R, Klasnja P and Murphy SA (2022). Batch policy learning in average reward Markov decision processes. Ann. Statist 50 3364–3387. MR4524500 10.1214/22-aos2231 [DOI] [Google Scholar]
- Lin S-H, Young JG, Logan R and VanderWeele TJ (2017). Mediation analysis for a survival outcome with time-varying exposures, mediators, and confounders. Stat. Med 36 4153–4166. MR3713656 10.1002/sim.7426 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Liu W, Tu J, Zhang Y and Chen X (2023). Online Estimation and Inference for Robust Policy Evaluation in Reinforcement Learning. arXiv preprint. Available at arXiv:2310.02581. [Google Scholar]
- Luckett DJ, Laber EB, Kahkoska AR, Maahs DM, Mayer-Davis E and Kosorok MR (2020). Estimating dynamic treatment regimes in mobile health using V-learning. J. Amer. Statist. Assoc 115 692–706. MR4107673 10.1080/01621459.2018.1537919 [DOI] [Google Scholar]
- Luo L, Shi C, Wang J, Wu Z and Li L (2025). Supplement to “Multivariate Dynamic Mediation Analysis under a Reinforcement Learning Framework.” 10.1214/24-AOS2475SUPP [DOI] [Google Scholar]
- Maathuis MH, Kalisch M and Bühlmann P (2009). Estimating high-dimensional intervention effects from observational data. Ann. Statist 37 3133–3164. MR2549555 10.1214/09-AOS685 [DOI] [Google Scholar]
- MacKinnon DP (2008). Introduction to Statistical Mediation Analysis. Taylor & Francis, London. [Google Scholar]
- Malinsky D and Spirtes P (2018). Causal structure learning from multivariate time series in settings with unmeasured confounding. In Proceedings of 2018 ACM SIGKDD Workshop on Causal Discovery 23–47. PMLR. [Google Scholar]
- Mnih V, Kavukcuoglu K, Silver D, Rusu AA, Veness J, Bellemare MG, Graves A, Riedmiller M, Fidjeland AK et al. (2015). Human-level control through deep reinforcement learning. Nature 518 529–533. [DOI] [PubMed] [Google Scholar]
- Murphy SA (2003). Optimal dynamic treatment regimes. J. R. Stat. Soc. Ser. B. Stat. Methodol 65 331–355. MR1983752 10.1111/1467-9868.00389 [DOI] [Google Scholar]
- Nandy P, Maathuis MH and Richardson TS (2017). Estimating the effect of joint interventions from observational data in sparse high-dimensional settings. Ann. Statist 45 647–674. MR3650396 10.1214/16-AOS1462 [DOI] [Google Scholar]
- NeCamp T, Sen S, Frank E, Walton MA, Ionides EL, Fang Y, Tewari A and Wu Z (2020). Assessing real-time moderation for developing adaptive mobile health interventions for medical interns: Microrandomized trial. J. Med. Internet Res 22 e15033. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Pamfil R, Sriwattanaworachai N, Desai S, Pilgerstorfer P, Georgatzis K, Beaumont P and Aragam B (2020). Dynotears: Structure learning from time-series data. In International Conference on Artificial Intelligence and Statistics 1595–1605. PMLR. [Google Scholar]
- Pearl J (2000). Causality: Models, Reasoning, and Inference. Cambridge Univ. Press, Cambridge. MR1744773 [Google Scholar]
- Pearl J (2012). The causal mediation formula—a guide to the assessment of pathways and mechanisms. Prev. Sci 13 426–436. [DOI] [PubMed] [Google Scholar]
- Peters J and Bühlmann P (2014). Identifiability of Gaussian structural equation models with equal error variances. Biometrika 101 219–228. MR3180667 10.1093/biomet/ast043 [DOI] [Google Scholar]
- Preacher KJ (2015). Advances in mediation analysis: A survey and synthesis of new developments. Annu. Rev. Psychol 66 825–852. 10.1146/annurev-psych-010814-015258 [DOI] [PubMed] [Google Scholar]
- Puterman ML (1994). Markov Decision Processes: Discrete Stochastic Dynamic Programming. Wiley Series in Probability and Mathematical Statistics: Applied Probability and Statistics. Wiley, New York. A Wiley-Interscience Publication. MR1270015 [Google Scholar]
- QIN ZT, ZHU H and Ye J (2021). Reinforcement learning for ridesharing: A survey. In 2021 IEEE International Intelligent Transportation Systems Conference (ITSC) 2447–2454. IEEE Press, New York. [Google Scholar]
- Ramprasad P, Li Y, Yang Z, Wang Z, Sun WW and Cheng G (2023). Online bootstrap inference for policy evaluation in reinforcement learning. J. Amer. Statist. Assoc 118 2901–2914. MR4681629 10.1080/01621459.2022.2096620 [DOI] [Google Scholar]
- Rucker DD, Preacher KJ, Tormala ZL and Petty RE (2011). Mediation analysis in social psychology: Current practices and new recommendations. Soc. Pers. Psychol. Compass 5 359–371. [Google Scholar]
- Sampson JN, Boca SM, Moore SC and Heller R (2018). FWER and FDR control when testing multiple mediators. Bioinformatics 34 2418–2424. 10.1093/bioinformatics/bty064 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Selig JP and Preacher KJ (2009). Mediation models for longitudinal data in developmental research. Res. Hum. Dev 6 144–164. [Google Scholar]
- Shaffer F and Ginsberg JP (2017). An overview of heart rate variability metrics and norms. Front. Public Health 5 258. 10.3389/fpubh.2017.00258 [DOI] [PMC free article] [PubMed] [Google Scholar]
- SHI C and LI L. (2022). Testing mediation effects using logic of Boolean matrices. J. Amer. Statist. Assoc 117 2014–2027. MR4528486 10.1080/01621459.2021.1895177 [DOI] [Google Scholar]
- Shi C, Zhang S, Lu W and Song R (2022). Statistical inference of the value function for reinforcement learning in infinite-horizon settings. J. R. Stat. Soc. Ser. B. Stat. Methodol 84 765–793. MR4460575 [Google Scholar]
- Shuai K, Liu L, He Y and Li W (2023). Mediation pathway selection with unmeasured mediator-outcome confounding. arXiv preprint. Available at arXiv:2311.16793. [Google Scholar]
- Silver D, Schrittwieser J, Simonyan K, Antonoglou I, Huang A, Guez A, Hubert T, BAKER L, LAI M et al. (2017). Mastering the game of go without human knowledge. Nature 550 354–359. [DOI] [PubMed] [Google Scholar]
- Sutton RS and Barto AG (2018). Reinforcement Learning: An Introduction, 2nd ed. Adaptive Computation and Machine Learning. MIT Press, Cambridge, MA. MR3889951 [Google Scholar]
- VanderWeele TJ (2016). Mediation analysis: A practitioner’s guide. Annu. Rev. Public Health 37 17–32. 10.1146/annurev-publhealth-032315-021402 [DOI] [PubMed] [Google Scholar]
- VanderWeele TJ and Tchetgen Tchetgen EJ (2017). Mediation analysis with time varying exposures and mediators. J. R. Stat. Soc. Ser. B. Stat. Methodol 79 917–938. MR3641414 10.1111/rssb.12194 [DOI] [Google Scholar]
- Wang J, QI Z and Wong RKW (2023). Projected state-action balancing weights for offline reinforcement learning. Ann. Statist 51 1639–1665. MR4658571 10.1214/23-aos2302 [DOI] [Google Scholar]
- Wang J, Shi C and Wu Z (2023). A robust test for the stationarity assumption in sequential decision making. In International Conference on Machine Learning 36355–36379. PMLR. [Google Scholar]
- Wei H, Cai H, Shi C and Song R (2024). On efficient inference of causal effects with multiple mediators. arXiv preprint. Available at arXiv:2401.05517. [Google Scholar]
- Wright S (1921). Correlation and causation. J. Agric. Res 20 557–585. [Google Scholar]
- Yuan Y and Qu A (2024). De-confounding causal inference using latent multiple-mediator pathways. J. Amer. Statist. Assoc 119 2051–2065. MR4797922 10.1080/01621459.2023.2240461 [DOI] [Google Scholar]
- Yuan Y, Shen X, Pan W and Wang Z (2019). Constrained likelihood for reconstructing a directed acyclic Gaussian graph. Biometrika 106 109–125. MR3912386 10.1093/biomet/asy057 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Zhang H, Chen X and Yang LF (2023). Adaptive liquidity provision in uniswap V3 with deep reinforcement learning. arXiv preprint. Available at arXiv:2309.10129. [Google Scholar]
- Zhang H, Zheng Y, Zhang Z, Gao T, Joyce B, Yoon G, Zhang W, Schwartz J, Just A et al. (2016). Estimating and testing high-dimensional mediation effects in epigenetic studies. Bioinformatics 32 3150–3154. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Zhao Y, Li L and Initiative, A. D. N. (2022). Multimodal data integration via mediation analysis with high-dimensional exposures and mediators. Hum. Brain Mapp 43 2519–2533. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Zhao Y and Luo X (2022). Pathway Lasso: Pathway estimation and selection with high-dimensional mediators. Stat. Interface 15 39–50. MR4305014 10.4310/21-SII673 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Zhao Y, Luo X, Lindquist M and Caffo B (2018). Functional mediation analysis with an application to functional magnetic resonance imaging data. arXiv preprint. Available at arXiv:1805.06923. [Google Scholar]
- Zheng W and van der Laan M (2017). Longitudinal mediation analysis with time-varying mediators and exposures, with application to survival outcomes. J. Causal Inference 5 Art. No. 20160006, 24. MR4328877 10.1515/jci-2016-0006 [DOI] [Google Scholar]
- Zheng X, Aragam B, Ravikumar PK and Xing EP (2018). Reinforcement learning for ridesharing: A survey. DAGs with NO TEARS: Continuous optimization for structure learning. In In Advances in Neural Information Processing Systems 9472–9483. [Google Scholar]
Associated Data
This section collects any data citations, data availability statements, or supplementary materials included in this article.
