EconBase
← Back to paper

Difference-in-Differences Models in the Presence of Time-Varying Mediators

The exact contents of citations.db main_text.text for this paper — one flattened LaTeX string, title through conclusion, appendix excluded, unmodified except for removing email addresses. This is what our citation measures are computed over.

72,544 characters

Difference-in-Differences Models in the Presence of Time-Varying Mediators


\begin{titlepage}
\nonstopmode

\title[DiD Models in the Presence of Time-Varying Mediators]{Difference-in-Differences Models in the Presence of Time-Varying Mediators}
\author{Kyunghoon Ban, Zhengrun Chen, and D\'esir\'e K\'edagni}
\address{Rochester Institute of Technology and UNC-Chapel Hill}
\noindent \date{\scriptsize{The present version is as of \today. We thank Bocar Ba, Jane Fruehwirth, Martin Huber, Valentin Verdier, and participants at the UNC econometrics workshop, the 2025 SEA Meeting, the 2026 AfES conference, seminar participants at Rensselaer Polytechnic Institute for helpful comments.
All errors are ours.
Kyunghoon Ban ([email removed]);
Zhengrun Chen ([email removed]);
D\'esir\'e K\'edagni ([email removed])}}

\begin{abstract}
{
We study difference-in-differences (DiD) designs in which a binary treatment changes an endogenous time-varying (continuous, discrete, or mixed) mediator that in turn affects an outcome. Under our model assumptions, we show that the usual DiD estimand mixes the average direct effect on the treated, the average indirect effect, and a trend bias term. A two-way fixed effects (TWFE) regression that controls for the mediator does not recover the average direct treatment effect on the treated. We show that a DiD estimand conditional on the observed mediator path identifies the conditional average direct effect for treated units at that path, and that averaging over the treated path distribution identifies the average direct effect even when unconditional parallel trends fails. A stable average mediator effect assumption helps recover the average mediator and indirect effects. The framework extends to multivariate mediators, nonlinear DiD, and multiple treatment periods settings. Existing doubly robust estimators can be used to conduct inference. Revisiting the effects of railroad access on agricultural land values, the specification yields a positive direct component not mediated by measured market access, while the corresponding indirect component is small and imprecise. A TWFE benchmark with the same sample and baseline geographic covariates gives a small, imprecise direct coefficient, whereas the original-control TWFE coefficient reverses sign.

}
\end{abstract}
\maketitle

{\footnotesize \textbf{Keywords}: Difference-in-differences, endogenous time-varying covariates, causal mediation.

\textbf{JEL subject classification}: C14, C31, C35, C36.}

\end{titlepage}


\section{Introduction}

{

The use of difference-in-differences (DiD) models in economics and social sciences has increased rapidly in recent years. The method relies on a key assumption called parallel trends. The presence of mediators could compromise the validity of this assumption. In this paper, we study identification in DiD models when mediators are present.
We study this problem for a binary treatment and a mediator that may be continuous, discrete, or mixed, may vary over time, and may be related to unobserved determinants of the outcome.

More specifically, to provide some intuition behind our main research question of interest, consider the following model
\begin{equation*}
\left\{
\begin{array}{lcl}
Y_{it}&=&\theta_{it}D_{it}+\beta_{it}M_{it}+\lambda_i+\eta_t+U_{it},\\[0.2cm]
M_{it}&=&\psi_t(D_{it},\gamma_i,\tilde{V}_{it}),\\[0.2cm]
D_{it}&=&h_t(\lambda_i,\gamma_i,\varepsilon_{it}),
\end{array}
\right.
\end{equation*}
where the vector $(\{Y_{it},D_{it},M_{it}\}_{i\in\mathcal N, t\in \mathcal T})$ is observed, while everything else is unobserved/unknown.
In the specification above, $Y_{it}$ is the outcome, $M_{it}$ is the mediator, and $D_{it}$ is the treatment.\footnote{Throughout the paper, we assume that no individual receives the treatment in the baseline period, i.e., $D_{i0}=0$ a.s. So, in the canonical DiD setting, our focus is on the treatment $D_{i1}=D_i$.}  The outcome equation contains a random direct effect of treatment $\theta_{it}$, a random effect of the mediator on the outcome $\beta_{it}$, individual fixed effects $\lambda_i$, time effects $\eta_t$, and idiosyncratic shocks $U_{it}$.  The mediator, which can be continuous, discrete or mixed, is specified as an unknown function $\psi_t$ of a vector of unobservables $\tilde{V}_{it}$ , its own individual fixed effect $\gamma_i$, where the function $\psi_t$ can change arbitrarily over time.  Treatment selection is allowed to depend on the fixed effects in both the outcome and mediator equations and on an additional unobservable random shock $\varepsilon_{it}$, through an unknown function $h_t$.  The outcome and mediator fixed effects may be arbitrarily dependent (e.g., a special case is common fixed effects, $\lambda_i=\gamma_i$).  The direct effect is heterogeneous and may depend on the mediator path. The mediator effect on the outcome may also vary across individuals and over time. In this paper, we are interested in measuring the direct effect of treatment $D_{it}$ on the outcome $Y_{it}$, that is, we want to learn about some features of $\theta_{it}$.

There are many empirical examples where there is a mediator between the treatment and the outcome of interest. For example, an expansion of health insurance (Medicare or Medicaid) can affect health conditions both directly and indirectly through preventive care. Also, a school reform such as an introduction of a new curriculum can affect wages directly and indirectly through educational attainment, or a local regulation may affect productivity directly and indirectly through asset values, input prices, or labor-market conditions. In these examples, the mediator is not an ordinary pre-treatment covariate but a post-treatment object whose distribution may be changed by the policy and affected by unobserved determinants of the outcome of interest. Consequently, simply controlling for it in a two-way fixed effects regression will generally induce some bias in the attempt to isolate the direct effect.


To illustrate the main idea behind our identification approach, we start from the canonical two-period, two-group DiD design. We first highlight the fact that the standard parallel trends assumption for the untreated outcome may not hold under our proposed framework and the set of assumptions we consider. Even when the idiosyncratic shocks satisfy independence restrictions, treated and untreated units can have different untreated outcome trends because they have different mediator fixed effects and because the average return to the mediator may change over time. Second, we emphasize that a TWFE regression controlling for the mediator generally fails to recover the average direct treatment effect on the treated because residualizing the treatment with respect to the mediator mechanically changes the estimand. Hence, the resulting coefficient generally mixes the direct effect with terms that depend on mediator effect heterogeneity and treatment-induced mediator changes.

Afterwards, we carefully propose a different route. We consider the difference between outcome changes for treated and untreated units, conditional on the full observed mediator path $(M_{i0},M_{i1})$. Then, we show that, under a DiD analogue of the sequential ignorability assumption considered in \cite{imai2010identification}, this path-conditional DiD estimand identifies the conditional average direct treatment effect on the treated, denoted $CADTT$. Averaging this conditional estimand over the mediator path distribution of treated units identifies the average direct treatment effect on the treated, $ADTT$.  Importantly, this result does not require the standard unconditional parallel trends assumption and is not a standard conditional parallel trends argument with a post-treatment covariate.

Furthermore, we clarify that the standard DiD estimand can be decomposed into average direct and indirect effects plus a bias term that vanishes when the standard parallel trends assumption holds, which can be implied when the average effect of the mediator on the outcome is stable across periods under our framework. Since the direct effect is identified by the path-conditional DiD approach, the average indirect effect can consequently be identified. Accordingly, the average mediator effect on the outcome of interest can be identified as well when the treatment effect on the mediator is identified from a DiD estimand for the mediator.

The mediator path argument also extends to multiple treatment periods \citep{callaway2021difference, dechaisemartin2020two}, staggered adoption as well as nonstaggered adoption.
For estimation, the identified $ADTT$ can be written as the integral of a conditional DiD estimand, where the conditioning variables are the pre- and post-treatment mediator values, with respect to the observed mediator path distribution for the treated group.  We therefore use the doubly robust (DR) DiD estimator of \cite{sant2020doubly}, applied with the mediator path as the conditioning vector.


This paper is related to several branches of the literature. First, it contributes to the causal mediation analysis. Classical mediation analysis studies decompositions of total effects into direct and indirect components and highlights that mediator endogeneity is a fundamental obstacle \citep{robins1992identifiability, pearl2001direct, imai2010identification}. Identification has been based on selection-on-observables assumptions, with the literature developing sensitivity analyses, nonparametric identification results, decompositions allowing interaction between treatment and the mediator, and machine-learning-based estimators \citep{vanderweele2014unification,celli2022causal,farbmacher2022causal}. In contrast, we allow selection into treatment through unobserved fixed effects and exploit within-unit changes through the DiD structure, while explicitly allowing the mediator to be time-varying, endogenous, and affected by the treatment.

Second, our paper is more closely related to recent work on mediation in DiD designs. \cite{deuchert2019direct} propose a DiD approach for direct and indirect effects with a binary mediator in principal strata. \cite{hsia2025causal} develop mediation analysis for DiD and panel data under common-trend-type assumptions and linear/additive specifications. More relatedly, \cite{schenk2024mediation} studies direct and indirect effects in DiD designs in the presence of a binary time-varying mediator. His identification approach relies on a set of parallel trends assumptions for the outcome and mediator, and mean independence of the treatment with respect to the untreated mediator. Our framework, on the other hand, allows for continuous, discrete, or mixed mediators. We also allow for dependence between the potential mediators and the treatment. Furthermore, \cite{huber2026difference} propose a DiD mediation framework for multivalued discrete or continuous treatments and mediators using conditional parallel trends and double/debiased machine learning. In their setting, the mediator is time-invariant, while it is time-varying in our framework.

Third, our analysis contributes to work on treatment-affected covariates in panel treatment effect models. Exogenous time-varying covariates can make parallel trends more plausible, but including endogenous time-varying covariates as controls in a TWFE regression can alter the TWFE estimand and introduce some bias when the treatment changes those covariates. Notably, \cite{caetano2024difference} formalizes several problems with TWFE regressions under conditional parallel trends, including a hidden linearity bias. \cite{brown2026direct} develop a panel approach with interactive fixed effects that permits treatment-affected covariates and separates the part of the estimated treatment effect due to the covariates from the part that is not. Our approach shares the view that treatment-affected variables should not be handled as ordinary controls. The difference is that we explicitly interpret such a variable as a mediator and identify direct and indirect effects for treated units.

Finally, our paper connects to extensions of DiD beyond the mean and linear models. Our nonlinear extension is in the spirit of changes-in-changes and nonlinear DiD approaches that identify counterfactual outcome distributions under restrictions on latent shocks rather than mean parallel trends \citep{athey2006identification,wooldridge2023simple,kim2025difference}. In our setting, the nonlinear argument is applied conditionally on the mediator path, which identifies distributional and quantile versions of direct effects. We also extend the baseline framework to multivariate mediators.

The rest of the paper proceeds as follows. Section \ref{anaF} sets out the baseline model and causal parameters. Section \ref{sec:baseline-id} derives the conventional estimand diagnostics and the mediator-path identification result, and Section \ref{sec:po-framework} restates that result in potential outcome notation. Section \ref{sec:extensions} treats multivariate mediators, nonlinear outcomes, and multiple treatment periods. Section \ref{sec:empirical} reports the railroad application, followed by the a summary and discussion in Section \ref{Conclusion}.
}



\section{Baseline structural framework}\label{anaF}
We first consider a canonical two-group, two-period DiD design. Individuals $i$ are observed in a baseline period $t=0$ and a post-treatment period $t=1$. Let $D_i\in\{0,1\}$ denote treatment-group status, $M_{it}$ a continuous mediator, and $Y_{it}$ the outcome. The model is specified as follows:
\begin{eqnarray}\label{seq1}
\left\{ \begin{array}{lcl}
     Y_{it} &=& \theta_i t D_i +\beta_{it} M_{it} + \lambda_i +\eta_t +U_{it},\\ \\
     M_{it} &=& \alpha_{i}t D_i+\gamma_i + \delta_t + V_{it},\\ \\
     D_i &=& h(\lambda_i,\gamma_i,\varepsilon_i),
     \end{array} \right.
\end{eqnarray}
where $t \in\{0,1\},$ the vector $(Y_{i0}, Y_{i1}, M_{i0}, M_{i1}, D_i)$ represents the observed data for each individual $i$, while the vector $\left(\theta_i, \alpha_i, \lambda_i, \gamma_i, \varepsilon_i, \{\beta_{it}, U_{it}, V_{it}\}_{t=0,1}\right)$ is latent. $\eta_t$ and $\delta_t$ are nonrandom time effects, $\lambda_i$ and $\gamma_i$ are time-invariant individual heterogeneity in the outcome and mediator equations, and $U_{it}$ and $V_{it}$ are time-varying shocks. $\theta_i$ is the direct effect of the treatment on the outcome $Y_{i1}$ in period 1, $\alpha_i$ is the effect of the treatment on the mediator $M_{i1}$,  and $\beta_{it}$ is the effect of $M_{it}$ on the outcome $Y_{it}$. Treatment status is determined by the selection equation $D_i=h(\lambda_i,\gamma_i,\varepsilon_i)$, where $h$ is an unknown function and $\varepsilon_i$ is an additional latent unobservable. Selection into treatment therefore depends on both $\lambda_i$ and $\gamma_i$, allowing individuals to sort into treatment on unobserved determinants of both the outcome and the mediator.


In this model, we allow the direct treatment effect to depend flexibly on the mediator path, i.e., $\theta_i\equiv \tilde{\theta}_i(M_{i0},M_{i1})$. The dependence between the fixed effects $\lambda_i$ and $\gamma_i$ is left unrestricted (e.g., $\lambda_i=\gamma_i$ is permitted). Moreover, the model allows the effect of the mediator on the outcome (i.e., $\beta_{it}$) to vary across individuals and over time.

In the potential outcomes framework, let $M_{it}(d)$ denote the potential mediator under treatment $d$, and let $Y_{it}(d,m)$ be the potential outcome under treatment $d$ and mediator $m$. We write $Y_{it}(d)\equiv Y_{it}(d,M_{it}(d))$ and define $Y_{it}(d,M_{it}(d'))$ as the cross-world potential outcome, where the treatment is set to $d$ and the mediator is held at its value under treatment $d'$. Model \eqref{seq1} then yields
\begin{eqnarray*}
    Y_{it}(d) &\equiv& Y_{it}(d,M_{it}(d))= \theta_i t d + \beta_{it} M_{it}(d) +\lambda_i + \eta_t + U_{it},\\
    Y_{it}(d,M_{it}(d')) &\equiv& \theta_i t d + \beta_{it} M_{it}(d') +\lambda_i + \eta_t + U_{it},\\
           M_{it}(d) &\equiv& \alpha_i t d + \gamma_i + \delta_t + V_{it}.
\end{eqnarray*}
Note that the above model implies that there are no anticipatory effects of the treatment in the baseline period 0, i.e., $Y_{i0}(0)=Y_{i0}(1)$ and $M_{i0}(0)=M_{i0}(1)$. This no-anticipation restriction is standard in DiD models. Using this potential outcome notation, we define the causal parameters of interest.


\begin{definition} The average total, direct, and indirect treatment effects on the treated in period 1 are defined as
\begin{align*}
ATT  &\equiv \mathbb E[Y_{i1}(1,M_{i1}(1))-Y_{i1}(0,M_{i1}(0))\mid D_i=1],\\
ADTT(d) &\equiv \mathbb E[Y_{i1}(1,M_{i1}(d))-Y_{i1}(0,M_{i1}(d))\mid D_i=1],\\
AITT(d) &\equiv \mathbb E[Y_{i1}(d,M_{i1}(1))-Y_{i1}(d,M_{i1}(0))\mid D_i=1],
\end{align*}
for $d\in\{0,1\}$.
\end{definition}

These correspond to the natural direct and indirect treatment effects studied in the causal mediation literature  \citep{pearl2001direct,imai2010identification}, restricted to the treated subpopulation. $ADTT(d)$ captures the effect of changing treatment status while holding the mediator at its potential value $M_{i1}(d)$, and $AITT(d)$ is the effect of the treatment-induced change in the mediator while holding treatment fixed at $d$. By construction,
\begin{equation*}
ATT = ADTT(d) + AITT(1-d).
\end{equation*}
Model \eqref{seq1}  is additively separable in the direct and indirect channels: for each $d$, $Y_{i1}(1,M_{i1}(d))-Y_{i1}(0,M_{i1}(d))=\theta_{i}$, and $Y_{i1}(d,M_{i1}(1))-Y_{i1}(d,M_{i1}(0))=\beta_{i1}\alpha_i$.
Thus, the direct effect is invariant to the mediator value at which it is evaluated, while the indirect effect is invariant to the treatment level. Consequently,
\begin{align*}
ADTT(1) & = ADTT(0) = \mathbb{E}[\theta_i\mid D_i=1],\\
AITT(1) & = AITT(0) = \mathbb{E}[\beta_{i1}\alpha_i\mid D_i=1],
\end{align*} and $$ATT =\mathbb{E}[\theta_i\mid D_i=1] + \mathbb{E}[\beta_{i1}\alpha_i\mid D_i=1].$$
We therefore suppress the argument $d$ and write $ADTT$ and $AITT$ throughout. This additive separability of the two channels plays an important role in identifying these effects.


\section{Identification: conventional estimands and mediator path DiD}\label{sec:baseline-id}
In this section, we state the main identifying assumptions and then present the baseline identification results.  All identification results hold conditional on exogenous time-invariant covariates vector $X_i$ such that $X_i(0)=X_i(1)=X_i$.

\subsection{Identifying assumptions}
\begin{assumption}[Exogenous fixed effects]\label{ass1p}
    $(\lambda_i, \gamma_i,\varepsilon_i)\ \rotatebox[origin=c]{90}{$\models$}\ (\{V_{it},U_{it},\beta_{it}\}_{t=0,1},\alpha_i)$
\end{assumption}

\begin{assumption}[Conditional independence]\label{ass2p}
    $(\{V_{it}\}_{t=0,1},\alpha_i)\ \rotatebox[origin=c]{90}{$\models$}\ (\{U_{it},\beta_{it}\}_{t=0,1})\vert (\lambda_i,\gamma_i,\varepsilon_i)$
\end{assumption}
Assumption \ref{ass1p} requires the unobservables driving selection into treatment, ($\lambda_i,\gamma_i,\varepsilon_i$), to be independent of all other unobservables in the model except the direct effect $\theta_i$.  By allowing $\theta_i$ to depend on selection unobservables, the model permits selection on the direct gain from treatment.
Assumption \ref{ass2p} further requires that, conditional on the selection unobservables, the latent components in the mediator equation are independent of those in the outcome equation, again except for $\theta_i$.

Together, Assumptions \ref{ass1p} and \ref{ass2p} can be viewed as a DiD analogue of the sequential ignorability assumption in \cite{imai2010identification}. They imply that, aside from the direct effect $\theta_i$, dependence between the mediator and the outcome arises only through the fixed effects $\lambda_i$ and $\gamma_i$. In particular, they rule out time-varying unobservables that jointly affect the mediator and the outcome. These assumptions yield the implications stated in Lemma \ref{lem:uncond_indep} below.


\begin{lemma}\label{lem:uncond_indep}
    Assumptions \ref{ass1p} and \ref{ass2p} imply the following:
                        $$(\{U_{it},\beta_{it}\}_{t=0,1})\ \rotatebox[origin=c]{90}{$\models$}\ (\{V_{it}\}_{t=0,1},\alpha_i, \lambda_i, \gamma_i,\varepsilon_i)$$
                   \end{lemma}
\begin{proof}
    See Appendix \ref{pf_lem:uncond_indep}.
\end{proof}
Lemma \ref{lem:uncond_indep} is important for proving our main identification results.


\subsection{Why conventional estimands fail}\label{sec:conventional-estimands}


\subsubsection{Standard DiD and the total effect}\label{sec:standard-did-diagnostic}
Let $\Delta Y_i=Y_{i1}-Y_{i0}$ and $\Delta M_i=M_{i1}-M_{i0}$, and define the DiD estimand
$$\tau^{DiD}\equiv \mathbb E[\Delta Y_i\mid D_i=1]-\mathbb E[\Delta Y_i\mid D_i=0]. $$

Under model \eqref{seq1} and Assumptions \ref{ass1p} and \ref{ass2p}, we show that
\begin{equation*}
\tau^{DiD}
=\underbrace{\mathbb E[\theta_i\mid D_i=1]}_{\text{direct}}
+\underbrace{\mathbb E[\beta_{i1}]\,\mathbb E[\alpha_i]}_{\text{indirect}}
+\underbrace{\mathbb E[\beta_{i1}-\beta_{i0}]
\big(\mathbb E[\gamma_i\mid D_i=1]-\mathbb E[\gamma_i\mid D_i=0]\big)}_{\text{parallel-trends bias}}.
\end{equation*}

The last term is due to the violation of the parallel trends assumption,
\begin{align*}
    & \mathbb E[Y_{i1}(0)-Y_{i0}(0)\mid D_i=1]-\mathbb E[Y_{i1}(0)-Y_{i0}(0)\mid D_i=0]\\
=\ & \mathbb E[\beta_{i1}-\beta_{i0}]\big(\mathbb E[\gamma_i\mid D_i=1]-\mathbb E[\gamma_i\mid D_i=0]\big),
\end{align*}
which is nonzero whenever the average mediator effect changes over time and $\gamma_i$ is correlated with treatment status. Hence, $\tau^{DiD}$ generally mixes the direct effect, the indirect effect, and a parallel-trends bias, and has no causal interpretation on its own. When the average mediator effect is stable ($\mathbb E[\beta_{i1}]=\mathbb E[\beta_{i0}]$) or there is no treatment selection on the mediator fixed effects ($\mathbb E[\gamma_i\vert D_i]=\mathbb E[\gamma_i]$), the standard parallel trends assumption holds, the bias vanishes, and the DiD estimand recovers the average total treatment effect on the treated, $\tau^{DiD}=ATT=\mathbb E[\theta_i\mid D_i=1]+\mathbb E[\beta_{i1}]\,\mathbb E[\alpha_i]$.


\subsubsection{TWFE conditioning on $M_{it}$ and the direct effect}\label{sec:twfe-diagnostic}

 A natural question to ask is: does a TWFE estimand that controls for $M_{it}$ identify the direct treatment effect under our model?
 To address this, we consider the following TWFE regression with a scalar mediator $M_{it}$: for $t\in\{0,1\}$,
$$Y_{it}=\pi_1 tD_{i}+\pi_2 M_{it}+\phi_{i}+\zeta_{t}+\xi_{it}$$
where $\phi_i$ is the individual fixed effect, $\zeta_t$ is the time fixed effect, $\pi_1$ and $\pi_2$ are constant coefficients. In practice, the coefficient $\pi_1$ is often interpreted as an average direct treatment effect on the outcome. However, as shown below, it generally combines the true average direct effect with additional bias terms.


To characterize the TWFE estimands, we introduce the following notation. For any random variables $X$ and $Y$, let $\Pi(Y\mid X)$ denote the linear projection of $Y$ onto $X$, i.e., $\Pi(Y\mid X)\equiv \mathbb{E}(Y)+\frac{Cov(X,Y)}{Var(X)}[X-\mathbb{E}(X)]$.  Define the residualized $D_i$ with respect to $\Delta M_i$ as $\widetilde{D}_i\equiv D_i - \Pi(D_i\mid \Delta M_i)$ and the residualized $\Delta M_i$ with respect to $D_i$ as $\widetilde{\Delta M_i} \equiv \Delta M_i - \Pi(\Delta M_i \mid D_i)$.
Then, the TWFE estimands are $\pi_{1}=\frac{Cov(\widetilde{D}_{i},\Delta Y_{i})}{Var(\widetilde{D}_{i})}$, and $\pi_2 =  \frac{Cov(\widetilde{\Delta M_{i}},\Delta Y_{i})}{Var(\widetilde{\Delta M_{i}})}.$\footnote{Throughout this subsection, assume the relevant second moments are finite and the population rank condition holds: $0<Var(D_i)<\infty$, $0<Var(\Delta M_i)<\infty$, $Var(\widetilde{D}_i)>0$, and $Var(\widetilde{\Delta M}_{i})>0$.
Equivalently, after partialling out the mediator change, the treatment regressor has nonzero residual variation, and after partialling out treatment status, the mediator change has nonzero residual variation.}
The following claim shows that each of these estimands can be decomposed into three terms.
\begin{claim}\label{claim:interpretTWFE}
Under model \eqref{seq1}, Assumptions \ref{ass1p} and \ref{ass2p},
the estimands for $\pi_1$ and $\pi_2$ from the above TWFE regression can be decomposed as:
\begin{align*}
\pi_1
= & \ \mathbb{E}(\theta_{i}\mid D_{i}=1)\\
& +\mathbb{E}(\beta_{i1}-\beta_{i0})
\left(
\frac{Cov(D_{i},\gamma_{i})}{Var(\widetilde{D}_{i})}
-
\frac{\mathbb{E}(\alpha_{i})Cov(\Delta M_{i},M_{i0})}
{Var(\widetilde{\Delta M}_{i})}
\right) \tag{A} \label{bias:A} \\
& +\frac{\mathbb{E}(\alpha_{i})}{Var(\widetilde{\Delta M}_{i})}
\big(
\mathbb{E}(\alpha_{i})Cov(D_{i},\theta_{i}D_{i})
-
Cov(\Delta M_{i},\theta_{i}D_{i})
\big) \tag{B}\label{bias:B}.
\end{align*}
\begin{align*}
\pi_2
= & \ \mathbb{E}(\beta_{i1})\\
&  + \frac{\mathbb{E}(\beta_{i1}-\beta_{i0})}
{Var(\widetilde{\Delta M}_{i})}
\Big[
Cov(\Delta M_{i},M_{i0})
-
\mathbb{E}(\alpha_{i})Cov(D_{i},\gamma_{i})
\Big]   \tag{C}\label{bias:C} \\
& + \frac{1}{Var(\widetilde{\Delta M}_{i})}
\Big[
Cov(\Delta M_i,\theta_{i}D_{i})
-
\mathbb{E}(\alpha_i)Cov(D_i,\theta_iD_i)
\Big]. \tag{D} \label{bias:D}
\end{align*}
\end{claim}


Claim \ref{claim:interpretTWFE} shows that TWFE generally fails to identify the average direct treatment effect and the average mediator effects. Instead, the coefficients $\pi_1$ and $\pi_2$ combine the causal parameters of interest with several bias terms; see proof in Appendix \ref{pf_claim:interpretTWFE}.


For $\pi_1$, it can be decomposed into the ADTT and two bias terms. The first bias term (\ref{bias:A}) is driven by differences in the average mediator effects on the outcome across periods. This difference would imply that the evolution of untreated potential outcome will depend on both the level of untreated mediator and its change over time:
$$  \Delta Y_i(0) = \beta_{i1}\Delta M_i(0) + \tilde{\beta}_i M_{i0}(0) + \eta_1-\eta_0 + U_{i1}-U_{i0}$$
where $\tilde{\beta}_i = \beta_{i1}-\beta_{i0}$. However, the TWFE specification implicitly imposes that the evolution depends only on the change in mediators. This feature is analogous to the ``hidden linearity bias''\footnote{In \cite{caetano2024difference}, the ``hidden linearity bias'' arises from the fact that the evolution of untreated potential outcomes depends on time-invariant exogenous covariates, the level of time-varying exogenous covariates, and the change in these covariates, which TWFE regressions fail to capture. Instead, we focus on the endogenous time-varying covariates (mediators), but we can flexibly accommodate both time-invariant and time-varying exogenous covariates in our model.} in \cite{caetano2024difference}. However, unlike their setting, our framework does not suffer from the ``explicit linearity bias'', which arises when the conditional expectation of the change in untreated potential outcomes is nonlinear in the change in mediators over time. In our model, this relationship remains linear. In addition, relative to \cite{caetano2024difference}, our setting introduces an additional bias term (\ref{bias:B}) which is driven by the endogeneity of mediators. This bias appears when the average treatment effect on the mediator is nonzero and the direct treatment effects on the outcome, $\theta_i$, is correlated with other unobserved heterogeneity in the model.

For $\pi_2$, it conflates mediator effects on the outcome from both periods, as captured by the term (\ref{bias:C}), and includes an additional bias term (\ref{bias:D}) driven by the dependence between direct treatment effects $\theta_i$ and other unobserved heterogeneity in the model.

These bias terms disappear only under strong conditions. For example, suppose  $\mathbb{E}(\alpha_i)\neq 0$, if the average mediator effect is time-invariant, i.e., $\mathbb{E}(\beta_{i1})=\mathbb{E}(\beta_{i0})$, and the direct treatment effect on the outcome is independent of both the treatment effect on the mediator and the shocks in the mediator equation, i.e., $\theta_{i}\ \rotatebox[origin=c]{90}{$\models$}\ (\alpha_{i},V_{i1},V_{i0})$, which implies $Cov(\Delta M_i,\theta_{i}D_{i})=\mathbb{E}(\alpha_i)Cov(D_i,\theta_iD_i)$, then the TWFE regression conditional on $M_{it}$ identifies the average direct treatment effect on the treated $\mathbb{E}[\theta_i\mid D_i=1]$, as well as the average mediator effects in period 1, $\mathbb{E}(\beta_{i1})$.

Figure~\ref{fig:simulation_example} provides a Monte Carlo illustration of these results; see the simulation design in Appendix~\ref{apx:simulation_example}. Under this DGP, the true ATT and ADTT equal $2$ and $1$, respectively.
Nevertheless, standard DiD and TWFE estimators produce biased estimates of these parameters, with the sign reversals. This motivates the mediator-path identification strategy discussed in Section \ref{sec:path-id}.


\begin{figure}[!htbp]
  \centering
  \begin{minipage}[t]{0.48\textwidth}
    \centering
    \includegraphics[width=\linewidth]{figures/theta_total_sim_new.pdf}
    {\footnotesize (a) Total effect}
  \end{minipage}\hfill
  \begin{minipage}[t]{0.48\textwidth}
    \centering
    \includegraphics[width=\linewidth]{figures/theta_direct_sim_new.pdf}
    {\footnotesize (b) Direct effect}
  \end{minipage}
  \caption{Monte Carlo simulation of TWFE estimators}
  \label{fig:simulation_example}
  \vspace{0.3em}
  \par\footnotesize\raggedright
  \textit{Notes}: The figure reports the Monte Carlo distribution of the TWFE estimates based on 1000 simulation replications. Panel (a) shows the distribution of the TWFE coefficient on $tD_i$ from a regression of $Y_{it}$ on $tD_i$ with unit and time fixed effects, corresponding to the total effect. Panel (b) shows the distribution of the TWFE coefficient on $tD_i$ from a regression of $Y_{it}$ on $tD_i$ and $M_{it}$ with unit and time fixed effects, which is commonly interpreted as a direct effect. Vertical dashed lines indicate the true ATT in panel (a) and the true ADTT in panel (b).
\end{figure}


\subsection{Identification of direct effects}\label{sec:path-id}

{
The diagnostic results above show that neither the unconditional DiD contrast nor a TWFE regression controlling for the mediator generally recovers the direct effect.
Hence, we propose an alternative approach; condition on the full observed mediator path \((M_{i0},M_{i1})\), construct a DiD contrast within each path, and then average these contrasts over the treated path distribution.
}

Define the conditional DiD estimand as
\begin{eqnarray*}
\tau^{DiD}(m_0,m_1)&\equiv& \mathbb{E}[\Delta Y_i\mid D_i=1,M_{i0}=m_0,M_{i1}=m_1]\\
&&-\ \mathbb{E}[\Delta Y_i\mid D_i=0,M_{i0}=m_0,M_{i1}=m_1]
\end{eqnarray*}

{
\begin{assumption}[Mediator path overlap and regularity]\label{ass:pathoverlap}
The treatment is nondegenerate conditional on the mediator path, $0<\mathbb P(D_i=1\vert M_{i0},M_{i1})<1$ a.s., the relevant first moments are finite.
\end{assumption}
}

\begin{proposition}[Identification of direct treatment effect]\label{prop:direffect}
Consider the structural model \eqref{seq1}. Under Assumptions \ref{ass1p},
\ref{ass2p}, and \ref{ass:pathoverlap},
 the conditional average direct effect on the treated is identified as the conditional DiD estimand,
   $$ CADTT(m_0,m_1) \equiv\mathbb{E} [ \theta_i\mid D_i=1, M_{i0}=m_0,M_{i1}=m_1]=\tau^{DiD}(m_0,m_1)
    .$$

\vspace{0.3cm}
 Consequently, the average direct effect on the treated is identified,
    $$ ADTT  \equiv \mathbb{E} [ \theta_i\mid D_i=1]=\mathbb{E}\big[ \tau^{DiD}(M_{i0},M_{i1}) \big| D_i =1\big]$$
    \end{proposition}
\begin{proof}
    See Appendix \ref{pf_prop:direffect}.
\end{proof}

The proposition shows that the conditional average direct effect on the treated is identified by the DiD estimand conditional on the mediator path. What is surprising is that identification does not require the associated conditional parallel trends assumption to hold. To see this, let
$\Delta Y_i(0)\equiv Y_{i1}(0,M_{i1}(0))-Y_{i0}(0,M_{i0}(0))$. We show that
\begin{align*}
&\mathbb E[\Delta Y_i(0)\mid D_i=1,M_{i1}=m_1,M_{i0}=m_0]
-\mathbb E[\Delta Y_i(0)\mid D_i=0,M_{i1}=m_1,M_{i0}=m_0]\\
&= \  -\mathbb E[\beta_{i1}]\cdot\mathbb E[\alpha_i\mid D_i=1,M_{i0}=m_0,M_{i1}=m_1],
\end{align*}
which is nonzero if both the average mediator effect on the outcome, $\mathbb E[\beta_{i1}]$,
and the conditional average treatment effect on the mediator, $\mathbb E[\alpha_i\mid D_i=1,M_{i0}=m_0,M_{i1}=m_1]$,
are different from zero. In general, when treatment affects the mediator and the mediator in turn affects the outcome, the standard conditional parallel trends assumption will fail. The reason is that the observed mediator path (referred to as \textit{factual path}) is contaminated by the treatment, and when the mediator matters to explain the variations in the outcome, this contamination may translate into different trends for treatment and control groups.  However, under Assumption \ref{ass1p} and \ref{ass2p}, parallel trends conditional on untreated potential mediator path (referred to as \textit{counterfactual path}) holds, that is,
\begin{align*}
&\mathbb E[Y_{i1}(0,m_1)-Y_{i0}(0,m_0)\mid D_i=1,M_{i1}(0)=m_1,M_{i0}(0)=m_0]\\
&\qquad =\mathbb E[Y_{i1}(0,m_1)-Y_{i0}(0,m_0)\mid D_i=0,M_{i1}(0)=m_1,M_{i0}(0)=m_0].
\end{align*}
The challenge is that the DiD estimand conditional on the counterfactual mediator path is infeasible. The result in Proposition \ref{prop:direffect} shows that the DiD conditional on the factual mediator path identifies the conditional average direct effect on the treated.


By integrating over the distribution of the factual mediator path conditional on the treatment group, we can identify the ADTT as
\begin{eqnarray*}
    \mathbb E[\theta_i\vert D_i=1] &=&\int \tau^{DiD}(m_0,m_1) dF_{M_{i0},M_{i1}\vert D_i=1}(m_0,m_1)\\
    &=&\int \mathbb E[\Delta Y_i \vert D_i=1, M_{i0}=m_0, M_{i1}=m_1]\\
    && \qquad \qquad - \mathbb E[\Delta Y_i \vert D_i=0, M_{i0}=m_0, M_{i1}=m_1] dF_{M_{i0},M_{i1}\vert D_i=1}(m_0,m_1).
\end{eqnarray*}


\begin{remark}[Binary and discrete mediator paths]
The conditional DiD argument extends to discrete or mixed mediators.
These settings are special cases of the extension considered in Section \ref{sec:nonabsorbing-mediation}.
\end{remark}

\subsection{Identification of indirect and mediator effects} In general, while we show that the average direct effect is identifiable under our assumptions, the identification of the average indirect effect requires stronger assumptions, which may not be plausible in some applications.
Define $\alpha^{DiD}\equiv\mathbb E[\Delta M_i\mid D_i=1]-\mathbb E[\Delta M_i\mid D_i=0],$
and consider the following assumption.
\begin{assumption}[Stable average mediator effect]\label{ass:stablebeta}
    $\mathbb E[\beta_{i1}]=\mathbb E[\beta_{i0}]$
\end{assumption}
This assumption rules out any time trend in the coefficient $\beta_{it}$ (e.g., $\beta_{it}=\beta_i+f(t)$). But, it allows for time heterogeneity in $\beta_{it}$. It only requires that $\beta_{it}$ has the same mean over time (e.g., $\beta_{it}=\beta_i+\tau_{it}$, where $\mathbb E[\tau_{it}]=0$).
When this assumption is combined with the previous unconditional parallel trends assumption, the standard DiD estimand identifies the average total effect on the treated. The average indirect effect on the treated is therefore obtained as the residual difference between the standard DiD estimand and the integral of the conditional DiD over the conditional distribution of the factual mediator path for the treated group. The following proposition holds.

\begin{proposition}\label{prop:medeffect}
    {Consider the structural model \eqref{seq1}.}
    Suppose $\alpha^{DiD}\neq0$.
    Then under Assumptions \ref{ass1p}, \ref{ass2p}, \ref{ass:pathoverlap}, and \ref{ass:stablebeta}, $\mathbb E[\beta_{i1}]$ is identified as
    \begin{eqnarray*}
        \mathbb E[\beta_{i1}]=\frac{\tau^{DiD}-\int \tau^{DiD}(M_{i1}=m_1, M_{i0}=m_0) dF_{M_{i1},M_{i0}\vert D_i=1}(m_1,m_0)}{\alpha^{DiD}}.
    \end{eqnarray*}
\end{proposition}

\begin{proof}
See Appendix \ref{pf_prop:medeffect}.
\end{proof}



\section{Potential outcome formulation}\label{sec:po-framework}
{
We now extend the mediator path identification argument from the linear structural model to the general potential outcome framework. The structural model in Sections \ref{anaF}--\ref{sec:baseline-id} is useful for showing why conventional estimands fail and why path conditioning works.
The potential outcome formulation below states the same logic directly in terms of potential outcomes and potential mediator paths.

Consider
}
\begin{eqnarray}\label{seqgeneral}
\left\{ \begin{array}{lcl}
     Y_{it} &=&  Y_{it}(1,M_{it}(1)) D_i+Y_{it}(0,M_{it}(0))(1-D_i),\\ \\
     M_{it} &=& M_{it}(1)D_i+M_{it}(0)(1-D_i),
     \end{array} \right.
\end{eqnarray}
where $Y_{it}(d,m_t)$ and $M_{it}(d)$ are potential outcome and potential mediator when the treatment $D_i$ and the mediator $M_{it}$ are exogenously set to $d$ and $m_t$, respectively.
\begin{assumption}[Conditional parallel trends]\label{conditionalPT}
        \begin{eqnarray*}
    &&\mathbb E[Y_{i1}(0,m_1)-Y_{i0}(0,m_0)\vert D_i=1,M_{i1}(0)=m_1,M_{i0}(0)=m_0]\\
    &&=\mathbb E[Y_{i1}(0,m_1)-Y_{i0}(0,m_0)\vert D_i=0,M_{i1}(0)=m_1,M_{i0}(0)=m_0] \text{ for all } m_1, m_0.
    \end{eqnarray*}
        \end{assumption}
This assumption states that conditional on the counterfactual mediator path $(M_{i0}(0),M_{i1}(0))$, the average potential outcome trend is independent of treatment status. As discussed earlier, Model \eqref{seq1} and Assumptions \ref{ass1p}--\ref{ass2p} imply this assumption. This assumption allows for a violation of parallel trends conditional on the observed mediator path $(M_{i0},M_{i1})$.

\begin{assumption}[Conditional orthogonality between potential mediator and untreated potential outcome trends]\label{conditionalorthorganity}
\begin{eqnarray*}
&& \mathbb E[Y_{i1}(0,m_1)-Y_{i0}(0,m_0) \vert D_i=d,M_{i1}(0)=m_1,M_{i0}(0)=m_0]\\
&& = \mathbb E[Y_{i1}(0,m_1)-Y_{i0}(0,m_0)\vert D_i=d, M_{i1}(1)=m_1,M_{i0}(1)=m_0] \text{ for all } m_1, m_0, d.
\end{eqnarray*}
       \end{assumption}
This assumption states that conditional on treatment status, the average potential outcome trend is independent of the potential mediator path. This assumption is also implied by Model \eqref{seq1} and Assumptions \ref{ass1p}--\ref{ass2p}.

The framework considered here covers settings where the sequential ignorability assumption in \cite{imai2010identification} could be violated. We leverage on the time dimension in the data structure to remove time-invariant factors that could compromise the validity of sequential ignorability.  Assumptions \ref{conditionalPT} and \ref{conditionalorthorganity} could be viewed as a generalization of sequential exogeneity to DiD settings.
As is customary in the DiD literature, we also rely on the assumption that the treatment has no anticipatory effects on the outcome and mediator (Assumption \ref{noanticipation}).
\begin{assumption}[No anticipation effects]\label{noanticipation}
$\,$
\begin{enumerate}[(i)]
    \item \label{noanticipation1} $Y_{i0}(1,m)=Y_{i0}(0,m),$ a.s. for all $m$.
    \item \label{noanticipation2} $M_{i0}(1)=M_{i0}(0),$ a.s.
\end{enumerate}
\end{assumption}
The following proposition holds.
\begin{proposition}\label{prop:generalresultADTT}
In the potential outcome model \eqref{seqgeneral},  under Assumptions \ref{ass:pathoverlap}, \ref{conditionalPT}, \ref{conditionalorthorganity},
and \ref{noanticipation}(\ref{noanticipation1}), the results in Proposition \ref{prop:direffect} hold.

\end{proposition}
As we discussed in the structural model in the previous section, the unconditional parallel trends assumption may not hold because of the heterogeneity in the mediator effect on the outcome and the dependence between the mediator path and the treatment. However, if one is willing to assume that parallel trends holds, then she can recover the average indirect effect.

\begin{assumption}[Unconditional parallel trends]\label{unconditionalPT}
    \begin{eqnarray*}
        \mathbb E[Y_1(0,M_1(0))-Y_0(0,M_0(0))\vert D=1]=\mathbb E[Y_1(0,M_1(0))-Y_0(0,M_0(0))\vert D=0]
    \end{eqnarray*}
\end{assumption}

Under Assumptions \ref{noanticipation} and \ref{unconditionalPT}, we can show that $\tau^{DiD}=ADTT+AITT$. Therefore, the AITT is identified as the difference between the DiD estimand and the identified ADTT. Hence, the following proposition holds.
\begin{proposition}\label{prop:generalresultAITT}
In the potential outcome model \eqref{seqgeneral}, under Assumptions \ref{ass:pathoverlap}, \ref{conditionalPT}, \ref{conditionalorthorganity}, \ref{noanticipation}, and \ref{unconditionalPT}, the AITT is identified: $$AITT=\tau^{DiD}-\int \tau^{DiD}(m_0,m_1) dF_{M_{i0},M_{i1}\vert D_i=1}(m_0,m_1).$$
\end{proposition}
The proof of this proposition is straightforward from the discussion above and is therefore omitted.


\section{Extensions}\label{sec:extensions}
{
\subsection{Multivariate mediators}\label{sec:multi-mediators}


In practice, there are multiple mediators that are responses to the treatment and influence the main outcome of interest. This section extends our identification results to multivariate mediators.

\subsubsection{Model and identification of average direct effect}

Let $\boldsymbol M_{it}\in\mathbb R^K$ be a vector of continuous mediators. The
multivariate model is
\begin{equation}\label{eq:mmulti}
\left\{
\begin{array}{lcl}
Y_{it} &=& \theta_i tD_i+\boldsymbol\beta_{it}'\boldsymbol M_{it}
          +\lambda_i+\eta_t+U_{it},\\[0.2cm]
\boldsymbol M_{it} &=& \boldsymbol\alpha_i tD_i
          +\boldsymbol\gamma_i+\boldsymbol\delta_t+\boldsymbol V_{it},\\[0.2cm]
D_i &=& h(\lambda_i,\boldsymbol\gamma_i,\varepsilon_i).
\end{array}
\right.
\end{equation}
where
$\boldsymbol\beta_{it},\boldsymbol\alpha_i,\boldsymbol\gamma_i,
\boldsymbol\delta_t,\boldsymbol V_{it}\in\mathbb R^K$. The average indirect
effect on the treated is
\[
AITT
=
\mathbb E\!\left[
Y_{i1}(0,\boldsymbol M_{i1}(1))
-
Y_{i1}(0,\boldsymbol M_{i1}(0))
\mid D_i=1
\right]
=
\mathbb E[\boldsymbol\beta_{i1}'\boldsymbol\alpha_i\mid D_i=1].
\]

\begin{assumption}\label{ass:multi_exog}$\,$
\begin{enumerate}[(i)]
    \item $(\lambda_i,\boldsymbol\gamma_i,\varepsilon_i)
\ \rotatebox[origin=c]{90}{$\models$}\
(\{\boldsymbol V_{it},U_{it},\boldsymbol\beta_{it}\}_{t=0,1},
\boldsymbol\alpha_i)$.
\item $(\{\boldsymbol V_{it}\}_{t=0,1},\boldsymbol\alpha_i)
\ \rotatebox[origin=c]{90}{$\models$}\
(\{U_{it},\boldsymbol\beta_{it}\}_{t=0,1})
\mid
(\lambda_i,\boldsymbol\gamma_i,\varepsilon_i).$
\item $0<\mathbb P(D_i=1 \vert \boldsymbol M_{i0}, \boldsymbol M_{i1})<1$ a.s.
\end{enumerate}
\end{assumption}

Let $\Delta Y_i\equiv Y_{i1}-Y_{i0}$, $\Delta\boldsymbol M_i\equiv \boldsymbol M_{i1}-\boldsymbol M_{i0}.$
For
$(\boldsymbol m_0,\boldsymbol m_1)$ in the treated mediator-path support,
define the path-conditional DiD estimand
\begin{eqnarray*}
\tau^{DiD}(\boldsymbol m_0,\boldsymbol m_1)
&\equiv&
\mathbb E[\Delta Y_i\mid D_i=1,\boldsymbol M_{i0}=\boldsymbol m_0,\boldsymbol M_{i1}=\boldsymbol m_1]\\
&& -\ \mathbb E[\Delta Y_i\mid D_i=0,\boldsymbol M_{i0}=\boldsymbol m_0,\boldsymbol M_{i1}=\boldsymbol m_1].
\end{eqnarray*}
Define
the vector mediator DiD estimand
\[
\boldsymbol\alpha^{DiD}
\equiv
\mathbb E[\Delta\boldsymbol M_i\mid D_i=1]
-
\mathbb E[\Delta\boldsymbol M_i\mid D_i=0].
\]

\begin{proposition}[Direct effect and mediator response with multivariate mediators]
\label{prop:multi_direct_alpha}
Consider the multivariate-mediator structural model \eqref{eq:mmulti}. Under Assumption \ref{ass:multi_exog},
$\mathbb E[\boldsymbol\alpha_i]=\boldsymbol\alpha^{DiD},$
and
\[
ADTT\equiv \mathbb E[\theta_i\mid D_i=1]=\int
\tau^{DiD}(\boldsymbol m_0,\boldsymbol m_1)
\,dF_{\boldsymbol M_{i0},\boldsymbol M_{i1}\mid D_i=1}
(\boldsymbol m_0,\boldsymbol m_1)=\mathbb E[\tau^{DiD}(\boldsymbol M_{i0},\boldsymbol M_{i1}) \vert D_i=1].
\]
\end{proposition}
The proof of this proposition is similar to that of Proposition \ref{prop:direffect} and is therefore omitted.

Under the stable mediator effect assumption ($\mathbb E[\boldsymbol \beta_{i1}]=\mathbb E[\boldsymbol \beta_{i0}]$), we can recover the average indirect effect AITT as the residual difference between the standard DiD estimand and the average direct effect ADTT. In general, when the mediator effect is heterogeneous over time, we cannot recover the AITT without further assumptions.


\subsection{Extension to Nonlinear Difference-in-Differences}
We consider the model below where the treatment is binary, $D\in \{0,1\}$, and there are two time periods, $t\in \{0,1\}$. This model is an extension of the changes-in-changes model in \cite{athey2006identification} to include a mediator. We drop the subscript $i$ here for simplicity.


\begin{eqnarray}\label{seqnonlineardid}
\left\{ \begin{array}{lcl}
     Y_{t} &=&  g_t(t D,M_{t},U_{t})\\ \\
     M_{t} &=& \psi_t(t D, V_{t})
     \end{array} \right.
\end{eqnarray}
In the above model, $U_t$ is a scalar unobservable, while $V_t$ is a vector of unobservables. $g_t$ and $\psi_t$ are unknown functions.
\begin{assumption}\label{ass:nonlineardid} $\,$
    \begin{enumerate}[(i)]
        \item \label{ass1:nonlineardid} $U_1 \vert D=d, M_0=m_0, M_1=m_1 \sim^{d} U_0 \vert D=d, M_0=m_0, M_1=m_1$.
        \item \label{ass2:nonlineardid} The function $g_t(0,m_t,.)$ is continuous and strictly increasing.
        \item \label{ass3:nonlineardid} $Supp\{U_t \vert D=1, M_0=m_0, M_1=m_1\} \subseteq Supp\{U_t \vert D=0, M_0=m_0, M_1=m_1\}$.
    \end{enumerate}
\end{assumption}
Assumption \ref{ass:nonlineardid}(\ref{ass1:nonlineardid}) states that the distribution of the outcome unobserved heterogeneity $U_t$ conditional on $(D,M_0,M_1)$ is stable over time. Assumption \ref{ass:nonlineardid}(\ref{ass2:nonlineardid}) is a smoothness and monotonicity condition that ensures that the function $g_t(0,m_t,.)$ is invertible. Assumption \ref{ass:nonlineardid}(\ref{ass3:nonlineardid}) is a support condition that requires that the support of the outcome unobserved heterogeneity $U_t$ for the treated group conditional on the joint vector $(M_0,M_1)$ is included in that of the control group. These assumptions combined imply that the counterfactual distribution $\mathbb P(Y_1(0,m_1) \leq y \vert D=1, M_0=m_0, M_1=m_1)$ is identified, which helps identify the average direct effect ADTT.

Define $Y_t(0,m_t)\equiv g_t(0,m_t,U_t)$, and $Y_t(0,M_t(0))\equiv g_t(0,M_t(0),U_t)$.
\begin{proposition}\label{prop:nonlinear}
    Under Assumption \ref{ass:nonlineardid}, we have
    \begin{eqnarray*}
        && \mathbb P(Y_1(1,m_1) \leq y \vert D=1, M_0=m_0, M_1=m_1) = \mathbb P(Y_1 \leq y \vert D=1, M_0=m_0, M_1=m_1),\\
       && \mathbb P(Y_1(0,m_1) \leq y \vert D=1, M_0=m_0, M_1=m_1) =  \\
       && \qquad \qquad F_{Y_0 \vert D=1, M_0=m_0, M_1=m_1}\left(F^{-1}_{Y_0 \vert D=0, M_0=m_0, M_1=m_1}(F_{Y_1 \vert D=0, M_0=m_0, M_1=m_1}(y))\right)
    \end{eqnarray*}
\end{proposition}

\begin{proof}
    See Appendix \ref{apx:nonlinear}.
\end{proof}

{
}


\subsection{Multiple treatment periods}

\subsubsection{Multiple treatment periods with no dynamic treatment effects}\label{sec:nonabsorbing-mediation}
Consider the following model specification: for $t\in \mathcal T\equiv \{0,1,\ldots,T\}$,
\begin{equation}\label{eq:multiplenonstaggered}
\left\{
\begin{array}{lcl}
Y_{it}&=&\theta_{it}D_{it}+\beta_{it}M_{it}+\lambda_i+\eta_t+U_{it},\\[0.2cm]
M_{it}&=&\psi_t(D_{it},\gamma_i,\tilde{V}_{it}),\\[0.2cm]
D_{it}&=&h_t(\lambda_i,\gamma_i,\varepsilon_{it}),
\end{array}
\right.
\end{equation}
where $D_{it}$ is a binary treatment indicator for individual $i$ at time $t$, and $\theta_{it}$ is the direct effect of the treatment on the outcome, which is allowed to vary across individuals and time. The variables $\tilde{V}_{it}$ and $\varepsilon_{it}$ could be multivariate. All other variables are the same as described in the model \eqref{seq1}. In the baseline period $(t=0)$, no individuals are treated ($D_{i0}=0$ for all $i$). This model assumes that past and future treatment statuses do not influence the current outcome and mediator. A similar restriction has been imposed on the outcome in \cite{dechaisemartin2020two} in the absence of mediators.

The functions $\psi_t$ and $h_t$ are unrestricted. For example,  when the mediator $M$ is continuous, we can set $\psi_t(D_{it},\gamma_i,\tilde{V}_{it})=\alpha_{it} D_{it} + \gamma_i+\delta_t + V_{it}$, where $\tilde{V}_{it}=(\alpha_{it},V_{it})$. When the mediator $M$ is binary, we can set $\psi_t(D_{it},\gamma_i,\tilde{V}_{it})=\mathbbm{1}\{\alpha_{it} D_{it} + \gamma_i+\delta_t + V_{it}>0\}.$ A generalized version of the identifying assumption in the two-period setting is given in Assumption \ref{ass:multiplenonstaggered} below.
\begin{assumption}\label{ass:multiplenonstaggered}$\,$
    \begin{enumerate}[(i)]
        \item  $(\lambda_i, \gamma_i,\{\varepsilon_{it}\}_{t\in \mathcal T})\ \rotatebox[origin=c]{90}{$\models$}\ (\{\tilde{V}_{it},U_{it},\beta_{it}\}_{t\in \mathcal T})$.
   \item  $\{\tilde{V}_{it}\}_{t\in \mathcal T}\ \rotatebox[origin=c]{90}{$\models$}\ (\{U_{it},\beta_{it}\}_{t\in \mathcal T})\vert (\lambda_i, \gamma_i,\{\varepsilon_{it}\}_{t\in \mathcal T})$.
   \item $0<\mathbb P(D_{it}=1\vert M_{i0},M_{it})<1$ a.s.
    \end{enumerate}
\end{assumption}
Under Assumption \ref{ass:multiplenonstaggered}, the standard parallel trends assumption may not hold for the outcome and the mediator. The mediator can be continuous, discrete, or mixed.
Define $\Delta Y_{it}\equiv Y_{it}-Y_{i0}$ and $\Delta M_{it} \equiv M_{it}-M_{i0}$. The proposition below generalizes the results in Proposition \ref{prop:direffect}. \begin{proposition}\label{prop:directeffect_multiple}
Under Assumption \ref{ass:multiplenonstaggered}, the conditional average direct effect on the contemporaneous treated group is identified as
\begin{eqnarray*}
    \mathbb E[\theta_{it}\vert D_{it}=1,M_{it}=m_t,M_{i0}=m_0] &=& \mathbb E[\Delta Y_{it} \vert D_{it}=1,M_{it}=m_t,M_{i0}=m_0]\\
    && \qquad -\mathbb E[\Delta Y_{it} \vert D_{it}=0,M_{it}=m_t,M_{i0}=m_0].
\end{eqnarray*}
The above estimand can be integrated over the distribution of the vector $(M_{it},M_{i0})$ conditional on the contemporaneous treatment group $D_{it}=1$ to obtain the average direct effect on the treated group. More precisely, the following holds.
\begin{eqnarray}
    \mathbb E[\theta_{it}\vert D_{it}=1]
    &=&\int \mathbb E[\Delta Y_{it} \vert D_{it}=1, M_{it}=m_t, M_{i0}=m_0]\label{eq:multiADTT}\\
    && \qquad \qquad - \mathbb E[\Delta Y_{it} \vert D_{it}=0, M_{it}=m_t, M_{i0}=m_0] dF_{M_{it},M_{i0}\vert D_{it}=1}(m_t,m_0). \nonumber
\end{eqnarray}
\end{proposition}
\begin{proof}
    See Appendix \ref{pf_prop:direffectmultiple}.
\end{proof}
When $\psi_t(1,\gamma_i,\tilde{V}_{it})=\psi_t(0,\gamma_i,\tilde{V}_{it})$ a.s., then $M_{it}$ is a standard time-varying covariate. The identification strategy developed in this paper still applies.

To understand the relevance of the results in Proposition \ref{prop:directeffect_multiple}, we devote a special attention to the unconditional DiD estimand $\mathbb E[\Delta Y_{it} \vert D_{it}=1]-\mathbb E[\Delta Y_{it} \vert D_{it}=0]$. Under Assumption \ref{ass:multiplenonstaggered}, we can show that
\begin{eqnarray*}
    \mathbb E[\Delta Y_{it} \vert D_{it}=1]-\mathbb E[\Delta Y_{it} \vert D_{it}=0] &=& \mathbb E[\theta_{it} \vert D_{it}=1]\\
    && + \mathbb E[\beta_{it}](\mathbb E[M_{it}\vert D_{it}=1]-\mathbb E[M_{it}\vert D_{it}=0])\\
    && -\mathbb E[\beta_{i0}](\mathbb E[M_{i0}\vert D_{it}=1]-\mathbb E[M_{i0}\vert D_{it}=0]).
\end{eqnarray*}
The term $\mathbb E[\beta_{it}](\mathbb E[M_{it}\vert D_{it}=1]-\mathbb E[M_{it}\vert D_{it}=0]) -\mathbb E[\beta_{i0}](\mathbb E[M_{i0}\vert D_{it}=1]-\mathbb E[M_{i0}\vert D_{it}=0])$ is the bias that stems from ignoring the mediator $M$. We call it the \textit{mediator bias}. If the average mediator effect is stable over time,  (i.e., $\mathbb E[\beta_{it}]=\mathbb E[\beta_{i0}]$), then we can recover this effect as the ratio between the DiD estimand for $Y$ net of the identified average direct effect and the DiD estimand for $M$
$$
\mathbb E[\beta_{i0}] = \frac{(\mathbb E[\Delta Y_{it} \vert D_{it}=1]-\mathbb E[\Delta Y_{it} \vert D_{it}=0] )-\mathbb E[\theta_{it}\vert D_{it}=1]}{\mathbb E[\Delta M_{it} \vert D_{it}=1]-\mathbb E[\Delta M_{it} \vert D_{it}=0]},
$$
where $\mathbb E[\theta_{it}\vert D_{it}=1]$ is identified in \eqref{eq:multiADTT}. Note that we do not require parallel trends for the mediator to identify this quantity.

First, when the mediator has no effect on the outcome (i.e., $\beta_{it}=0$ for all $i$ and $t$), then the unconditional DiD estimand $\mathbb E[\Delta Y_{it} \vert D_{it}=1]-\mathbb E[\Delta Y_{it} \vert D_{it}=0]$ identifies the average direct effect on the treated, $\mathbb E[\theta_{it} \vert D_{it}=1]$. In such a case $\Delta Y_{it}=\theta_{it} D_{it} + \eta_t-\eta_0 + U_{it} -U_{i0}$, and we have
\begin{eqnarray*}
\mathbb E[\Delta Y_{it} \vert D_{it}] &=& \mathbb E[\theta_{it}\vert D_{it}] D_{it} + \eta_t-\eta_0+ \mathbb E[U_{it} - U_{i0} \vert D_{it}],\\
&=& \mathbb E[\theta_{it}\vert D_{it}] D_{it} + \eta_t-\eta_0+ \mathbb E[U_{it} - U_{i0}],\ \text{ under Assumption \ref{ass:multiplenonstaggered}},\\
&=& \theta_t D_{it} + \tilde{\eta}_t.
\end{eqnarray*}
One can run a cross-sectional regression for each period $t\in \{1,\ldots,T\},$
\begin{eqnarray}
\Delta Y_{it} &=& \theta_t D_{it} + \tilde{\eta}_t + e_{it}.
\end{eqnarray}
One can alternatively run the saturated regression to obtain the whole parameter vector $(\theta_1,,\ldots,\theta_T)$ with a joint covariance matrix,
\begin{eqnarray}
\Delta Y_{it} = \sum_{s=1}^T \tilde{\eta}_s \mathbbm{1}\{t=s\}+ \sum_{s=1}^T \theta_s D_{it}\mathbbm{1}\{t=s\} + e_{it}.
\end{eqnarray}

Second, when $\psi_t(D_{it},\gamma_i,\tilde{V}_{it})=\alpha_{it} D_{it} + \gamma_i+\delta_t + V_{it}$, then the mediator bias simplifies to
$$\mathbb E[\beta_{it}]\,\mathbb E[\alpha_{it}]
+\mathbb E[\beta_{it}-\beta_{i0}]
\big(\mathbb E[\gamma_i\mid D_{it}=1]-\mathbb E[\gamma_i\mid D_{it}=0]\big).$$
This mediator bias becomes the average indirect effect when the mediator effect $\beta_{it}$ is on average stable over time (i.e., $\mathbb E[\beta_{it}]=\mathbb E[\beta_{i0}]$) or the treatment selection variable, $D_{it}$, is independent of the mediator fixed effects. In such a case, the standard parallel trends assumption holds for the outcome and the mediator (because of the linear two-way fixed effects specification).

\begin{remark}[Multiple pre-treatment periods]
    When there are multiple pre-treatment periods, we can use the fact that the identification of $\mathbb E[\theta_{it}\vert D_{it}=1]$ does not depend on a specific pre-treatment period to check for violations of our identifying assumptions. More precisely, suppose that there are $T_0$ multiple pre-treatment periods. For $t_0\in \{-T_0,\ldots, 0\}$, define $\Delta Y_{it}^{t_0}\equiv Y_{it}-Y_{it_0}$. Since no individuals were treated in the pre-treatment periods, we have $D_{it_0}=0$ for all $t_0\in \{-T_0,\ldots, 0\}$. Suppose that model~\eqref{eq:multiplenonstaggered} and Assumption \ref{ass:multiplenonstaggered} hold for $t\in \mathcal T=\{-T_0, \ldots,0,\ldots,T\}.$ Then,
    \begin{eqnarray*}
    \mathbb E[\theta_{it}\vert D_{it}=1]
    &=&\int \mathbb E[\Delta Y_{it}^{t_0} \vert D_{it}=1, M_{it}=m_t, M_{it_0}=m_{t_0}]\\
    && \qquad \qquad - \mathbb E[\Delta Y_{it}^{t_0} \vert D_{it}=0, M_{it}=m_t, M_{it_0}=m_{t_0}] dF_{M_{it},M_{it_0}\vert D_{it}=1}(m_t,m_{t_0}). \nonumber
\end{eqnarray*}
for all  $t_0\in \{-T_0,\ldots, 0\}$. So, we can test for whether the above estimand is constant across values of $t_0$ for each $t\in \{1,\ldots,T\}$.
\end{remark}


\subsubsection{Multiple treatment periods with staggered adoption and dynamic treatment effects}\label{sec:staggered-adoption}
We modify the model specification \eqref{eq:multiplenonstaggered} to allow the outcome to depend on past or future treatments. The staggered adoption model we consider is the following. For $t\in \mathcal T=\{0,\ldots,T\}$,
\begin{eqnarray}\label{eq:multiplestaggered}
\left\{ \begin{array}{lcl}
     Y_{it} &=&  (\sum_{g=1}^T\theta_{it}^g D_i^g)\mathbbm{1}\{t>0\} +\beta_{it} M_{it} + \lambda_i +\eta_t +U_{it},\\ \\
     M_{it} &=& (\sum_{g=1}^T\alpha_{it}^g D_i^g)\mathbbm{1}\{t>0\}+\gamma_i + \delta_t + V_{it},\\ \\
     D_{it} &=& \mathbbm{1}\{h(\lambda_i,\gamma_i, \varepsilon_i)\leq t,t>0\},
     \end{array} \right.
\end{eqnarray}
where $D_i^g$ is the indicator for whether individual $i$ receives treatment for the first time in period $g$ or not, and $\theta_{it}^g$ is the direct effect of individual $i$ receiving treatment for the first time in period $g$ on her outcome in period $t$.
Let $\mathcal G \equiv \{1, \ldots, T, \infty\}$.
\begin{assumption}\label{ass:multiplestaggered}$\,$
    \begin{enumerate}[(i)]
        \item  $(\lambda_i,\gamma_i,\varepsilon_i)\ \rotatebox[origin=c]{90}{$\models$}\ (\{V_{it},U_{it},\beta_{it},\{\alpha_{it}^g: g\in \mathcal T\}\}_{t\in \mathcal T})$.
   \item  $(\{V_{it},\{\alpha_{it}^g: g\in \mathcal T\}\}_{t\in \mathcal T})\ \rotatebox[origin=c]{90}{$\models$}\ (\{U_{it},\beta_{it}\}_{t\in \mathcal T}) \vert \lambda_i, \gamma_i,\varepsilon_i$.
   \item $0<\mathbb P(D_{i}^g=1\vert M_{i0},M_{it})<1$ a.s. for all $g \in \mathcal G$.
    \end{enumerate}
\end{assumption}
Assumption \ref{ass:multiplestaggered} implies  $(\{V_{it},\{\alpha_{it}^g: g\in \mathcal T\}\}_{t\in \mathcal T},\lambda_i, \gamma_i,\varepsilon_i)\ \rotatebox[origin=c]{90}{$\models$}\ (\{U_{it}, \beta_{it}\}_{t\in \mathcal T})$.
We can show that under this assumption, the conditional average direct treatment effect on the treated is identified:
\begin{eqnarray*}
    \mathbb E[\theta_{it}^g\vert D_i^g=1, M_{it}=m_t, M_{i0}=m_0]&=&\mathbb E[\Delta Y_{it} \vert D_i^g=1, M_{it}=m_t, M_{i0}=m_0]\\
    &&- \mathbb E[\Delta Y_{it} \vert D_i^{\infty}=1, M_{it}=m_t, M_{i0}=m_0],
\end{eqnarray*}
where $D_i^{\infty}$ an indicator for the never-treated group. We can obtain the average direct effect on the treated as
\begin{eqnarray*}
    \mathbb E[\theta_{it}^g\vert D_{i}^g=1]
    &=&\int \mathbb E[\Delta Y_{it} \vert D_{i}^g=1, M_{it}=m_t, M_{i0}=m_0]\\
    && \qquad \qquad - \mathbb E[\Delta Y_{it} \vert D_{i}^{\infty}=1, M_{it}=m_t, M_{i0}=m_0] dF_{M_{it},M_{i0}\vert D_{i}^g=1}(m_t,m_0). \nonumber
\end{eqnarray*}


\section{Empirical illustration: railroads and market access}\label{sec:empirical}

The mediator-path identification result writes the $ADTT$ as a conditional DiD estimand averaged over the mediator-path distribution of treated units. We implement this estimand using the doubly robust estimator of \cite{sant2020doubly}. To keep the application aligned with the notation used throughout the paper, $Y$ denotes the outcome, $M$ the mediator, $D$ the treatment, and $\boldsymbol X$ the baseline covariates throughout this section. We reserve $\boldsymbol W$ for the target-specific conditioning vector used in a given doubly robust specification.

\subsection{Questions, sample, and empirical design}

Donaldson and Hornbeck's principal object is the aggregate contribution of the national railroad network to the agricultural sector in 1890 \citep{donaldson2016railroads}. They first estimate how changes in county market access between 1870 and 1890 are capitalized into agricultural land values. They then calculate how much each county's market access would fall if all railroads were removed from the 1890 transportation network and aggregate the implied land-value losses. Their headline conclusion is that removing all railroads would reduce the total value of U.S.\ agricultural land by $60.2\%$, with annual losses equal to $3.22\%$ of GNP.

In their framework, market access is constructed to summarize the direct and indirect spatial general-equilibrium effects of changes in the national railroad network. Their use of the terms ``direct'' and ``indirect'' therefore does not correspond to the natural direct and indirect treatment effects studied in this paper. Likewise, the local-railroad controls in their Table II assess whether the estimated relationship between market access and land value is robust to conditioning on own and nearby railroad construction; those controls are not used to construct a causal mediation decomposition.

Our illustration instead asks a local-adoption question. Let $t=0$ denote 1870 and $t=1$ denote 1890. For county $o$, let $Y_{ot}$ denote the log value of agricultural land and buildings, let $M_{ot}$ denote log cost-based market access, and define the baseline geographic covariates as
\[
\boldsymbol X_o
=
(\mathrm{lon}_o,\mathrm{lat}_o)',
\]
where $\mathrm{lon}_o$ and $\mathrm{lat}_o$ denote, respectively, the longitude and latitude of the geographic centroid of county $o$.
The treatment indicator $D_o$ equals one if county $o$ had no railroad track in 1870 but had track in 1890, and equals zero if the county had no track in either year. Under the maintained assumptions, we report the total effect of local railroad adoption on $Y$, the mediator response of $M$, the $ADTT$ identified through mediator-path conditioning, and the residual $AITT$.

We begin with the $2{,}327$-county balanced regression sample used in the Donaldson--Hornbeck baseline specification. Restricting the sample to counties without railroad track in 1870 excludes the $1{,}272$ counties that already had track, leaving $1{,}055$ counties observed in both periods. Of these counties, $730$ are treated and $325$ are controls. Because $M_{ot}$ is a network object, it can change for control counties when railroad track is constructed elsewhere. By contrast, $D_o$ represents whether the county itself adopts railroad track between the two periods and stays zero for all counties in the baseline period.
We report standard errors using state-clustered CR0 stacked-sandwich covariances and use the delta method where needed. The results without baseline covariates are discussed in Table \ref{tab:estimates_dh_nocov} in the Appendix.

Throughout the application, the average direct effect on the treated, $ADTT$, is the component not transmitted through the mediator, the measured cost-based market-access. It can therefore contain depot-town activity, local commerce, amenities, and omitted dimensions or spillovers of market access. Because each county's outcome and market access evolve with the realized national network, the estimated $ADTT$ is a local-adoption effect in that network, not the no-interference effect of changing the county's track status while holding the rest of the network fixed.

\subsection{TWFE and doubly robust specifications}

For the original-control TWFE benchmark, define the separate cubic geographic basis
\[
\boldsymbol b_{\mathrm{geo}}(\boldsymbol X_o)
=
\big(
\mathrm{lon}_o,\mathrm{lon}_o^2,\mathrm{lon}_o^3,
\mathrm{lat}_o,\mathrm{lat}_o^2,\mathrm{lat}_o^3
\big)'.
\]
For county $o$ in state $\mathfrak s(o)$ and period $t\in\{0,1\}$, we estimate
\begin{equation}\label{eq:twfe-dh}
Y_{ot}
=
\pi_1 tD_o
+\pi_2 M_{ot}
+\phi_o
+\zeta_{\mathfrak s(o),t}
+\boldsymbol b_{\mathrm{geo}}(\boldsymbol X_o)'\boldsymbol\chi_t
+\xi_{ot},
\end{equation}
where $\phi_o$, $\zeta_{\mathfrak s(o),t}$, and $\boldsymbol b_{\mathrm{geo}}(\boldsymbol X_o)'\boldsymbol\chi_t$ represent county fixed effects, state-by-period fixed effects, and the cubic geographic trends used in Equation (13) of \cite{donaldson2016railroads}, and $tD_o$ denotes local railroad adoption.

In Table \ref{tab:estimates_dh}, the TWFE total effects are obtained by omitting $M_{ot}$ from \eqref{eq:twfe-dh}, and the direct effect and the $M\to Y$ effect are estimates of $\pi_1$ and $\pi_2$, respectively. The TWFE indirect effects are estimated as the total coefficient minus $\pi_1$. Recall that the direct and indirect effects obtained from the TWFE regressions are descriptive, not causal, by Claim \ref{claim:interpretTWFE}.

The two TWFE benchmarks use the same $1{,}055$ counties and equal observation weights, but they differ in their covariate selection. The original-control column contains state-by-period effects and the cubic geographic basis in \eqref{eq:twfe-dh}, whereas the same-controls column replaces them with common period effects and linear trends in $\boldsymbol X_o$, matching the sample, weights, and baseline covariates in the DR specifications. Comparing that column with DR therefore holds the observed covariate set fixed and therefore helps separate differences due to the estimator from differences due to the richer original-control specification.

The doubly robust columns implement the improved estimator of \cite{sant2020doubly}.
For the total effect and the mediator response, the conditioning vector is
\[
\boldsymbol W_o=\boldsymbol X_o.
\]
For the direct effect, the linear mediator-path specification uses
\[
\boldsymbol W_o
=
(M_{o0},M_{o1},\boldsymbol X_o')',
\]
whereas the additive-quadratic mediator-path specification uses
\[
\boldsymbol W_o
=
(M_{o0},M_{o0}^2,M_{o1},M_{o1}^2,\boldsymbol X_o')'.
\]
\footnote{``Quadratic'' in Table \ref{tab:estimates_dh} refers to separate squared terms in the two mediator coordinates and does not include the interaction $M_{o0}M_{o1}$.}

The DR specification cannot retain the original state and cubic controls. Eight of the $37$ represented states contain treated counties but no controls, so treated-support overlap fails within those states; one additional state contains controls only. We therefore define the same-controls TWFE column with the linear geographic pair $\boldsymbol X_o$, which is the covariate set used in the DR fits.
}


\begin{table}[!htbp]
\centering
\begin{threeparttable}
\footnotesize
\caption{Local railroad adoption and market-access mediation, 1870--1890}
\label{tab:estimates_dh}
\setlength{\tabcolsep}{3pt}
\begin{tabular}{lcccc}
\toprule
& \multicolumn{2}{c}{TWFE} & \multicolumn{2}{c}{Doubly Robust} \\
\cmidrule(lr){2-3}\cmidrule(lr){4-5}
& Original controls & Same controls & Linear path & Additive quadratic \\
& (1) & (2) & (3) & (4) \\
\midrule
$D \to Y$ (Total) & -0.109 & 0.348\ifmmode^{**}\else\(^{**}\)\fi & 0.390\ifmmode^{**}\else\(^{**}\)\fi & 0.390\ifmmode^{**}\else\(^{**}\)\fi \\
 & (0.087) & (0.147) & (0.158) & (0.158) \\[3pt]
$D \to Y$ (Direct) & -0.253\ifmmode^{***}\else\(^{***}\)\fi & 0.090 & 0.429\ifmmode^{**}\else\(^{**}\)\fi & 0.525\ifmmode^{*}\else\(^{*}\)\fi \\
 & (0.098) & (0.175) & (0.177) & (0.275) \\[3pt]
$D \to M$ & 0.376\ifmmode^{***}\else\(^{***}\)\fi & 0.656\ifmmode^{***}\else\(^{***}\)\fi & 0.698\ifmmode^{***}\else\(^{***}\)\fi & 0.698\ifmmode^{***}\else\(^{***}\)\fi \\
 & (0.054) & (0.100) & (0.107) & (0.107) \\[3pt]
$M \to Y$ & 0.384\ifmmode^{***}\else\(^{***}\)\fi & 0.394\ifmmode^{**}\else\(^{**}\)\fi & -0.055 & -0.193 \\
 & (0.114) & (0.178) & (0.204) & (0.386) \\[3pt]
$D \to M \to Y$ (Indirect) & 0.144\ifmmode^{***}\else\(^{***}\)\fi & 0.258\ifmmode^{**}\else\(^{**}\)\fi & -0.039 & -0.135 \\
 & (0.043) & (0.118) & (0.141) & (0.262) \\
\midrule
Covariate adjustment & State + cubic geo. & Linear geo. & Linear geo. & Linear geo. \\
Observations & 2{,}110 & 2{,}110 & 2{,}110 & 2{,}110 \\
\bottomrule
\end{tabular}
\par\footnotesize
\textit{Notes}: Columns (1) and (2) are descriptive TWFE decompositions. Their rows report, in order, the total local-adoption effect coefficient from the outcome regression without $M$, that coefficient after adding $M$, targeting the direct effect, the local-adoption effect coefficient from the mediator regression, the coefficient on $M$ in the outcome regression, and the difference between the first two coefficients.
The specification of Column (1) uses state-by-period effects and separate cubic terms in longitude and latitude. Column (2) uses the same $1{,}055$ counties, equal observation weights, and linear geographic covariates as Column (3). Columns (3) and (4) report DR estimates of $ATT$, $ADTT$, the treatment effect on $M$, the mediator-effect ratio, and $AITT$ under our framework.
The sample consists of $730$ adopters and $325$ controls observed in two periods. Standard errors use a joint state-clustered CR0 stacked-sandwich covariance across $37$ states, and the last two rows use the delta method.
$^{*}$, $^{**}$, and $^{***}$ denote statistical significance at the 10\%, 5\%, and 1\% , respectively.
\end{threeparttable}
\end{table}


\subsection{Average effects}

As discussed above, Table \ref{tab:estimates_dh} shows contrasts in direct and indirect effects between TWFE approaches and DR specifications under our assumptions, while the total effect estimates are stable across designs when the covariate set is held fixed.
In particular, the direct effect estimate is statistically indistinguishable from zero under the TWFE specification with linear geographic controls but is $0.429$ $(0.177)$ under our preferred linear path DR specification.
Also, we notice the sign reversal in indirect effect estimates from $0.258$ $(0.118)$ to $-0.039$ $(0.141)$, yet the latter is not statistically significant.
Under the additive-quadratic path model, the DR estimates remain qualitatively similar to the preferred linear path DR estimates, but the direct estimate loses precision.
The overlap diagnostics suggest treating this as a sensitivity analysis, not as a second preferred specification.


\section{Summary and Discussion}\label{Conclusion}


We study DiD designs where treatment changes a time-varying mediator and the mediator also affects the outcome. In such settings, policymakers may want to know the direct effect of the policy on an outcome and how much of the policy effect operates through the mediator. However, a challenge is that the mediator is endogenous and affected by the treatment, and the conventional DiD estimand may not have a clear causal interpretation. Hence, neither ignoring the mediator nor adding it as a time-varying control in a TWFE regression generally helps identify the desired policy effects.

Instead, Proposition \ref{prop:direffect} identifies $CADTT(m_0,m_1)$ by comparing outcome changes across treatment groups at a common observed mediator path, and integrating this contrast over treated paths yields $ADTT$. The result does not require parallel trends conditional on the factual mediator path under our framework, and Claim \ref{claim:interpretTWFE} explains why including $M_{it}$ in TWFE does not produce the same object. Under the addition of Assumption \ref{ass:stablebeta}, the unconditional outcome and mediator DiD moments also identify the indirect effect and the average mediator coefficient when the mediator response is nonzero.
One lesson for applied work, not only practical but also important, is that a post-treatment mediator should not be treated as an ordinary control in a DiD regression. Conditioning on the mediator path can be useful, but the target parameter and the assumptions differ from those underlying standard covariate-adjusted DiD.


This is not a mere claim but is highlighted in the empirical illustrations that we consider. In the railroad application, the linear DR path model estimates $ADTT=0.429$ and $AITT=-0.039$, with the latter imprecisely estimated. On the other hand, the same-controls TWFE claims that the direct effect is $0.090$ and cannot be statistically distinguished from zero. The second application, Alcohol Prohibition and Farm Productivity, which is reported in the Appendix, similarly shows the difference between the standard TWFE framework and our approach in the models with covariates.

However, there are several limitations pointing to useful directions for future work. First, the identifying assumptions considered here restrict the dependence between mediator shocks and outcome shocks after conditioning on the unobservables that determine treatment selection. Also, the identification of the indirect effect relies on the stability of the average mediator effect, and relaxing this restriction would require additional sources of variation or partial identification arguments.


\bibliographystyle{jpe}
\bibliography{mybib}

\clearpage