Skip to main content
NIHPA Author Manuscripts logoLink to NIHPA Author Manuscripts
. Author manuscript; available in PMC: 2026 Jun 1.
Published in final edited form as: Stat Med. 2025 Jun;44(13-14):e70123. doi: 10.1002/sim.70123

A Bayesian approach to the g-formula via iterative conditional regression

Ruyi Liu 1,2, Liangyuan Hu 3, F Perry Wilson 4, Joshua L Warren 1, Fan Li 1,2,4,*
PMCID: PMC12184534  NIHMSID: NIHMS2083649  PMID: 40476299

Abstract

In longitudinal observational studies with time-varying confounders, the generalized computation algorithm formula (g-formula) is a principled tool to estimate the average causal effect of a treatment regimen. However, the standard non-iterative g-formula implementation requires specifying both the conditional distribution of the outcomes and the joint distribution of all time-varying covariates. This process can be cumbersome to implement and is prone to model misspecification bias. As an alternative, the iterative conditional expectation (ICE) g-formula estimator solely depends on a series of nested outcome regressions and avoids the need for specifying the full distribution of all time-varying covariates. This simplicity lends itself to the natural integration of flexible machine learning techniques to develop more robust average causal effect estimators with time-varying treatments. In this work, we introduce a Bayesian approach that includes parametric regressions and Bayesian Additive Regression Trees to flexibly model a series of outcome surfaces. We fit the ICE g-formula and develop a sampling algorithm to obtain samples from the posterior distribution of the final causal effect estimator. We illustrate the performance characteristics of the Bayesian ICE estimator and the associated variations via simulation studies and applications to two real world data examples.

Keywords: Causal inference, Bayesian additive regression trees, g-formula, longitudinal propensity score, observational studies, time-varying confounding

1 |. INTRODUCTION

In longitudinal observational studies with time-varying treatments and confounders, traditional regression-based adjustment can often lead to biased causal effect estimates. This is because the confounders that are measured over time act both as intermediate outcomes of previous treatment assignments and also as confounders affecting future treatment assignments and the final outcome, thereby direct adjustment of post-treatment covariates opens up the back-door path between the treatment assignment and the final outcome.1 Under a common set of identifying assumptions, 1 g-methods have been developed as useful tools to estimate the causal effects of longitudinal treatments by properly adjusting for both the baseline and time-varying confounding; these include the generalized computation algorithm formula (g-formula),2,3,4 marginal structural models5,6 and structural nested models.7,8 Each approach has its own merits and limitations, and a comparison between their implementation and application can be found in Daniel et al.9 Among the g-methods, marginal structural models and g-formulas are relatively more commonly used (likely due to their intuitive simplicity and availability in software implementation), with the former depending on models for propensity scores (via inverse probability of treatment weighting) and the latter depending on models for the outcome as well as the history of time-varying covariates. From exploiting information within a set of outcome models, the g-formula approach can lead to more efficient causal effect estimates compared to inverse probability of treatment weighting, and may be attractive as a result.

Operationally, the implementation of the standard non-iterative g-formula requires one to model the conditional outcome distribution given the history of time-varying covariates and treatments, and additionally to model all time-varying covariates given their history, which can be pursued in either a frequentist 9 or Bayesian paradigm.10 The Bayesian implementation of the g-formula can be appealing for several reasons. It allows the incorporation of informative priors, which helps stabilize estimates especially when the sample size is small, and it provides automatic uncertainty quantification for any well-defined function of parameters. 11 For example, Keil et al. 10 discussed an implementation of the Bayesian g-formula which exploits the posterior predictive distributions to derive the point and interval estimates, and demonstrated that this approach maintains the desirable frequentist properties even when the sample size is limited or data are sparse. Chen et al. 12 developed a general class of Bayesian g-formulas for discrete-time survival data that depend on the estimated propensity and censoring scores and integrated the Bayesian Additive Regression Trees (BART) priors to alleviate concerns on fully parametric model misspecification. With discrete time-varying confounders, Josefsson and Daniels13 considered a Bayesian g-formula with BART priors to estimate the time-varying survivor average causal effects when the primary quantitative outcome is truncated by death.

Broadly, there are two available implementations of the g-formula: the noniterative conditional expectation (NICE) and the iterative conditional expectation (ICE). The aforementioned implementations of Bayesian g-formula have exclusively focused on NICE,10 which requires modeling the joint density of all time-varying confounders, and the conditional outcome distribution given the treatment and confounder history. 14 This is often a non-trivial task especially as the number of time-varying confounders increases; the complexity primarily arises from the need to account for dependencies across multiple covariates within each time period and between different time periods. Shinohara et al. 15 and Achy-Brou et al. 16 have enhanced the practicality of the NICE estimator for handling multidimensional time-varying confounders by incorporating the longitudinal propensity score as a lower-dimensional summary of all confounders, reducing the complexity of the estimation process; Chen et al. 17 advanced this implementation for causal survival analysis with time-dependent confounding. In addition to modeling time-varying covariates, NICE also requires outcome modeling. Zhou et al. 18 introduced a multiple imputation method for implementing the NICE estimator that uses penalized splines and longitudinal propensity scores to mitigate model misspecification bias and improve robustness, but still requires modeling both the time-varying confounders and the outcome. Typically, the risk of model misspecification increases as the number of models increases. The most severe model misspecification can lead to the g-null paradox, which occurs when the union of the assumed parametric models becomes inconsistent with the causal null. 19,20 As a result, these approaches may incorrectly reject the causal null a priori in sufficiently large samples, even when the null holds. These challenges motivated us to seek an implementation of the g-formula without the need to model any time-varying confounders.

In this article, our objective is to address two aforementioned limitations in existing Bayesian g-formula implementations—the daunting task of modeling time-varying covariates and the risk of g-null paradox due to potential model misspecification. To tackle the first challenge, we focus on an ICE implementation21,22,23 of the g-formula to alleviate the need to model multidimensional confounders in each time period. The ICE representation only requires a series of nested outcome models and avoids the need for specifying the joint distributions of all time-varying covariates, thus reducing the burden in modeling different types and possibly many time-varying covariates. 14,23 To address the second challenge, we leverage Bayesian nonparametric priors to represent each regression component in the ICE formulation. The parametric g-formula presupposes that the relationship between the outcome of interest and both the exposures and possible confounders should be correctly specified, and the ICE estimator may not converge in probability to the true parameter value if any component of the series of the outcome is incorrectly modeled.24 For this reason, we integrate the nonparametric prior, BART, to flexibly characterize a series of outcome models to enable the estimation of the causal effect of a specified treatment regimen. In brief, BART is a nonparametric Bayesian sum-of-trees model which uses dimensionally adaptive random basis elements.25,26 There is a burgeoning literature in adapting BART for flexible causal inference with randomized trials and observational data. For example, BART has been used to optimize dynamic treatment regimes by fitting sequential regression models, imputing counterfactual outcomes, and addressing uncertainties in decision rules. 27,28 Several previous studies have also provided empirical evidence demonstrating that BART can be particularly powerful with a time-fixed treatment, not only in terms of estimating average causal effects29,30,31 but also in identifying conditional average causal effects and quantifying treatment effect heterogeneity. 17,32,33,34,35,36 Additionally, BART has proven effective for estimating causal effects in the presence of intermediate variables. 13,37,38 When compared to other Bayesian nonparametric methods, such as Dirichlet process priors, 39 Gaussian process priors, 40 and Gamma process priors, 41 BART may enjoy the advantage of computational efficiency and minimal tuning requirements. However, little is known about the performance of BART in studying time-varying treatments as a flexible modeling strategy to alleviate model misspecification concerns.

The remainder of this article is organized as follows. In Section 2, we provide a review of parametric g-formula using ICE and the identifying assumptions with time-varying treatment and confounding. In Section 3, we describe a Bayesian ICE estimator and propose a sampling algorithm to obtain samples from the posterior distribution of the average causal effect estimator in the context of linear regression. We show that the requisite sampling procedure must accurately propagate the uncertainty in each stage of regression, and introduce a multistage sampling algorithm for inference. To alleviate concerns on parametric model misspecification, we employ in Section 4 a nonparametric prior specification of each mean function using BART, 27 and further incorporate the estimated longitudinal propensity scores as additional covariates when modeling the responses. In Section 5, we conduct simulations to examine the finite-sample performance of the Bayesian ICE approach and draw comparisons to competing methods under different data-generating processes. Two illustrative data examples are presented in Section 6. Section 7 concludes.

2 |. PARAMETRIC G-FORMULA WITH ITERATIVE CONDITIONAL EXPECTATION: A REVIEW

2.1 |. Notation and estimand

We consider a longitudinal observational study with treatment assignment at multiple time points which can depend on the history of time-varying covariates and past treatments. Assume that we have n independent and identically distributed copies of sequences of observables L1,A1,,LK,AK,Y obtained from n individuals, where K denotes the number of time periods. The variable Y is the final outcome of interest observed at the end of the K-th time interval. For k=1,,K,Ak{0, 1} is the binary treatment indicator given at the k-th time interval and Lk is a vector of covariates measured at the start of the k-th time interval just prior to the treatment assignment Ak. A directed acyclic graph illustrating the causal relationships between the full sequence of observables is shown in Figure 1.

Figure 1.

Figure 1

Directed acyclic graph (DAG) representing the causal relationships between all observables in a typical longitudinal observational study.

Let AkA1,,Ak be the treatment history up to the k-th interval, L¯kL1,,Lk be the history of confounders up to the k-th interval, and OkL1,A1,,Lk be the combined history of all past information. Under the potential outcomes framework, we can write YaK as the potential outcome at the end of the study when treatment regimen aK is followed. For example, consider a scenario with six time intervals. An intervention regimen might be represented as aK(*)=(1,1,1,1,1,1), which denotes the assignment of a continuously active intervention throughout the entire six-month period. An alternative regimen can be represented as aK(**)=(0,0,0,1,1,1), indicating the control condition for the initial three-month period, followed by an active intervention for the subsequent three months. We pursue a super-population framework, 42 and define the population average treatment effect estimand (abbreviated as average treatment effect), comparing two intervention regimens aK(*) with aK(**), as EYaK(*)YaK(**); here, the expectation is defined over a super-population of which the observed sample is representative. For clarity and ease of reference, a glossary of key notation in this work is provided in Table 1.

Table 1.

A glossary of notation.

Notation Explanation

Introduced in Section 2
n Number of individuals in the study or sample size.
K Number of time periods.
Y Final outcome of interest observed at the end of the K-th time interval.
Ak Binary treatment indicator at time interval k.
L k Vector of covariates measured at the start of the k-th time interval prior to the treatment assignment Ak.
A¯k Treatment history up to time interval k,(A1,,Ak).
L¯k Covariate history up to time interval k,(L1,,Lk).
O¯k Combined history of all past information, (L1,A1,,Lk), up to time interval k.
Y(a¯k) Potential outcome under treatment regimen a¯K
Y(A¯k,a_k+1) Potential outcome had an individual received the observed treatment regimen A¯k during the initial k time intervals, followed by treatment assignment a_k+1 from the k + 1 time interval onward.
fK(a¯K,l¯K) Expectation of the observed outcome at the last observation time point K given the entire history.
fk(a¯K,l¯k) Expectation of the nested (pseudo) outcome at time k + 1 conditional on the treatment history a¯k and the covariate history l¯k up to the k-th interval.
δk Vector of regression coefficients parameterizing the conditional expectation function fk(·).
δ^k Estimator for δk.
Y^k(A¯k1,a_k) Predicted values of the outcome from a fitted regression model at time k, that is, Y^k(A¯k1,a_k)=fk(A¯k1,a_k,L¯k;δ^k).
𝒜 Set of treatment regimens of interest.

Introduced in Section 3
σk2 Variance of the error term in a postulated regression model at time k.
pδk(δk) Generic notation for prior distribution on δk.
pσk2(σk2) Generic notation for prior distribution on σk2.
pk,n(|) Generic notation for full conditional distribution of parameters at time k
y˜a2 A generic argument representing a draw from the time-2 posterior predictive distribution given treatment a2.
y˜(a1,a2) A generic argument representing a draw from the time-1 posterior predictive distribution given treatment regimen (a1, a2).
D K The full observed data up until the last time interval K.
D k Observed history up to time k and the pseudo-outcomes generated by fitted outcome model at time k + 1, k{1,,K1}.
τ(a1,a2),(a1,a2) Causal estimand: population average treatment effect, defined in equation (1).
τ^(a1,a2),(a1,a2) Estimated average treatment effect comparing regimens (a1, a2) and (a1,a2), defined in equation (10).

Introduced in Section 4
x Vector of q generic covariates, x=(x1,,xq).
m Number of regression trees in BART.
Tj The j-th binary tree structure in BART.
bj Number of terminal nodes in tree Tj.
Mj Set of parameter values associated with each of the terminal nodes in the j-th tree, Mj={μj1,,μjbj}.
μjl l-th terminal node value in the j-th tree.
g(x;Tj,Mj) Function assigning a terminal node value to x according to the j-th binary tree.
p(Tj) Prior distribution on tree structure Tj.
p(μil|Tj) Prior distribution on terminal node parameters μjl.
p(σ) Prior distribution on error standard deviation σ.
πk Longitudinal propensity score at time k.

2.2 |. Iterative conditional expectation

Given that we can observe only one potential outcome corresponding to the observed treatment sequence, the potential outcomes under the treatment regimens of interest cannot be fully observed for each individual. To identify the estimand, several standard assumptions are employed. Define fKaK,lKEYAK=aK,L¯K=lK as the mean outcome at the last observation time point K given the entire history, and for k{K1,,1}, we define

fk(a¯K,l¯k)E(fk+1(a¯K,lk+1)|A¯k=a¯k,L¯k=l¯k).

Let f0aKEf1aK,l1. Here, fkaK,l¯k represents the expected value of the nested outcome at time k+1 conditional on the treatment history ak and the covariate history l¯k up to the k-th interval; it captures the dependence of future outcomes on past treatments and covariates in an iterative fashion. Importantly, the subscript k of fk acknowledges that the conditional mean function is time-specific, and should match the subscript of time-varying confounder argument l¯k (but not necessarily the subscript of the treatment assignment argument aK). Under the identifying assumptions of (1) consistency: YaK=Y if AK=aK,L¯ak=L¯k if Ak=ak, (2) no unmeasured confounding: for all aK and k,YaKAkL¯k=l¯k,Ak1=ak1, and (3) positivity: for all ak and k, if PAk1=ak1,L¯k=l¯k>0, then PAk=akAk1=ak1,L¯k=l¯k>0, it has been shown that EYaK is point identified, i.e., the expectation of the counterfactual outcomes can be written in terms of the observed data. 3,24 That is, there exists a nested relationship such that fkaK,l¯k=Efk+1aK,l¯k+1Ak=ak,L¯k=l¯k=EYaKAk=ak,Lk=lk, for k{1,,K1} and f0aK=EYaK. The original proof of this result is given in Robins et al., 2 and we reproduce the proof in Appendix 1 for ease of reference. This approach has been referred to as the iterative conditional expectation, or ICE.

To operationalize the parametric g-formula via ICE, we first posit a series of parametric models such that fkAK,L¯k=fkAK,L¯k;δk,1kK, where δk is a finite-dimensional regression coefficient vector. For example, with a continuous final outcome (such as blood pressure measured at the end of the longitudinal study), a natural choice may be linear regression, to estimate the expected outcome based on a possible treatment assignment sequence and the history of confounders up to a certain time interval k. We introduce YAk,a_k+1 as the potential outcome of an individual if had that individual received the observed treatment regimen Ak during the initial k time intervals, followed by treatment assignment a_k+1 from the k+1 time interval onward until the end of study. 43

For point estimation, one can compute δ^K which solves the estimating equation (i.e., the score equation derived from the log likelihood function) defined by the outcome model fK given all histories with parameters δK, PnδKfKAK,LK;δKYfKAK,LK;δK=0, where Pn(V)1ni=1nVi is the empirical expectation. For k{K1,K2,,1}, with the assumed model at time K and the estimated parameter value δ^K, we can generate the pseudo-outcomes at time K for each individual under all possible regimens Y^KAK1,a_KfKAK1,a_K,LK;δ^K, where a_K{0,1}. These obtained pseudo-outcomes will be used in the next regression at time K1 to estimate the parameters for the outcome model, fK1, by solving the corresponding estimating equations. Then, pseudo-outcomes at time K1 can be further imputed based on δ^K1. Therefore, in a sequential manner, for k{K1,K2,,1}, we can iteratively compute δ^k by solving the score equation with pseudo-outcomes obtained from the previous regression model. Within each iteration, we use δ^k to impute the pseudo-outcomes for each person considering the actual treatment path observed until time k,Ak, and all future treatment regimen of interest up until the end of the study, a_k+1. For example, consider a linear regression defined at time k, then Y^k+1Ak,a_k+1=fkAk,a_k+1,L¯k;δk+ϵk, where fk is a linear function of treatment history and covariates, ϵk is the mean-zero error term, and Y^k+1 are predicted values of the outcome from a fitted regression model at time k+1. The estimated parameters δ^k are obtained by regressing pseudo-outcomes at k+1 on the treatment and confounder history up to time k (Ak and L¯k) and the all possible future treatment regimens (a_k+1{0,1}Kk), based on ordinary least squares. In general, the pseudo-outcomes imputed at time k are used to estimate the model parameters at time k1. This sequential regression is repeated from the end of the study, k=K, to k=1. Once we have δ^1, we can obtain the predicted potential outcomes for each individual under all treatment regimen of interest, Y^1a_1=Y^1aK=f1a_1,L¯1;δ^1. Finally, the ICE estimator of EYaK is obtained as the empirical average of Y^1aK across all individuals. Under the series of assumed models, fk,k{1K}, the parametric ICE estimator is consistent and asymptotically normally distributed. 24

It is worth noting that, in a study focusing on comparing only a subset of potential treatment regimens, rather than all possible 2K regimens, computational complexity can be reduced by imputing potential outcomes solely for the regimens of interest. The generic procedure for carrying out imputation without limiting the set of regimens is illustrated in Table 2, where the potential outcomes for all 2K possible regimens are imputed through sequential regression. In contrast, Table 3 demonstrates a computationally simpler process when restrictions are applied to the set of regimens 𝒜 directly relevant to the set of estimands of interest. Consider the simple example where we wish to examine the average treatment effect by comparing the never-treat regimen (0, 0, 0) with the always-treat regimen (1, 1, 1). Without restrictions, the ICE estimator would impute the potential outcomes of (A1,A2,1) and (A1,A2,0) at k=3; impute the potential outcomes of (A1,1,1),(A1,0,1),(A1,1,0), and (A1,0,0) at k=2; and impute the potential outcomes of all 8 possible treatment regimens at k=1. However, with restrictions on the set of regimens, 𝒜={(0,0,0),(1,1,1)}, the imputation procedure would still impute the potential outcomes of (A1,A2,1) and (A1,A2,0) at k=3, but only impute the potential outcomes of (A1,1,1) and (A1,0,0) at k=2, and only impute the potential outcomes of (0, 0, 0) and (1, 1, 1) at k=1. This imputation procedure is most useful when the number of time intervals is large, in which case addressing all 2K potential outcomes becomes computationally prohibitive. Only potential outcomes corresponding to regimens in 𝒜 are considered in creating the pseudo-outcomes at each time interval. The cardinality of 𝒜 is usually much smaller than 2K. In what follows, for the sake of generality, we do not restrict the space of regimens and employ unrestricted imputation to demonstrate our method in the more general case. The modification of the general procedure with a smaller 𝒜 is straightforward.

Table 2.

Imputation of potential outcomes at three time intervals without restricting the set of regimens. “k” represents the step of imputation. “Observed Regimen” refers to the actual treatment sequence assigned to an individual. “” indicates the available imputed potential outcomes at each step. “?” marks the missing potential outcomes at each step.

Time Interval Observed Regimen Imputed Potential Outcomes
A 1 A 2 A 3 Y^(0, 0, 0) Y^(0, 0, 1) Y^(0, 1, 0) Y^(0, 1, 1) Y^(1, 0, 0) Y^(1, 0, 1) Y^(1, 1, 0) Y^(1, 1, 1)
k = 3 0 0 0 ? ? ? ? ? ?
0 0 1 ? ? ? ? ? ?
0 1 0 ? ? ? ? ? ?
0 1 1 ? ? ? ? ? ?
1 0 0 ? ? ? ? ? ?
1 0 1 ? ? ? ? ? ?
1 1 0 ? ? ? ? ? ?
1 1 1 ? ? ? ? ? ?

k = 2 0 0 0 ? ? ? ?
0 0 1 ? ? ? ?
0 1 0 ? ? ? ?
0 1 1 ? ? ? ?
1 0 0 ? ? ? ?
1 0 1 ? ? ? ?
1 1 0 ? ? ? ?
1 1 1 ? ? ? ?

k = 1 0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1

Table 3.

Imputation of potential outcomes at three time intervals with restrictions on the set of regimens. 𝒜={(0, 0, 0),(1, 1, 1)} is the set of treatment regimens of interest. “k” represents the step of imputation. “Observed Regimen” refers to the actual treatment sequence assigned to an individual. “” indicates the available imputed potential outcomes at each step. “?” marks the missing potential outcomes at each step.

Time Interval Observed Regimen Imputed Potential Outcomes
A 1 A 2 A 3 Y^(0, 0, 0) Y^(0, 0, 1) Y^(0, 1, 0) Y^(0, 1, 1) Y^(1, 0, 0) Y^(1, 0, 1) Y^(1, 1, 0) Y^(1, 1, 1)
k = 3 0 0 0 ? ? ? ? ? ?
0 0 1 ? ? ? ? ? ?
0 1 0 ? ? ? ? ? ?
0 1 1 ? ? ? ? ? ?
1 0 0 ? ? ? ? ? ?
1 0 1 ? ? ? ? ? ?
1 1 0 ? ? ? ? ? ?
1 1 1 ? ? ? ? ? ?

k = 2 0 0 0 ? ? ? ? ? ?
0 0 1 ? ? ? ? ? ?
0 1 0 ? ? ? ? ? ?
0 1 1 ? ? ? ? ? ?
1 0 0 ? ? ? ? ? ?
1 0 1 ? ? ? ? ? ?
1 1 0 ? ? ? ? ? ?
1 1 1 ? ? ? ? ? ?

k = 1 0 0 0 ? ? ? ? ? ?
0 0 1 ? ? ? ? ? ?
0 1 0 ? ? ? ? ? ?
0 1 1 ? ? ? ? ? ?
1 0 0 ? ? ? ? ? ?
1 0 1 ? ? ? ? ? ?
1 1 0 ? ? ? ? ? ?
1 1 1 ? ? ? ? ? ?

3 |. A BAYESIAN PARAMETRIC G-FORMULA VIA ITERATIVE CONDITIONAL EXPECTATION

In the rest of the article, we consider the Bayesian paradigm for inference; further rationales for pursuing Bayesian inference in our setting are provided in Section 1. Under this paradigm, the posterior predictive distribution of the potential outcomes can be derived by integrating over the posterior distributions of the unknown parameters for causal inference. To clearly demonstrate the algorithm for better intuition, our discussion is presently centered on a Bayesian ICE framework with two time intervals and a continuous outcome Y. This approach is readily generalizable to accommodate multiple time periods and categorical outcomes. To elucidate the essential components of the sampling step in the Bayesian ICE approach, we consider linear regression. We opt for a series of nested linear regressions to also ensure compatibility between the conditional and marginal models in terms of the time-varying covariates and therefore reducing the concern about model compatibility. After detailing the sampling algorithm, we will relax these modeling assumptions by incorporating Bayesian nonparametric priors with more flexible mean function specification to enhance the robustness in Section 4.

This estimation algorithm uses the Bayesian ICE approach to numerically approximate the posterior predictive distribution of the potential outcomes, as well as to derive quantities from a comparison of potential outcomes under two treatment regimens.10 With two time intervals, the average treatment effect that compares the regimen a1,a2 with regimen a1,a2 is defined as

τ(a1,a2),(a1,a2)=E[Yi(a1,a2)Yi(a1,a2)],for(a1,a2)(a1,a2){0,1}2. (1)

To estimate this quantity, we start by first specifying the time-2 outcome model, which depends on the individual’s history up to time k=2. Assuming an outcome regression model for the potential outcomes, we have

Y(A1,A2)=f2(O¯2,A2;δ2)+ϵ2, (2)

where O2=L1,A1,L2 is the individual’s history at time k=2,δ2 is an unknown parameter vector for time-2 outcome model, and ϵ2 is the error term. In a linear regression setting, a common specification of the mean function is f2O2,A2;δ2=δ2,0+δ2,1A1+δ2,2A2+δ2,3L1+δ2,4L2,ϵ2𝒩0,σ22, and σ22 is the variance of the error term. The outcome is then modeled as

Y(A1,A2)ϕ2(y|O¯2,A2;δ2,σ22)=𝒩(f2(O¯2,A2;δ2),σ22). (3)

We then proceed by specifying the prior distributions of δ2 and σ22, denoted as pδ2δ2 and pσ22σ22. In the absence of additional external information, we specify conjugate, weakly-informative priors, facilitating straightforward analytical calculations of the posterior distributions and sampling procedures. Specifically, we use a weakly informative multivariate normal prior (e.g., mean 0 and a diagonal variance matrix with diagonal entries equal to 100) for the regression coefficients and a weakly informative inverse-gamma prior (e.g., the shape and rate parameters both set to 0.001) for the error variance, which are standard choices in Bayesian regression modeling.44 Leveraging the observed data at time k=2,D2=L1,i,A1,i,L2,i,A2,i,Yii=1n, we draw from the joint posterior distribution of δ2 and σ22 via Gibbs sampling. Samples from the posterior distribution of time-2 model parameters are obtained by iterative draws from the full conditionals:

p2,n(δ2|D2,σ22)pδ2(δ2)i=1nϕ2(yi|O¯2,A2;δ2,σ22),
p2,n(σ22|D2,δ2)pσ22(σ22)i=1nϕ2(yi|O¯2,A2;δ2,σ22),

which are themselves multivariate normal and inverse-gamma, respectively. For each draw of (δ^2,σ^22) after burn-in, we then generate the pseudo-outcomes for each unit under observed treatment history A1 and all possible treatment assignments at k=2. The time-2 posterior predictive distribution of the potential outcome under time-2 treatment a2 is defined as

p(y˜a2|D2)Eδ2,σ22|D2[p(y˜a2|δ2,σ22)], (4)

where the expectation is defined based on the joint posterior, pδ2,σ22D2, obtained through Gibb sampling, y~a2 is a generic argument representing a draw from the time-2 posterior predictive distribution after setting the treatment at k=2 as A2=a2. Each unit i has two pseudo-outcomes Y^i,2A1,i,1 and Y^i,2A1,i,0, respectively, at time 2; hence Y^2=Y^i,2A1,i,0,Y^i,2A1,i,1i=1n is a vector with 2n entries, reflecting two predictions per unit for all n units.

Next, for each generated Y^2, we move to the previous time point k=1. The time-1 outcome model is defined similarly,

Y(A1,a2)=f1(L1,A1,a2;δ1)+ϵ1, (5)
Y(A1,a2)ϕ1(y|L1,A1,a2;δ1,σ12)=𝒩(f1(L1,A1,a2;δ1),σ12), (6)

where a2{0,1},δ1 is the unknown parameter vector, σ12 is the error variance, and ϵ1𝒩0,σ12. In linear regression setting, we may specify f1L1,A1,a2;δ1=δ1,0+δ1,1A1+δ1,2a2+δ1,3L1. Prior distributions for δ1 and σ12 are specified as pδ1δ1 and pσ12σ12, respectively. With similar conjugate and weakly informative priors as in the time-2 model, the time-1 model posterior parameter distribution is calculated using the observed history at the first time interval and the pseudo-outcomes, denoted as D1=L1,i,A1,i,0,Y^i,2A1,i,0,L1,i,A1,i,1,Y^i,2A1,i,1i=1n. Then, conditional on D1, the time-1 samples from the posterior distribution are obtained by iterative draws from the full conditionals:

p1,n(δ1|D1,σ12)pδ1(δ1)i=1na=01ϕ1(yi|L1,A1,a2=a;δ1,σ12), (7)
p1,n(σ12|D1,δ1)pσ12(σ12)i=1na=01ϕ1(yi|L1,A1,a2=a;δ1,σ12), (8)

which are again themselves multivariate normal and inverse-gamma, respectively, due to conjugacy.

For inference, we consider the idea of nested multiple imputation, which is an effective approach to mix the draws from multiple posterior distribution.45 In other words, for each draw of (δ^2,σ^22), multiple draws of (δ^1,σ^12) are retained to predict the time-1 pseudo-outcomes. The time-1 posterior predictive distribution of the potential outcome under the specified treatment regimen (a1,a2) is defined as

p(y˜(a1,a2)|D1)Eδ1,σ12|D1[p(y˜(a1,a2)|δ1,σ12)], (9)

where pδ1,σ12D1 can be obtained through time-1 joint posterior distribution approximated through Gibbs sampling, and y~a1,a2 is a generic argument representing a draw from the time-1 posterior predictive distribution given treatment regimen a1,a2. In practice, for each draw of δ^1,σ^12 preserved, we generate the time-1 pseudo-outcomes for each unit from ϕ1yL1,a1,a2;δ^1,σ^12, where a1,a2{0,1}. Then, each unit i has four predicted outcomes Y^i,1(1,1),Y^i,1(1,0),Y^i,1(0,1), and Y^i,1(0, 0), respectively. Y^1=Y^i,1(0, 0),Y^i,1(0, 1),Y^i,1(1, 0),Y^i,1(1, 1)i=1n is the vector with 4n entries, reflecting four predictions per unit for all n units. Thus, we obtain every participant’s time-1 pseudo-outcomes under all possible treatment assignment sequences (a1,a2) of interest in the study.

To enhance the efficiency of Markov chain Monte Carlo (MCMC) methods, thinning is an important technique to reduce the autocorrelation between successive samples, ensuring that the draws are as independent as possible and represenstative of the posterior distribution. By selectively retaining only a limited number of draws from the MCMC chain, thinning mitigates the effects of serial correlation, leading to a more robust and effective approximation of the posterior. For time 2, consider the total number of draws to be S2, with B2 burn-in and a thinning rate of t2, resulting in C2=S2B2t2 final samples retained at time 2. The pseudo-outcome vector corresponding to each retained draw at time 2 is denoted as Y^2(1),,Y^2C2. Similarly, for each retained sample at time 2, consider the number of draws at time 1 to be S1, with B1 burn-in and a thinning rate of t1, resulting in C1=S1B1t1 final samples retained at time 1. Then, for a fixed draw, c2, from time 2, the time 1 pseudo-outcome vector corresponding to each retained draw at time 1 is denoted as Y^1c2,1,,Y^1c2,C1. The total number of draws for the two time intervals is C=C1×C2.Y^i,1c2,c1a1,a2 and Y^i,1c2,c1a1,a2 are the imputed potential outcomes of individual i for the treatment regimens a1,a2 and a1,a2 respectively, based on the c2-th retained posterior draw from time 2, and the according c1-th retained draw from time 1. The point estimator for τa1,a2,a1,a2 is estimated by calculating the difference of the posterior means of the imputed average potential outcomes,

τ^(a1,a2),(a1,a2)=1C1×C2c2=1C2c1=1C1τ^(a1,a2),(a1,a2)(c2,c1)=1C1×C2c2=1C2c1=1C1{1ni=1n(Y^i,1(c2,c1)(a1,a2)Y^i,1(c2,c1)(a1,a2))}. (10)

The 95% quantile-based credible interval is determined by computing the 2.5-th and 97.5-th percentiles of the posterior distribution. The implementation of this algorithm with two time intervals is outlined in Algorithm 1.

It is important to note that the estimand comparing regimen a1,a2 with a1,a2,τa1,a2,a1,a2, defined in Equation (1), is a population average treatment effect. By construction, this estimand is a function of the distribution of the potential outcomes in the target population, integrated over the population distribution of baseline confounders. In principle, one needs to model the distribution of the baseline confounders L1 in order to target such a quantity. However, in practice, accurately modeling multidimensional baseline confounders can be cumbersome and prone to bias under parametric model misspecification. As an alternative, we integrate over the empirical distribution of the baseline confounders to implement our estimator in (10). In the terminology of Li et al.,42 our target estimand should be regarded as a mixed average treatment effect, which approximates the population average treatment effect by replacing the theoretical distribution over L1 in the target population with its empirical distribution. This approach is the focus of most Bayesian causal inference methods,29,46 and is adopted both for convenience and to avoid additional model misspecification bias.

4 |. INTEGRATING BAYESIAN ADDITIVE REGRESSION TREES

4.1 |. Model formulation

A challenge with Bayesian ICE approach under linear regression working models is the risk of parametric model misspecification. The parametric g-formula assumes that the relationship between the outcome of interest, exposures, and potential confounders is correctly specified. However, if any component of the outcome model is incorrectly specified, the ICE estimator may fail to converge to the true parameter value in probability. To alleviate bias from potential model misspecification, we consider BART,25 a Bayesian nonparametric prior, as a more flexible way to model the series of outcome surfaces for the estimation of average treatment effect comparing two prespecified treatment regimen. BART has emerged as a popular tool with a wide range of applications, particularly in estimating the average and heterogeneous causal effects.29,47,48,34,35 Tan and Roy26 provide a comparative tutorial, demonstrating the superiority of BART over parametric regressions when data are generated from a complicated outcome surface. Although our primary focus is on continuous outcomes, the methodological flexibility of BART allows its application across various types of outcomes.49,50,51

Algorithm 1.

A Bayesian ICE sampling algorithm with K = 2 time intervals

 1: Input: Observed data: Dn. Prior distributions for model parameters at time 1 and 2.
 2: Define time-2 outcome model based on the observed individual’s history at time k = 2.
Y(A1,A2)=f2(O¯2,A2;δ2)+ϵ2,ϵ2𝒩(0,σ22).
 3: Initialize time-2 model parameters and prior distributions, pδ2(δ2) and pσ22(σ22).
 4: Obtain samples from the time-2 posterior distribution using Gibbs sampling.
 5: Consider the total number of draws to be S2, with B2 burn-in and a thinning rate of t2.
 6: The number of retained samples at time 2 is C2=S2B2t2.
 7: for c2{1,,C2} do
 8:   (δ2(B2+t2c2),σ22(B2+t2c2)) denotes the c2-th retained posterior draw of time-2 model.
 9:   Generate the time-2 pseudo-outcomes, Y^2(c2)={Y^i,2(c2)(A1,i,0),Y^i,2(c2)(A1,i,1)}i=1n.
10:   Use Y^2(c2) as the outcome for time-1 model.
11:   Specify time-1 outcome model,
Y(A1,a2)=f1(L1,A1,a2;δ1)+ϵ1,ϵ1𝒩(0,σ12).
12:   Specify prior distributions of time-1 model parameters, pδ1(δ1) and pσ12(σ12).
13:   Obtain samples from the time-1 parameter posterior distribution.
14:   Consider the number of draws at time 1 to be S1, with B1 burn-in and a thinning rate of t1.
15:   The number of retained samples at time 1 is C1=S1B1t1.
16:   for c1{1,,C1} do
17:     Based on Y^2(c2),(δ1(c2,B1+t1c1),σ12(c2,B1+t1c1)) denotes the c1-th retained draw at time 1.
18:     Generate the time-1 pseudo-outcomes,
Y^1(c2,c1)={Y^i,1(c2,c1)(0,0),Y^i,1(c2,c1)(0,1),Y^i,1(c2,c1)(1,0),Y^i,1(c2,c1)(1,1)}i=1n.
19:     Estimate the posterior sample of causal contrast comparing regimens (a1, a2) and (a1,a2),
τ^(a1,a2),(a1,a2)(c2,c1)=1ni=1n(Y^i,1(c2,c1)(a1,a2)Y^i,1(c2,c1)(a1,a2)).
20:   end for
21: end for
22: The point estimate of average treatment effect comparing regimen (a1, a2) with (a1,a2) is
τ^(a1,a2),(a1,a2)=1C1×C2c2=1C2c1=1C1τ^(a1,a2),(a1,a2)(c2,c1).
23: Compute the 95% credible interval of estimated average treatment effect by taking the 2.5-th and 97.5-th percentile of (τ^(a1,a2),(a1,a2)(1,1),,τ^(a1,a2),(a1,a2)(C2,C1)).
24: Output: The estimated treatment effect, τ^(a1,a2),(a1,a2), and its credible interval.

The BART is composed of two main parts: a sum-of-trees model and a regularization prior on the model parameters.25 Suppose that the final outcome Y is related to q generic covariates, represented as x=x1,,xq, and the BART is given by

Y=j=1mg(x;Tj,Mj)+ϵ, (11)

where ϵN0,σ2. It approximates the mean function using a sum of m regression trees denoted as j=1mgx;Tj,Mj, where Tj is the j-th binary tree structure and Mj=μj1,,μjbj denotes a set of parameter values associated with each of the bj terminal nodes in tree Tj.25 An increase in m enhances the model flexibility, but the choice of m can affect the computational demand. Previous work indicates that, starting with m=1, the predictive performance of BART improves dramatically until at some point it levels off and then begins to very slowly degrade for even larger values of m.25 A specification of m=50 trees is often deemed sufficient according to Bleich et al. 52 Compared to the linear mean model specification, a major advantage of BART is its flexibility in capturing the potentially complex functional form of covariates in the mean function.26 The function gx;Tj,Mj assigns a terminal node value μjlMj to x according to binary tree Tj. The mean function, E(Yx), is the sum of all the terminal node values assigned to x by each of the binary regression tree. When the number of trees m exceeds one, each μjl contributes only partially to E(Yx). Additionally, μjl represents a main effect if gx;Tj,Mj depends on a single component of x, and an interaction effect if it depends on multiple components. 25 Thus, the sum-of-trees model by construction automatically addresses both main effects and interaction effects, enhancing the predictive performance.

To achieve regularization, BART assigns priors for paramaters T1,M1,,Tm,Mm, and the variance σ2. The regularization priors can prevent any single tree from having an overwhelming influence on the final model prediction. The priors are designed such that the tree components T1,M1,,Tm,Mm and σ2 are a priori independent and that the tree components T1,M1,,Tm,Mm are independent of each other. The specification only requires for priors pTj,pμjlTj and p(σ). For the tree structure prior pTj, the default specifications by Chipman, George, and McCulloch53 (CGM98) are used.25 The terminal node parameter priors pμjlTj are the conjugate normal distribution, and the prior on σ2 is an inverse Chi-squared distribution where the hyperparameters can be chosen by cross-validation. With these priors, posterior inference for a single BART model proceeds through an iterative Bayesian backfitting MCMC algorithm.25

4.2 |. Outcome models for two time intervals

To flexibly model a series of outcome surfaces under the ICE representation using the BART model, the time-2 outcome model is given by

Y(A1,A2)=f2(L1,A1,L2,A2)+ϵ2=j=1mg2(L1,A1,L2,A2;T2j,M2j)+ϵ2,

where ϵ2𝒩0,σ22. Similarly, the time-1 outcome model is given by a separate BART specification based on the pseudo-outcomes

Y(A1,a2)=f1(L1,A1,a2)+ϵ1=j=1mg1(L1,A1,a2;T1j,M1j)+ϵ1,

where ϵ1𝒩0,σ12. Instead of generating posterior samples from the posterior distributions of the linear model parameters in linear regression (or other parametric regression), we now draw posterior samples of f2,σ2 at time 2, and f1,σ1 at time 1. The remaining steps of the sampling algorithm referred to in Algorithm 1 are unchanged from Section 3. Figure 2 presents a schematic illustration of the sampling process for K=2 time intervals using BART to model outcome surfaces under the ICE representation (BART-ICE), with prespecified numbers of MCMC draws for each BART fitting, burn-in, and thinning rate at both time points.

Figure 2.

Figure 2

Schematic of a BART-ICE sampling procedure for K=2 time intervals. Yobs denotes the observed outcome vector. Lk denotes a set of confounders measured at the beginning of the k-th interval. Ak denotes a binary treatment in the k-th time interval. The notation Y() represents a model where Y is the outcome and the terms inside the parentheses denote predictor variables, with lowercase terms indicating fixed values. At time 2, let the total number of draws be S2, with B2 draws discarded as burn-in and a thinning rate of t2, resulting in C2=S2B2t2 retained samples. f2B2+t2c2,σ2B2+t2c2 denotes the c2-th retained draw from time-2 BART posterior, which generates the pseudo-outcomes Y^2c2 at time 2. For each retained sample at time 2, let the number of draws at time 1 be S1, with B1 burn-in and a thinning rate of t1, resulting in C1=S1B1t1 retained samples. Then, for a fixed draw c2 from time 2, f1c2,B1+t1c1,σ1c2,B1+t1c1 denotes the c1-th retained draw from time-1 BART posterior. Y^1c2,c1 denotes the time-1 pseudo-outcomes generated by f1c2,B1+t1c1,σ1c2,B1+t1c1.τ^c2,c1 is the estimated average treatment effect calculated from Y^1c2,c1. The total number of draws retained for the two time intervals is C=C1×C2.

4.3 |. Incorporation of longitudinal propensity scores

With a time-fixed treatment and a single time interval, Dorie et al.35 and Hahn et al.34 considered the inclusion of an estimated propensity score as an additional covariate in BART to enhance its robustness and efficiency for causal inference. With a time-to-event outcome, Hu et al.33 also demonstrated that incorporating an estimated propensity score into the set of covariates in an accelerated failure time BART model can further enhance the efficiency in estimating conditional average treatment effect. With time-varying treatments and under a NICE formulation, Achy-Brou et al.16 and Chen et al.12 developed the g-formula that includes an estimated longitudinal propensity score as a low-dimensional covariate that is sufficient to control for all time-varying confounding, for non-censored and censored outcomes, respectively. Following Achy-Brou et al.,16 the assumption of unconfoundedness given covariates implies unconfoundedness given longitudinal propensity scores. This suggests that the treatment assignment can be considered ignorable given the propensity scores. Consequently, adjusting for longitudinal propensity scores is sufficient to address time-varying confounding. More generally, as pointed out in Zigler et al.,54 a Bayesian regression estimator that adjusts for the estimated propensity score along with all confounders in the propensity score model is akin to a doubly robust estimator, which consistently estimate the causal effect when either the propensity score model or the model for additional confounder adjustment is correct. Similarly, Li et al.42 mentioned that such a specification implicitly conducts regression within each propensity score strata to address residual confounding and is considered as a Bayesian analog of a doubly robust estimator (even though it does not strictly possess the frequentist double robustness property). These prior discussions have motivated us to adopt a similar approach under the ICE formulation, using the estimated longitudinal propensity scores as additional covariates. Following Hahn et al.,34 one may not necessarily need to explicitly address the uncertainty of the estimated propensity score in a BART model, as Bayesian inference on treatment effects is derived directly from the conditional distribution of the outcome given treatments and time-varying covariates, with the estimated longitudinal propensity scores being functions of these covariates. Furthermore, the estimated longitudinal propensity scores are included in the model along with the full covariate vector, and therefore this approach should be at least as capable of estimating a complex response surface as the corresponding model without propensity scores.

In our setting, the longitudinal propensity score is defined as the conditional probability of receiving a treatment given pretreatment covariates at each time interval.55 In the two time interval scenario, the longitudinal propensity scores is given by πk=PrAk=1Ak1,L¯k,k=1,2. Assuming πˆ1 and πˆ2 are estimates of longitudinal propensity scores, π1 and π2, we consider a variant of the Bayesian ICE estimator that includes L1,π1,A1,L2,π2,A2 in the time-2 model formulation, and includes L1,π1,A1,a2 in the time-1 model formulation. To mitigate potential model misspecification issues, we obtain the longitudinal propensity score estimates, π^1 and π^2, nonparametrically using the Super Learner.33 We employ a Super Learner due to its flexibility to draw tools from multiple libraries, and highly accurate performance in binary classification problems.56 These propensity score estimates are then treated as fixed covariates throughout all time intervals.

5 |. SIMULATION STUDIES

5.1 |. Simulation design

To compare the empirical performance of the BART-ICE estimators and the estimators derived from modeling outcome surfaces by fitting parametric linear regression (BLR-ICE) as well as other frequentist ICE alternatives, we carry out a series of simulation studies, focusing on estimating the average treatment effect in the context of longitudinal observational studies. Throughout we consider a total sample size of n=500 and K=2 time intervals, comparing regimen (1, 1) with (0, 0).

In the first time interval, we simulate p1=3 covariates, where X11 and X21 are drawn from the standard normal distribution 𝒩(0,1), and X3 is drawn from a folded normal distribution, i.e., X3=|Z|,Z𝒩(0,1). X11 and X21 are time-varying covariates while X3 is a baseline covariate. The treatment assignment in the first time interval is generated from A1X11,X21,X3Bernoulliπ1. The true propensity score in the first time interval follows

π1=Pr(A1=1|X11,X21,X3)=exp{γ1L112}1+exp{γ1L112},

where γ1=(1,0.5, 0.25) and L1=X11,X21,X3. In the second time interval, we simulate p2=2 covariates. X12=Z12U2 and X22=Z22U2, where Z12 and Z22 are drawn from the standard normal distribution, and U2=2+2A11/3. The treatment assignment at the second time interval is generated from Bernoulliπ2. The true propensity score follows

π2=Pr(A2=1|X11,X21,X3,A1,X12,X22)=exp{A1+γ2L2+14}1+exp{A1+γ2L2+14},

where γ2=(1,0.5) and L2=X12,X22. We then consider four data-generating processes with different complexities:

  1. Y=25010A110A2+27.4X11+13.7X21+13.7X3+27.4X12+13.7X22+ϵ, where ϵ𝒩(0,25).

  2. Y=131+exp6X11+X21+X3+X12+X22+2X12X22+1.8X11+X21+X3A121+exp4X12+X22A2+ϵ, where ϵ𝒩(0, 0.64).

  3. Y=0.5+0.1A1+0.7sinA1+0.4sinA2+0.2X11+0.3X212+0.7sinX3+0.2X11X21+0.9X11X3+0.8logX12X22X3+A2+ϵ, where ϵ𝒩(0,6.25).

  4. Y=105sinπX11X3+21+eX22+ϵifA1=1andA2=1,6+3X1125sinX21+41+eX3+2X123X22+ϵifA1=1andA2=0,4+X1122sinX3+21+eX22+ϵifA1=0andA2=1,7.511+eX21+sinX3X122+2X12X222+ϵotherwise.

    Among all treatment conditions, ϵ𝒩(0,225). In this final scenario, we intentionally set a large error variance to ensure that the true effect size is comparable to the standard deviation of the error. This helps to evaluate the robustness of the method under conditions where the signal-to-noise ratio is low, which is often encountered in real-world data.

Across all four data-generating processes, X11,X21,X3,X12,X22 are confounders influencing both the treatment assignments as well as the final outcome. In scenario (1), the true outcome model does not include any non-linear terms or transformations of the confounders or treatment assignments. In contrast, scenarios (2), (3), and (4) incorporate increasingly complex relationships, integrating both linear and non-linear confounding effects. Specifically, scenario (2) contains interactions between treatments and confounders, as well as among the confounders themselves. Scenario (3) includes the trigonometric functions with periodic relationships, and interaction terms involving a logarithm of an absolute value. In scenario (4), we introduce a piecewise function with four different equations depending on the values of treatment assignments. Each piecewise function includes both linear and non-linear terms, depending on the combinations of treatment assignments at the two time points. For each data-generating process, we evaluate and compare the performance of the following Bayesian methods (1–4) and frequentist methods (5–10), each within the ICE framework to ensure comparability.

  1. (BLR-ICE) Introduced in Section 3, this approach models the mean outcome function at each time point by fitting a Bayesian version of linear regression based on the ICE representation.

  2. (BLR-PS-ICE) The BLR-ICE estimator with the estimated longitudinal propensity scores included as additional covariates. We use the R package SuperLearner to estimate the longitudinal propensity scores, based on an ensemble library including generalized additive models, generalized linear models with and without regularization. The same approach is used to estimate longitudinal propensity scores for all subsequent comparators, whenever applicable.

  3. (BART-ICE) This approach uses BART as the working outcome model for fk under the ICE representation at each time point. We used the bart function from the R package BayesTree with the default settings to implement BART-ICE.

  4. (BART-PS-ICE) The BART-ICE estimator with the estimated longitudinal propensity scores included as additional covariates.

  5. (BSpline-ICE) Under the general ICE formulation in Section 2 this approach uses the B-splines for outcome modeling by transforming continuous covariates into a basis matrix representing a family of piecewise polynomial functions, defined by specified interior knots and polynomial degree.57 The transformation of continuous variables is implemented using the bs function from the splines package. For the simulation, the default settings of the spline basis, such as the degrees of freedom, interior knots, and the degree of the piecewise polynomial, are applied. For this and all subsequent approaches, variance and interval estimation proceed through nonparametric bootstrap with 100 replicates.

  6. (BSpline-PS-ICE) The BSpline-ICE estimator with the estimated longitudinal propensity scores included as additional covariates.

  7. (RF-ICE) This approach models fk nonparametrically by random forest, which is an ensemble learning method that constructs multiple decision trees during training and combines their predictions to improve regression accuracy and reduce overfitting. 58 RF-ICE estimator fits a random forest at each time point using the randomForest function from the randomForest package59. We set number of trees to be ntree = 500.

  8. (RF-PS-ICE) The RF-ICE estimator with the estimated longitudinal propensity scores included as additional covariates.

  9. (KR-ICE) This approach models fk nonparametrically by kernel regression, which estimates the relationship between covariates and outcome by weighting nearby observations based on a kernel function. We use the npreg function from the np package60 to implement kernel regression, which allows continuous, unordered, and ordered factor data types, employing kernel smoothing with automated bandwidth selection. The neighborhood bandwidth specification is performed using function npregbw following the method of Racine and Li. 61,62 Gaussian kernels were used for continuous covariates, while Aitchison-Aitken kernels were applied for categorical covariates.

  10. (KR-PS-ICE) The KR-ICE estimator with the estimated longitudinal propensity scores included as additional covariates.

For computational considerations, each simulation data-generating process is independently replicated H=100 times, and all 10 estimators are fit to each one of the H simulated datasets. The performance metrics are provided in Section 5.3.

5.2 |. Implementation details of the Bayesian methods

For Bayesian methods, BART and BLR, at time 2, we generate S2=4000 total MCMC samples, with B2=3000 as burn-in and a thinning rate of t2=10. For each retained sample at time 2, the number of MCMC draws at time 1 was S1=4000, with B1=3000 discarded as burn-in and a thinning rate of t1=100. Thus, we retained every 10-th time-2 posterior sample after burn-in, and accordingly, every 100-th time-1 sample from each chain after the burn-in period. The total number of draws for the two time intervals is C=C2×C1=S2B2t2×S1B1t1=4000300010×40003000100=1000. By examining the traceplots of the MCMC samples, we verify the convergence of the algorithm, ensuring that the chains mix well and are representative of the target posterior distribution. Choosing a smaller C2=S2B2t2 ensures that we can propagate the tree even with larger data samples, thereby reducing the computational cost of sampling. Selecting an appropriate C1=S1B1t1 allows us to sufficiently explore the posterior distribution space through multiple imputation.45 When computational resources permit, a larger C2 can be considered to further improve the accuracy of the sampling process. With limited computational resources, thinning enables us to run a sufficiently long chain and select representative posterior samples. Compared to running a short chain and retaining all posterior samples, this approach is more effective in approximating the posterior distribution. All simulations were carried out using R version 4.3.1. 63 To facilitate the application of these methods to estimate the average treatment effect, we provide code to replicate our simulation studies in the GitHub page https://github.com/Ruyi-Liu/Bayesian-ICE.

5.3 |. Performance metrics

We evaluate the overall accuracy in estimating the average treatment effect for each method using relative bias. For Bayesian methods, there are C=1000 different Y^1 generated for each simulated dataset h, and (τ^h(1),,τ^h(C)) is the sequence of estimated treatment effect corresponding to each Y^1,h{1,,H}. The point estimator for the average treatment effect of dataset h based on the posterior mean is given by τ^h=τ^h(1)++τ^h(C)C. For frequentist methods, we also use τ^h to generically denote the point estimator for the average treatment effect using dataset h. Then, the relative bias is defined as

Relative Bias=1Hh=1Hτ^hττ,

where the true causal effect, τ=τa1,a2,a1,a2, for each scenario is calculated from a sufficiently large sample—a simulated population with 10, 000, 000 participants. 64 The Monte Carlo Standard Deviation (MCSD) is then calculated for each method to measure the spread of the estimated values across different simulation runs. For each method, MCSD is computed as

MCSD=1H1h=1H(τ^h(1Hh=1Hτ^h))2.

Additionally, we also calculate the root mean squared error (RMSE) for each method,

RMSE=h=1H(τ^hτ)2H,

which is an overall measure accounting for the bias and variability of each estimator. Finally, the frequentist coverage of the 95% credible interval (for Bayesian methods) or confidence interval (for frequentist methods) is calculated as follows. For each simulated dataset h, the 95% credible interval in Bayesian methods is determined by the 2.5-th and 97.5-th percentiles from the sequence of MCMC draws, τ^h(1),,τ^h(C). For frequentist methods, the 95% confidence interval is computed as τ^h1.96σ^h,τ^h+1.96σ^h, where σ^h is the estimated standard error of τ^h through nonparametric bootstrap with 100 replicates. Coverage is then calculated as the proportion of all H datasets for which the interval estimator includes the true treatment effect, τ.

5.4 |. Simulation results

We focus on estimating the average treatment effect comparing treatment regimens (1, 1) and (0, 0), using the ten methods introduced in Section 5.1 and under four data-generating processes of varying complexity. Figure 3 and Figure 4 summarize, for a sample size of n=500, the relative bias and the frequentist coverage of the estimated average treatment effect using all methods, respectively. For brevity in the main text, results on MCSD and RMSE are presented in Appendix 2 and 3.

Figure 3.

Figure 3

Box plots of relative deviation from the truth τ^hτ/τ for estimating average treatment effect comparing regimen (1, 1) with (0, 0) using each of ten methods across four data-generating processes. The methods are categorized into two groups: bayesian and frequentist. Each box represents the distribution of relative bias for a given method, with the horizontal dashed line indicating zero bias. The four data-generating processes are labeled as Scenario 1, Scenario 2, Scenario 3, and Scenario 4, with facet panels displaying the results separately. Bayesian methods include BLR-ICE, BLR-PS-ICE, BART-ICE, and BART-PS-ICE, while frequentist methods include BSpline-ICE, BSpline-PS-ICE, RF-ICE, RF-PS-ICE, KR-ICE, and KR-PS-ICE.

Figure 4.

Figure 4

Frequentist coverage of the 95% confidence or credible interval across all simulated datasets for ten methods under four data-generating processes. The dashed horizontal line represents the nominal coverage level. Bar heights indicate the proportion of simulations in which the true parameter was contained within the estimated confidence or credible intervals. Bayesian methods include BLR-ICE, BLR-PS-ICE, BART-ICE, and BART-PS-ICE, while frequentist methods include BSpline-ICE, BSpline-PS-ICE, RF-ICE, RF-PS-ICE, KR-ICE, and KR-PS-ICE.

Overall, the simulation results indicate that among the Bayesian methods, BART-ICE and BART-PS-ICE consistently yield lower relative bias across data-generating processes (2)–(4), compared to their fully parametric BLR-based counterparts. The most obvious relative bias reduction is in scenario (4), where the outcome model is the most complicated. This demonstrates the advantage of BART in adapting to increasing complexity, without the need for explicit specification of the functional forms. Across all scenarios under the non-linear data-generating processes, the BART-based methods also consistently yield a lower RMSE and MCSD than BLR-based methods, which indicates that BART-ICE and BART-PS-ICE provide more precise estimates with less variability compared to their fully parametric counterparts. When data are generating from a simpler linear model (1), BLR-based methods perform well, as expected, but BART-based methods still maintain similar bias and nominal frequentist coverage, with some inflation of MCSD and RMSE.

Turning our focus to the frequentist nonparametric methods, we find that BSpline-ICE and BSpline-PS-ICE perform well under scenario (1) and (2), but have less favorable performance under more complex data-generating processes (3) and (4) with slightly higher variability and notable under-coverage. Furthermore, RF-ICE and KR-ICE show poor performance across all data-generating processes, reflected by large relative bias, low coverage, and high RMSE. The relative bias of RF-based and KRbased methods also appears to be highly sensitive to the data-generating process. Notably, these methods perform particularly poorly under simpler data-generating processes, and the inclusion of longitudinal propensity scores can even introduce additional distortions in bias and coverage for these estimators, especially in scenarios (3)–(4). Despite having small MCSD in some scenarios, RF-based and KR-based methods often fail to provide unbiased inference and can show inflated RMSE. Among the frequentist methods, the BSpline-based approaches demonstrate the best overall performance. However, despite their relative advantage within the frequentist methods we have compared, BSpline-based estimators are still dominated by BART-based estimators regarding efficiency and frequentist coverage. Overall, our simulation results demonstrate the superior performance of BART in terms of accuracy, efficiency, and robustness, particularly under complex data-generating processes. Moreover, under data-generating processes with increased complexity, including the estimated longitudinal propensity scores as additional covariates appears to have improved the accuracy for BART-based methods, as indicated by the smaller relative bias and closer to nominal coverage, although at a slight cost of efficiency; this observation is consistent with prior findings in Hu et al. 33 for BART survival estimators targeting conditional average treatment effects under a time-fixed treatment setting. Finally, while integrating longitudinal propensity scores may enhance the performance of BART-based methods, its benefits does not seem to carry to any of the frequentist methods across all data-generating processes.

6 |. ILLUSTRATIVE DATA EXAMPLES

6.1 |. Application to the Yale New Haven Health System Electronic Health Record data

We first demonstrate our methods to analyze data from the Yale New Haven Health System (YNHHS) Electronic Health Record. We examine the effect of prescribed antihypertensives on blood pressure among patients who developed severe inpatient hypertension. 65 The data includes inpatients not initially admitted for hypertension but who later developed severe inpatient hypertension, systolic blood pressure (SBP) >180mmHg or diastolic blood pressure (DBP) >110mmHg. 65 We applied all four Bayesian ICE methods to analyze the YNHHS data from this cohort study. The cut of the data follows that in Cheng et al.43 The study spanned from 2016 to 2020 and involved adult patients across five hospitals in New Haven, CT. The primary outcome is the blood pressure response within six hours after the development of severe hypertension. We aim to estimate the treatment effect of antihypertensive drug at (0, 2), [2, 4), and [4, 6) hours following the development of severe hypertension (HTN) on patients’ SBP at 6 hours following the development of severe HTN. The initial time interval (0 to 2 hours), the intermediate interval (2 to 4 hours), and the final interval (4 to 6 hours), are denoted as k=1,2,3 respectively. During each time interval, the administration of antihypertensive drug treatment, represented by Ak, is encoded as 1 if treatment was administered and 0 otherwise. The baseline covariates, denoted as L1, include a range of demographic and clinical factors such as age, gender, race, body mass index, existing comorbidities with a focus on cardiovascular and hypertension history, and initial systolic and diastolic blood pressure (SBP and DBP) measurements at the development of severe HTN. Furthermore, the time-varying covariates, represented by L2 and L3, capture the most recent SBP and DBP measurements prior to 2 and 4 hours respectively. The primary outcome of interest is the SBP at 6 hours after developing severe HTN. Following Cheng et al.43, our analysis includes 5, 925 individuals, specifically selected for having complete data across all relevant variables.

At time 3, we generated S3=4000 total MCMC samples, with B3=3000 as burn-in and a thinning rate of t3=10. At time 2, we generated S2=4000 total MCMC samples, with B2=3000 as burn-in and a thinning rate of t2=100. For each retained sample at the previous time point, the number of MCMC draws at time 1 was S1=4000, with B1=3000 discarded as burn-in and a thinning rate of t1=200. Following Zhou et al., 45 a time-1 thinning rate of t1=200 is chosen to be adequate, as 5 samples are preserved for each retained chain. Through traceplots of the MCMC sample, we confirm the algorithm’s convergence, ensuring that the chains are well-mixed and accurately represent the posterior distribution. If computational resources are sufficient, increasing C3 and C2 can be explored to improve the sampling process. Applying four methods, the results are summarized in Table 4. Using BART-PS-ICE estimator and five cores for parallel computation, each analysis including all three estimands required approximately 104.31 hours to complete due to the non-trivial sample size. Using five cores and BART-ICE estimator, each analysis required approximately 103.62 hours to complete. Notice that the computation time is based on imputing all potential outcomes across all time points, similar to the scheme in Table 2, if the interest lies in one estimand only, using the restricted imputation scheme in Table 3 could further reduce the computational time.

Table 4.

Analysis of the Yale New Haven Health System (YNHHS) Electronic Health Record data: estimation results for average treatment effects comparing regimen (1, 1, 1) with (0, 0, 0), (0, 1, 1) with (0, 0, 0), and (0, 0, 1) with (0, 0, 0), using BLR-ICE, BLR-PS-ICE, BART-ICE, and BART-PS-ICE. “ATE” denotes average treatment effect comparing two regimens.

ATE Method Estimated ATE 95% Credible Interval
τ(1,1,1),(0,0,0) BLR-ICE −4.377 (−6.589, −2.349)
BLR-PS-ICE −2.752 (−5.398, −0.252)
BART-ICE −3.458 (−6.229, −0.774)
BART-PS-ICE −3.463 (−6.231, −0.737)

τ(0,1,1),(0,0,0) BLR-ICE −4.932 (−6.869, −3.333)
BLR-PS-ICE −3.638 (−5.981, −1.573)
BART-ICE −3.901 (−6.365, −1.728)
BART-PS-ICE −3.497 (−5.816, −1.208)

τ(0,0,1),(0,0,0) BLR-ICE −3.444 (−4.860, −2.004)
BLR-PS-ICE −2.819 (−4.109, −1.083)
BART-ICE −3.010 (−4.625, −1.485)
BART-PS-ICE −2.760 (−4.468, −0.674)

We clarify that the estimands of scientific interest pertain to the sustained effects of antihypertensive exposure over time, as the drug remains active, while discontinuous treatment sequences are of less clinical interest. There are three different estimand of interest. The estimand τ(1,1,1),(0,0,0) denotes the treatment effect for receiving antihypertensive drug treatment at all three time intervals, (0, 2), [2, 4), and [4, 6) hours following the development of severe HTN, as compared to not receiving any antihypertensive treatment during these time intervals. The estimand τ(0,1,1),(0,0,0) represents the treatment effect for cases where treatment was not administered in the (0,2) hour period, but was received during the [2, 4) and [4, 6) hours following the development of severe HTN, as compared to not receiving any antihypertensive treatment during these time intervals. The estimand τ(0,0,1),(0,0,0) represents the treatment effect for cases where antihypertensive drug treatment was not administered in the initial and intermediate time intervals but did in the final time interval, [4, 6) hours following the development of severe HTN, as compared to not receiving any antihypertensive treatment during all three time periods. The point estimates of τ(1,1,1),(0,0,0) are negative across all four methods, indicating that the use of antihypertensive treatment at all three time intervals can reduce SBP among patients who developed severe inpatient hypertension. The estimated values of τ(1,1,1),(0,0,0) range from −2.752 to −4.377. All blood pressure reductions are expressed in mmHg. The point estimates of τ(0,1,1),(0,0,0) are all negative, ranging from −3.497 to −4.932, which indicates effective SBP reduction when treatment is initiated at 2 hours after the development of severe HTN. The estimated values for τ(0,0,1),(0,0,0) are consistently negative, ranging from −2.760 to −3.444, suggesting that even a late intervention can effectively reduce SBP. The 95% credible intervals for the estimates of τ(1,1,1),(0,0,0),τ(0,1,1),(0,0,0), and τ(0,0,1),(0,0,0) exclude the null. Therefore, the antihypertensive treatment activated at different time points after the development of severe HTN can significantly reduce the SBP.

The Bayesian ICE methods employed provide a range of estimated treatment effects and the corresponding credible intervals, confirming the effectiveness of the antihypertensive drug treatment. The negative estimated average treatment effect values across different time-varying treatment regimens suggest that antihypertensive drug treatment carried out at each time period is beneficial in reducing patients’ SBP at 6 hour following the development of severe HTN. From the results, we also observe that the lengths of the 95% credible intervals are relatively similar across all four methods. The BART-based approaches (with and without incorporating estimated longitudinal propensity scores) show more consistent results compared to the BLR-based approach in terms of point estimates and 95% credible intervals. The BLR-ICE method without incorporating propensity scores differs most notably from the other three methods, likely due to misspecification of the working model by linear regression.

6.2 |. Application to National Heart Lung and Blood Institute Growth and Health Study data

As an additional illustration, we apply our Bayesian ICE methods to analyze the data from the National Heart Lung and Blood Institute Growth and Health Study. We focus on understanding how disparities in diet, physical activity, and socioeconomic factors may contribute to obesity in pre-adolescent girls of different ethnic backgrounds. The research included African-American and Caucasian girls, aged 9 and 10, during 1987 and 1988, recruited from Richmond, CA, and Cincinnati, OH, as well as from families enrolled in a health maintenance organization in Washington, D.C.24 The study conducted follow-up assessments annually over 9 years. This analysis utilizes the initial three periods data of the study, investigating how dietary habits impact Body Mass Index (BMI) by the fourth period. We quantify dietary intake by daily percentage of energy from saturated fats reported in the questionnaire of each time period. Following previous studies24,66,67, if this percentage is under 10 at time period k, we assign a value of 1 to the diet variable Ak,k=1,2,3; otherwise, it is set to 0. The outcome variable Y is the logarithm of BMI measured at the fourth time period. The baseline covariates, denoted as L1, include race (1 for Caucasian, 0 for African-American), household income, and logarithm of a physical activity score recorded at the first time period. Furthermore, at the second time period, the time-varying covariates, represented by L2, is logarithm of BMI recorded at k=2. At the third time period, L3 include logarithm of BMI and logarithm of physical activity score recorded at k=3.

We use all four Bayesian methods, BLR-ICE, BLR-PS-ICE, BART-ICE, and BART-PS-ICE, to analyze the longitudinal effect of dietary intake (daily percentage of energy from saturated fats) on BMI of pre-adolescent girls from various ethnic backgrounds. The results are summarized in Table 5. Given the large dataset, we generated 4000 total MCMC samples with 3000 as burn-in at each time point. Specifically, at time 3, the thinning rate was t3=10; at time 2, it was t2=100; and at time 1, it was t1=200. This ensures that 5 samples are preserved for each retained chain at time 1. Using BART-PS-ICE estimator and one core for computation, each analysis including all three estimands required approximately 85.05 hours to complete. Using BART-ICE estimator, each analysis required approximately 90.41 hours to complete. Again, the computation time is based on imputing all potential outcomes across all time points, similar to the scheme in Table 2.

Table 5.

Analysis of the National Heart Lung and Blood Institute Growth and Health Study data: estimation results for average treatment effects comparing regimen (1, 1, 1) with (0, 0, 0), (0, 1, 1) with (0, 0, 0), and (0, 0, 1) with (0, 0, 0) using BLR-ICE, BLR-PS-ICE, BART-ICE, and BART-PS-ICE. “ATE” denotes average treatment effect comparing two regimens.

ATE Method Estimated ATE 95% Credible Interval
τ(1,1,1),(0,0,0) BLR-ICE −0.027 (−0.054, 0.000)
BLR-PS-ICE 0.038 (−0.789, 0.944)
BART-ICE −0.037 (−0.072, −0.002)
BART-PS-ICE −0.054 (−0.273, 0.165)

τ(0,1,1),(0,0,0) BLR-ICE −0.005 (−0.027, 0.018)
BLR-PS-ICE 0.048 (−0.035, 0.125)
BART-ICE −0.009 (−0.029, 0.012)
BART-PS-ICE −0.047 (−0.206, 0.103)

τ(0,0,1),(0,0,0) BLR-ICE 0.005 (−0.010, 0.021)
BLR-PS-ICE −0.040 (−0.088, 0.005)
BART-ICE 0.001 (−0.011, 0.016)
BART-PS-ICE −0.053 (−0.147, 0.018)

There are three different estimands of interest. The estimand τ(1,1,1),(0,0,0) represents the effect of having daily percentage of energy from saturated fats consistently lower than 10% across all three time intervals, as compared to having daily percentage of energy from saturated fats consistently greater than 10% across all time intervals. The estimand τ(0,1,1),(0,0,0) represents the effect of reducing daily energy intake from saturated fats to below 10% starting from the second time interval. The estimand τ(0,0,1),(0,0,0) represents the effect of reducing daily energy intake from saturated fats to below 10% in the final time interval. The point estimate of τ(1,1,1),(0,0,0) ranges from −0.054 to 0.038. Focusing on BART-PS-ICE method, the point estimate for τ(1,1,1),(0,0,0) stands at −0.054. This indicates that maintaining a daily intake of energy from saturated fats below 10% across all three time periods can effectively lead to a reduction in BMI; the estimates and findings for τ(0,1,1),(0,0,0) and τ(0,0,1),(0,0,0) are generally similar, but all credible intervals based on BART-PS-ICE include zero. The results overall suggest that dietary interventions that reduce saturated fat intake may have effects in reducing the BMI, even when implemented in later time points.

The variability in estimates and their associated credible intervals given by different methods can be attributed to methodological differences between the models, for example, their capability of handling non-linearity. In terms of the point estimate, the four methods provided roughly similar results, all of which are close to zero. For all estimands of interest in this data example, we find that incorporating estimated longitudinal propensity scores further widens the 95% credible interval. Based on our simulation findings, it is possible that the outcome surface is approximately linear. In this case, adding propensity scores as an additional covariate may inflate variance, similar to the simulation scenario (1).

7 |. DISCUSSION

To estimate the average causal effect of a treatment regimen in longitudinal observational studies, the ICE estimator can be an attractive version of the g-formula because it avoids the need for specifying the full distribution of all time-varying confounders, as in the standard g-formula implementation.10 This work offers a version of the ICE estimator under a Bayesian framework and further integrates nonparametric priors—BART—to flexibly model the series of outcome surfaces and improves the robustness. We presented the sampling algorithm to obtain samples from the posterior distribution of the Bayesian ICE estimator under nested regressions. Compared with BLR-based ICE estimator and competing frequentist nonparametric regression-based estimators, we demonstrated via simulations that BART-based ICE estimator can provide stronger protection against model misspecification, and often achieve closer to nominal frequentist coverage, under different data-generating processes.

We have considered two versions of the BART-ICE estimator—one including only the original time-varying confounders and one additionally including the nonparametrically estimated longitudinal propensity scores as additional confounders. The idea of adding longitudinal propensity scores in the regression-based causal effect estimators is not uncommon, especially in the setting of a time-fixed treatment. Specifically, Zigler et al. 54 and Li et al. 42 have explained that a Bayesian regression estimator with the original confounders augmented by the estimated propensity score implicitly conducts outcome regression with strata defined by the propensity score, and can be viewed as the Bayesian analogue of a doubly robust estimator (even though this approach does not strictly possess the double robustness asymptotic property in the frequentist sense). Previous studies have exploited the additional value of adjusting for propensity scores in the regression setting. For example, Hahn et al. 34 developed the Bayesian causal forest that integrates the estimated propensity scores as part of the model specification with a time-fixed treatment, to address regularization-induced confounding. Hu et al. 33 demonstrated the benefit of integrating the estimated propensity scores for estimating heterogeneous treatment effects with a time-fixed treatment and censored survival outcomes, and found that adding a nonparametrically estimated propensity score as an additional fixed covariate in the accelerated failure time model formulation can further improve the frequentist coverage. With a time-varying treatment, Chen et al. 12 demonstrated a slight efficiency advantage of including the estimated longitudinal propensity scores in the BART-based NICE estimator for causal survival analysis in discrete time. These prior findings across various contexts have motivated us to explore the use of nonparametrically estimated longitudinal propensity scores within the BART-ICE framework. Our results suggest that under more complex data-generating processes, augmenting BART-ICE with estimated longitudinal propensity scores can further reduce bias and improve frequentist coverage. However, in simpler data-generating processes, this augmentation may slightly inflate variance, likely due to over-specification of the outcome model. Thus, the benefits of incorporating estimated longitudinal propensity scores in BART-ICE appear to depend on the complexity of the data-generating process. In principle, traditional model checking tools may provide insight into assessing model fit to the data when evaluating model and prior distribution choices. Methods such as Deviance Information Criterion (DIC) or Widely Applicable Information Criterion (WAIC) could be useful in selecting the best model. However, the development of specific model checking methods requires future research, particularly given the complexity introduced by the imputation of pseudo-outcomes at each stage using nested regression.

In our reflection, although Bayesian methods have merits for causal inference, 42 they are relatively less studied in the context of time-varying treatments. Keil et al. demonstrated that the NICE approach for g-formula is amenable to a Bayesian approach and illustrated the frequentist properties of the Bayesian NICE estimator, which improves the accuracy of causal effect estimates in small samples or when data are sparse. 10 Different from their work, our work focuses on ICE estimator and develops a Bayesian sampling algorithm to obtain samples from its posterior distribution. Compared to Bayesian NICE, the ICE approach requires fewer model assumptions, as it does not require specifying models for the joint distribution of observed variables. This characteristic offers some convenience and potential protection against model misspecification. However, it is important to recognize that the backward iterative nature of the ICE method can also result in an increase in computational time, especially for longitudinal studies with a large number of periods; so there is an implicit trade-off when choosing between different gformula methods and this decision should depend on the study context, model complexity, and computational resources. Our primary goal is to provide a Bayesian version of the g-formula that obviates the need to specify the potentially complex time-varying covariates and offer an additional option when researchers are interested in implementing flexible g-computation with time-varying treatments. In our experiences, for longitudinal observational studies with a moderate number of time-varying covariates but a limited number of time periods, Bayesian ICE would be recommended, thereby minimizing the modeling efforts for possibly a handful of covariates and improving the model robustness to confounding distribution specifications. Conversely, in studies with a large number of periods but only a few time-varying covariates, the Bayesian NICE estimator could have a computational advantage, with some thoughtful efforts in specifying the joint likelihood for the entire time-varying confounders. Finally, as we demonstrated via simulations, it would be beneficial to consider more flexible specification of the component models—such as BART—in either version of the g-formula estimator to further improve the operating characteristics of the final average causal effect estimator.

Our work, like other prior studies on longitudinal causal inference, has primarily relied on the key identification assumptions of no unmeasured confounding (sequential ignorability) and positivity. For observational studies with either a time-fixed or time-varying treatment, the no unmeasured confounding assumption may not always hold in practice, and in such cases, the BART-ICE methods (despite its flexibility in representing outcome surfaces) are not guaranteed to produce valid estimates for the average causal effects; also see, for example, Section 4.6 in Hu et al.33 for an empirical demonstration of bias that cannot be avoided by flexible BART causal estimators even in the presence of unmeasured baseline confounding. When unmeasured confounding is suspected in longitudinal observational studies, a useful approach is to incorporate sensitivity functions. In this regard, Cheng et al.43 extended the confounding function approach originally proposed by Brumback et al.68 to a generalized version of the ICE estimator in the context of estimating quantile causal effects. Their version of the sensitivity function can be adapted to our setting, and enable the development of a BART-based sensitivity analysis framework, following the example in Hu et al.31 for multi-valued time-fixed treatments. A comprehensive development of this approach would be a valuable direction for future work. Second, the positivity assumption could also be challenging to satisfy in longitudinal observational studies, particularly when the number of time intervals is large and the sample size is limited. While various strategies have been proposed to address positivity violations in the context of time-fixed treatments,69,70 their extensions to time-varying treatments remain less developed. In a Bayesian setting, Papadogeorgou and Li71 highlighted that in regions of poor covariate overlap, BART may overstate the certainty of causal effect estimates, and recommended Gaussian process priors as a potential remedy. Zhu et al.40 further explored this approach and systematically investigated the use of Gaussian processes for addressing positivity violations with a time-fixed treatment. Integrating Gaussian process into the g-formula estimator under the time-varying treatment setting, particularly under both NICE and ICE formulations, represents an important avenue for future research that improves the quality of time-varying causal effect estimation under positivity violation. Third, our current Bayesian ICE implementation adheres to the theoretical underpinnings of nested imputation.45 However, we acknowledge that this approach can be computationally intensive due to the need to fit multiple Bayesian models per each draw from the previous time point. An anonymous reviewer suggested an alternative approach, which aggregates all draws from time 2 and fits a single model at time 1, thereby reducing the computational time. Assessing the theoretical justification and comparative performance of this approach against our current method, as well as developing more computationally efficient implementations of the Bayesian ICE method more generally, would be valuable directions for future research.

Supplementary Material

Supinfo

ACKNOWLEDGEMENTS

Research in this article was supported by the United States National Institutes of Health, National Heart, Lung, and Blood Institute (NHLBI, grant numbers R01-HL168202 and 1R01HL159077-01A1), and by the Patient-Centered Outcomes Research Institute® (PCORI® Award ME-2021C2-23685). The content is solely the responsibility of the authors and does not necessarily represent the official views of the National Institutes of Health, PCORI®, its Board of Governors or Methodology Committee.

APPENDIX 1. THE ITERATIVE EXPECTATION OF THE COUNTERFACTUAL OUTCOMES

By definition, fkaK,lkEfk+1aK,lk+1Ak=ak,Lk=lk, for k{1,,K1}. For k=K, we have the following by consistency assumption

fK(a¯K,l¯K)=E(Y|A¯K=a¯K,L¯K=l¯K)=E(Y(a¯K)|A¯K=a¯K,L¯K=l¯K).

For k=K1,

fK1(a¯K,l¯K1)=E(fK(a¯K,l¯K)|A¯K1=a¯K1,L¯K1=l¯K1)=E(E(Y(a¯K)|A¯K=a¯K,L¯K=l¯K)|A¯K1=a¯K1,L¯K1=l¯K1)=E(E(Y(a¯K)|A¯K1=a¯K1,L¯K=l¯K)|A¯K1=a¯K1,L¯K1=l¯K1)(By no unmeasured confounding.)=E(Y(a¯K)|A¯K1=a¯K1,L¯K1=l¯K1)(By law of iterated expectation.)

Assuming fk+1aK,lk+1=EYaKAk+1=ak+1,Lk+1=lk+1 holds for k=1,,K1. Then,

fk(a¯K,l¯k)=E(fk+1(a¯K,l¯k+1)|A¯k=a¯k,L¯k=l¯k)=E(E(Y(a¯K)|A¯k+1=a¯k+1,L¯k+1=l¯k+1)|A¯k=a¯k,L¯k=l¯k)=E(E(Y(a¯K)|A¯k=a¯k,L¯k+1=l¯k+1)|A¯k=a¯k,L¯k=l¯k)=E(Y(a¯K)|A¯k=a¯k,L¯k=l¯k)

Therefore, by induction, we can show that, for k=1,,K,

fk(a¯K,l¯k)=E(Y(a¯K)|A¯k=a¯k,L¯k=l¯k).

Thus, f0aK=Ef1aK,l1=EEYaKA1=a1,L¯1=l¯1=EYaK.

APPENDIX 2. MONTE CARLO STANDARD DEVIATION ACROSS DIFFERENT ESTIMATION METHODS AND SCENARIOS

Figure.

Figure.

Monte Carlo Standard Deviation (MCSD) across all simulated datasets for ten methods under four data-generating processes. Each panel represents a different data-generating process. Bar heights indicate MCSD values, measuring the variability of parameter estimates across repeated simulations. Bayesian methods include BLR-ICE, BLR-PS-ICE, BART-ICE, and BART-PS-ICE, while frequentist methods include BSpline-ICE, BSpline-PS-ICE, RF-ICE, RF-PS-ICE, KR-ICE, and KR-PS-ICE.

APPENDIX 3. ROOT MEAN SQUARED ERROR ACROSS DIFFERENT ESTIMATION METHODS AND SCENARIOS

Figure.

Figure.

Root Mean Squared Error (RMSE) across all simulated datasets for ten methods under four data-generating processes. Each panel represents a different data-generating process, with bayesian methods and frequentist methods shown for comparison. Bar heights indicate RMSE values, measuring the average squared deviation from the true average treatment effect. Bayesian methods include BLR-ICE, BLR-PS-ICE, BART-ICE, and BART-PS-ICE, while frequentist methods include BSpline-ICE, BSpline-PS-ICE, RF-ICE, RF-PS-ICE, KR-ICE, and KR-PS-ICE.

Footnotes

CONFLICT OF INTEREST

The authors declare no potential conflicts of interest with respect to the research, authorship and/or publication of this article.

DATA AVAILABILITY STATEMENT

The data used in Section 6.1 were obtained with the assistance and supervision of the Clinical and Translational Accelerator (CTRA), Department of Medicine, Yale School of Medicine and the Joint Data Analytics Team. This research data are not publicly available due to privacy or ethical restrictions. The data used in Section 6.2 were prepared using the Research Materials (NHLBI Growth and Health Study) obtained from the NHLBI Biologic Specimen and Data Repository Information Coordinating Center (BioLINCC) and do not necessarily reflect the opinions or views of the NHLBI Growth and Health Study or the NHLBI. The NHLBI Growth and Health Study data is available from the NHLBI BioLINCC website and can be requested at https://biolincc.nhlbi.nih.gov/studies/nghs/.

References

  • 1.Hernán MA, Robins JM. Causal Inference: What If. Boca Raton, FL: Chapman & Hall/CRC, 2020. [Google Scholar]
  • 2.Robins J A new approach to causal inference in mortality studies with a sustained exposure period—application to control of the healthy worker survivor effect. Mathematical Modelling. 1986;7(9-12):1393–1512. [Google Scholar]
  • 3.Robins JM. Addendum to “a new approach to causal inference in mortality studies with a sustained exposure period—application to control of the healthy worker survivor effect”. Computers & Mathematics with Applications. 1987;14(9-12):923–945. [Google Scholar]
  • 4.Robins JM. A graphical approach to the identification and estimation of causal parameters in mortality studies with sustained exposure periods. Journal of Chronic Diseases. 1987;40:139S–161S. [DOI] [PubMed] [Google Scholar]
  • 5.Robins JM, Hernan MA, Brumback B. Marginal structural models and causal inference in epidemiology. Epidemiology. 2000:550–560. [DOI] [PubMed] [Google Scholar]
  • 6.Hernán MÁ, Brumback B, Robins JM. Marginal structural models to estimate the causal effect of zidovudine on the survival of HIV-positive men. Epidemiology. 2000:561–570. [DOI] [PubMed] [Google Scholar]
  • 7.Robins JM. Correcting for non-compliance in randomized trials using structural nested mean models. Communications in Statistics - Theory and Methods. 1994;23(8):2379–2412. [Google Scholar]
  • 8.Vansteelandt S, Joffe M. Structural Nested Models and G-estimation: The Partially Realized Promise. Statistical Science. 2014;29(4):707–731. [Google Scholar]
  • 9.Daniel RM, Cousens S, De Stavola B, Kenward MG, Sterne J. Methods for dealing with time-dependent confounding. Statistics in Medicine. 2013;32(9):1584–1618. [DOI] [PubMed] [Google Scholar]
  • 10.Keil AP, Daza EJ, Engel SM, Buckley JP, Edwards JK. A Bayesian approach to the g-formula. Statistical Methods in Medical Research. 2018;27(10):3183–3204. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 11.Woody S, Carvalho CM, Murray JS. Model interpretation through lower-dimensional posterior summarization. Journal of Computational and Graphical Statistics. 2021;30(1):144–161. [Google Scholar]
  • 12.Chen X, Hu L, Li F. A flexible Bayesian g-formula for causal survival analyses with time-dependent confounding. arXiv preprint arXiv:2402.02306. 2024. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 13.Josefsson M, Daniels MJ. Bayesian semi-parametric g-computation for causal inference in a cohort study with MNAR dropout and death. Journal of the Royal Statistical Society: Series C (Applied Statistics). 2021;70(2):398–414. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 14.Wen L, Young JG, Robins JM, Hernán MA. Parametric g-formula implementations for causal survival analyses. Biometrics. 2021;77(2):740–753. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 15.Shinohara RT, Narayan AK, Hong K, et al. Estimating parsimonious models of longitudinal causal effects using regressions on propensity scores. Statistics in Medicine. 2013;32(22):3829–3837. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 16.Achy-Brou AC, Frangakis CE, Griswold M. Estimating treatment effects of longitudinal designs using regression models on propensity scores. Biometrics. 2010;66(3):824–833. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 17.Chen X, Harhay MO, Tong G, Li F. A Bayesian machine learning approach for estimating heterogeneous survivor causal effects: Applications to a critical care trial. The Annals of Applied Statistics. 2024;18(1):350–374. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 18.Zhou T, Elliott MR, Little RJA. Penalized spline of propensity methods for treatment comparison. Journal of the American Statistical Association. 2019;114(525):1–19. [Google Scholar]
  • 19.Robins JM. General methodological considerations. Journal of Econometrics. 2003;112(1):89–106. [Google Scholar]
  • 20.Young JG, Cain LE, Robins JM, O’Reilly EJ, Hernán MA. Comparative effectiveness of dynamic treatment regimes: an application of the parametric g-formula. Statistics in Biosciences. 2011;3:119–143. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 21.Bang H, Robins JM. Doubly robust estimation in missing data and causal inference models. Biometrics. 2005;61(4):962–973. [DOI] [PubMed] [Google Scholar]
  • 22.Petersen M, Schwab J, Gruber S, Blaser N, Schomaker M, Laan v. dM. Targeted maximum likelihood estimation for dynamic and static longitudinal marginal structural working models. Journal of Causal Inference. 2014;2(2):147–185. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 23.Tran L, Yiannoutsos C, Wools-Kaloustian K, Siika A, Van Der Laan M, Petersen M. Double robust efficient estimators of longitudinal treatment effects: comparative performance in simulations and a case study. The International Journal of Biostatistics. 2019;15(2):20170054. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 24.Babino L, Rotnitzky A, Robins J. Multiple robust estimation of marginal structural mean models for unconstrained outcomes. Biometrics. 2019;75(1):90–99. [DOI] [PubMed] [Google Scholar]
  • 25.Chipman HA, George EI, McCulloch RE. BART: Bayesian additive regression trees. The Annals of Applied Statistics. 2010;4(1):266–298. [Google Scholar]
  • 26.Tan YV, Roy J. Bayesian additive regression trees and the General BART model. Statistics in Medicine. 2019;38(25):5048–5069. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 27.Murray TA, Yuan Y, Thall PF. A Bayesian machine learning approach for optimizing dynamic treatment regimes. Journal of the American Statistical Association. 2018;113(523):1255–1267. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 28.Li X, Logan BR, Hossain SF, Moodie EE. Dynamic Treatment Regimes Using Bayesian Additive Regression Trees for Censored Outcomes. Lifetime Data Analysis. 2024;30(1):181–212. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 29.Hill JL. Bayesian nonparametric modeling for causal inference. Journal of Computational and Graphical Statistics. 2011;20(1):217–240. [Google Scholar]
  • 30.Hu L, Gu C, Lopez M, Ji J, Wisnivesky J. Estimation of causal effects of multiple treatments in observational studies with a binary outcome. Statistical Methods in Medical Research. 2020;29(11):3218–3234. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 31.Hu L, Ji J, Ennis RD, Hogan JW. A flexible approach for causal inference with multiple treatments and clustered survival outcomes. Statistics in Medicine. 2022;41(25):4982–4999. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 32.Caron A, Baio G, Manolopoulou I. Estimating individual treatment effects using non-parametric regression models: A review. Journal of the Royal Statistical Society Series A: Statistics in Society. 2022;185(3):1115–1149. [Google Scholar]
  • 33.Hu L, Ji J, Li F. Estimating heterogeneous survival treatment effect in observational data using machine learning. Statistics in Medicine. 2021;40(21):4691–4713. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 34.Hahn PR, Murray JS, Carvalho CM. Bayesian regression tree models for causal inference: Regularization, confounding, and heterogeneous effects (with discussion). Bayesian Analysis. 2020;15(3):965–1056. [Google Scholar]
  • 35.Dorie V, Hill J, Shalit U, Scott M, Cervone D. Automated versus do-it-yourself methods for causal inference: Lessons learned from a data analysis competition. Statistical Science. 2019;34(1):43–68. [Google Scholar]
  • 36.Henderson NC, Louis TA, Rosner GL, Varadhan R. Individualized treatment effects with censored data via fully nonparametric Bayesian accelerated failure time models. Biostatistics. 2020;21(1):50–68. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 37.Bargagli-Stoffi FJ, De Witte K, Gnecco G. Heterogeneous causal effects with imperfect compliance: A Bayesian machine learning approach. The Annals of Applied Statistics. 2022;16(3):1986–2009. [Google Scholar]
  • 38.Linero AR, Zhang Q. Mediation analysis using Bayesian tree ensembles.. Psychological Methods. 2022. [DOI] [PubMed] [Google Scholar]
  • 39.Antonelli J, Daniels MJ. Discussion of PENCOMP. Journal of the American Statistical Association. 2019;114(525):24–27. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 40.Zhu AY, Mitra N, Roy J. Addressing positivity violations in causal effect estimation using Gaussian process priors. Statistics in Medicine. 2023;42(1):33–51. [DOI] [PubMed] [Google Scholar]
  • 41.Oganisian A, Getz KD, Alonzo TA, Aplenc R, Roy JA. Bayesian semiparametric model for sequential treatment decisions with informative timing. Biostatistics. 2024:kxad035. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 42.Li F, Ding P, Mealli F. Bayesian causal inference: a critical review. Philosophical Transactions of the Royal Society A. 2023;381(2247):20220153. [DOI] [PubMed] [Google Scholar]
  • 43.Cheng C, Hu L, Li F. Doubly robust estimation and sensitivity analysis for marginal structural quantile models. arXiv preprint arXiv:2210.04100. 2022. [DOI] [PubMed] [Google Scholar]
  • 44.Gelman A, Carlin JB, Stern HS, Rubin DB. Bayesian Data Analysis. Chapman and Hall/CRC, 1995. [Google Scholar]
  • 45.Zhou X, Reiter JP. A note on Bayesian inference after multiple imputation. The American Statistician. 2010;64(2):159–163. [Google Scholar]
  • 46.Chib S. Analysis of treatment response data without the joint distribution of potential outcomes. Journal of Econometrics. 2007;140(2):401–412. [Google Scholar]
  • 47.Leonti M, Cabras S, Weckerle CS, Solinas MN, Casu L. The causal dependence of present plant knowledge on herbals—contemporary medicinal plant use in Campania (Italy) compared to Matthioli (1568). Journal of Ethnopharmacology. 2010;130(2):379–391. [DOI] [PubMed] [Google Scholar]
  • 48.Green DP, Kern HL. Modeling heterogeneous treatment effects in survey experiments with Bayesian additive regression trees. Public Opinion Quarterly. 2012;76(3):491–511. [Google Scholar]
  • 49.Sparapani RA, Logan BR, McCulloch RE, Laud PW. Nonparametric survival analysis using Bayesian additive regression trees (BART). Statistics in Medicine. 2016;35(16):2741–2753. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 50.Kindo BP, Wang H, Peña EA. Multinomial probit Bayesian additive regression trees. Stat. 2016;5(1):119–131. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 51.Linero AR, Sinha D, Lipsitz SR. Semiparametric mixed-scale models using shared Bayesian forests. Biometrics. 2020;76(1):131–144. [DOI] [PubMed] [Google Scholar]
  • 52.Bleich J, Kapelner A, George EI, Jensen ST. Variable selection for BART: an application to gene regulation. Ann. Appl. Stat 2014;8(3):1750–1781. [Google Scholar]
  • 53.Chipman HA, George EI, McCulloch RE. Bayesian CART model search. Journal of the American Statistical Association. 1998;93(443):935–948. [Google Scholar]
  • 54.Zigler CM, Watts K, Yeh RW, Wang Y, Coull BA, Dominici F. Model feedback in Bayesian propensity score estimation. Biometrics. 2013;69(1):263–273. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 55.Rosenbaum PR, Rubin DB. The central role of the propensity score in observational studies for causal effects. Biometrika. 1983;70(1):41–55. [Google Scholar]
  • 56.Pirracchio R, Petersen ML, Laan v. dM. Improving propensity score estimators’ robustness to model misspecification using Super Learner. American Journal of Epidemiology. 2015;181(2):108–119. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 57.Hastie TJ. Statistical Models in S. Routledge, 2017. [Google Scholar]
  • 58.Breiman L. Random forests. Machine learning. 2001;45:5–32. [Google Scholar]
  • 59.Liaw A, Wiener M. Classification and Regression by randomForest. R News. 2002;2(3):18–22. [Google Scholar]
  • 60.Hayfield T, Racine JS. Nonparametric Econometrics: The np Package. Journal of Statistical Software. 2008;27(5):1–32. [Google Scholar]
  • 61.Racine J, Li Q. Nonparametric estimation of regression functions with both categorical and continuous data. Journal of Econometrics. 2004;119(1):99–130. [Google Scholar]
  • 62.Li Q, Racine J. Cross-validated local linear nonparametric regression. Statistica Sinica. 2004:485–512. [Google Scholar]
  • 63.R Core Team . R: A Language and Environment for Statistical Computing. R Foundation for Statistical Computing; Vienna, Austria: 2023. [Google Scholar]
  • 64.Zhu AY, Mitra N, Hemming K, Harhay MO, Li F. Leveraging baseline covariates to analyze small cluster-randomized trials with a rare binary outcome. Biometrical Journal. 2024;66(1):2200135. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 65.Ghazi L, Li F, Chen X, et al. Severe inpatient hypertension prevalence and blood pressure response to antihypertensive treatment. The Journal of Clinical Hypertension. 2022;24(3):339–349. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 66.KIMM SY, GLYNN NW, KRISKA AM, et al. Longitudinal changes in physical activity in a biracial cohort during adolescence. Medicine & Science in Sports & Exercise. 2000;32(8):1445–1454. [DOI] [PubMed] [Google Scholar]
  • 67.Morrison J. Obesity and cardiovascular disease risk factors in black and white girls: the NHLBI Growth and Health Study. American Journal of Public Health. 1992;82(12):1613–1620. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 68.Brumback BA, Hernán MA, Haneuse SJ, Robins JM. Sensitivity analyses for unmeasured confounding assuming a marginal structural model for repeated measures. Statistics in Medicine. 2004;23(5):749–767. [DOI] [PubMed] [Google Scholar]
  • 69.Petersen ML, Porter KE, Gruber S, Wang Y, Van Der Laan MJ. Diagnosing and responding to violations in the positivity assumption. Statistical Methods in Medical Research. 2012;21(1):31–54. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 70.Li F, Thomas LE, Li F. Addressing extreme propensity scores via the overlap weights. American Journal of Epidemiology. 2019;188(1):250–257. [DOI] [PubMed] [Google Scholar]
  • 71.Papadogeorgou G, Li F. Discussion of “Bayesian Regression Tree Models for Causal Inference: Regularization, Confounding, and Heterogeneous Effects”. Bayesian Analysis. 2020;15(3):1007–1013. [Google Scholar]

Associated Data

This section collects any data citations, data availability statements, or supplementary materials included in this article.

Supplementary Materials

Supinfo

Data Availability Statement

The data used in Section 6.1 were obtained with the assistance and supervision of the Clinical and Translational Accelerator (CTRA), Department of Medicine, Yale School of Medicine and the Joint Data Analytics Team. This research data are not publicly available due to privacy or ethical restrictions. The data used in Section 6.2 were prepared using the Research Materials (NHLBI Growth and Health Study) obtained from the NHLBI Biologic Specimen and Data Repository Information Coordinating Center (BioLINCC) and do not necessarily reflect the opinions or views of the NHLBI Growth and Health Study or the NHLBI. The NHLBI Growth and Health Study data is available from the NHLBI BioLINCC website and can be requested at https://biolincc.nhlbi.nih.gov/studies/nghs/.

RESOURCES