Skip to main content
Wiley Open Access Collection logoLink to Wiley Open Access Collection
. 2026 Mar 10;45(6-7):e70481. doi: 10.1002/sim.70481

Bayesian Sensitivity Analysis for Causal Estimation With Time‐Varying Unmeasured Confounding

Yushu Zou 1,2, Liangyuan Hu 3, Amanda Ricciuto 4, Mark Deneau 5, Kuan Liu 1,
PMCID: PMC12975701  PMID: 41807294

ABSTRACT

Causal inference relies on the untestable assumption of no unmeasured confounding to ensure the causal parameter of interest is identifiable. Sensitivity analysis quantifies the unmeasured confounding's impact on causal estimates. Among sensitivity analysis methods proposed in the literature, the latent confounder approach is favored for its intuitive interpretation via the use of bias parameters to specify the relationship between the observed and unobserved variables, and the sensitivity function approach directly characterizes the net causal effect of the unmeasured confounding without explicitly introducing latent variables to the causal models. In this paper, we developed and extended these two sensitivity analysis approaches, namely the Bayesian sensitivity analysis with latent confounding variables and the Bayesian sensitivity function approach for the estimation of time‐varying treatment effects with longitudinal observational data subjected to time‐varying unmeasured confounding. We investigated the performance of these methods in a series of simulation studies and applied them to a multicenter pediatric disease registry to provide practical guidance on their implementation.

Keywords: Bayesian sensitivity analysis, longitudinal data, sensitivity function, unmeasured confounding

1. Introduction

Observational studies provide a feasible, efficient, and cost‐effective design for gathering evidence to study treatment and exposure effects [1]. These data present inherent complexities for comparative effectiveness research, such as time‐varying treatment‐confounding feedback, where the confounders change over time and are influenced by past treatment. Administrative databases are a common source of observational data. Although administrative data are rich in information that spans diagnostic codes, health service billing codes, prescription records, and other information collected at each health service encounter, key variables such as detailed clinical biomarkers and sociodemographic variables (e.g., education level and household income) are not always captured [2]. These variables are often considered unmeasured confounding variables in the causal conceptual framework. For causal estimation, unmeasured confounding violates the strongly ignorable treatment assignment assumption and can lead to biased estimates of treatment effects [3].

Sensitivity analysis can be applied to quantify the impact of unmeasured confounding on causal estimation, and has been advocated by the Strengthening the Reporting of Observational Studies in Epidemiology (STROBE) guidelines for the purpose of examining the influence of potential unmeasured confounding [4]. Unmeasured confounding is typically captured through one or more nonidentifiable numerical parameters, commonly termed bias parameters (or known as sensitivity parameters) [5, 6]. One proceeds by specifying and formulating the bias parameters with a plausible range of values and derives the bias‐corrected causal estimand using these bias parameters. There are two streams of sensitivity analysis approaches that have been proposed under this framework, namely the latent variable approach and the sensitivity function approach (also known as the confounding function approach).

The latent variable approach introduces the unmeasured confounding as a single latent/unmeasured variable in the causal framework. Rosenbaum and Rubin first proposed this approach to examine how sensitive the conclusions of a study with a binary outcome are to a binary unmeasured confounder [7]. Several sensitivity methods have been developed under the latent variable approach for cross‐sectional data, including parametric [8, 9, 10, 11, 12, 13], nonparametric [14], and semi‐parametric [15, 16]. The latent variable approach is favored when external knowledge or external data is available to inform the distribution of the unmeasured confounding and the strength of association between the unmeasured confounding and the measured variables. Many approaches with the latent confounding variables fall under probabilistic sensitivity analysis, which posit probability distributions for the bias parameters and average over the distributions to obtain bias‐adjusted estimates, and can be estimated under full Bayesian inference or Monte Carlo estimation.

The sensitivity function approach is framed based on the exchangeability assumption. It uses the sensitivity function to characterize the net causal effect influenced by the unmeasured confounding. The sensitivity function is viewed as the bias parameter and used to derive bias‐corrected estimations of the average potential outcome to quantify the influence of unmeasured confounding on the average treatment effect. Existing methods for the sensitivity function approach include parametric [6, 17, 18], and semi‐parametric [19, 20]. The sensitivity function approach is preferred when there is insufficient knowledge about the unmeasured confounding and when the primary interest is in understanding the residual confounding in causal estimation without explicitly introducing the unmeasured confounding as random variables in causal modelling.

These two streams of sensitivity analysis for unmeasured confounding have been studied rigorously in the point treatment setting. Extensions to longitudinal causal data with time‐varying treatment and time‐varying unmeasured confounding are very limited and predominantly frequentist. In this paper, we proposed two Bayesian sensitivity analyses, one parametric method utilizing Bayesian g‐computation based on the latent confounding variable approach [21] and one semi‐parametric method utilizing Bayesian marginal structural models [22, 23] following the sensitivity function approach [6]. Our paper is organized as follows. Section 2 details the setup and notation. In Section 3, we provide an overview of our proposed sensitivity analysis procedure. In Section 4, we examine the performance of our proposed method using a simulation study. Section 5 demonstrates applying the proposed procedure to primary sclerosing cholangitis (PSC) registry data. A discussion of the proposed methods is provided in Section 6.

2. Causal Framework With Time‐Varying Treatment

Suppose we have data from an observational study in which patients are treated throughout J visits. We collect data of the form 𝒟n={Xi1,Ai1,,XiJ,AiJ,Yi}i=1n, which include ni.i.d. replicates of (X1,A1,,XJ,AJ,Y), such that XjRp denotes the measured characteristics at visit j; Aj{0,1} denotes the treatment assignment patients received at visit j, j=1,,J; and YR is continuous patient outcome. Let Uij be a time‐varying unmeasured confounder for patient i at visit j, it could be binary, categorical, or continuous. Overbar notation is used to indicate the history of the variable up to visit j, such that Xj={X1,,Xj} and Aj={A1,,Aj}. We suppress the subscript when denoting the entire sequence, for example, XJ=X. The DAG that illustrates the proposed causal framework with unmeasured time‐varying confounding is presented in Figure 1. Following Rubin's [24] potential outcome framework, define Y(a) as the potential outcome under the treatment sequence a. For J total visits, there are in total 2J potential outcomes corresponding to 2J unique binary treatment sequences a from set 𝒜={a1,a2J}. We defined the causal estimand of interest as the average treatment effect (ATE), without loss of generalizability, characterized by the pair‐wise mean difference between two average potential outcomes (APOs) of two distinct treatment sequences as ATE=E[Y(a)]EY(a). We assume stable unit treatment value assumption (SUTVA), consistency Yi=aa2JI{Ai=a}Yi(a), positivity, 0<P(Aj|Aj1,Xj,Uj)<1 and 0<P(Aj|Aj1,Xj)<1, and sequential latent ignorable treatment assumption, Y(a)Aj|Aj1,Xj,Uj. Given the complete data {U,X,A,Y} and above assumptions, E[Ya] is identifiable, such that

FIGURE 1.

FIGURE 1

Longitudinal causal diagram with time‐varying latent variables as unobserved confounders. Uj, Xj, and Aj represent latent confounders, observed confounders, and treatment at visit j, respectively. Y represents the end‐of‐study outcome.

E[Y(a)]=xJx1uJu1EY(a)|X=x,U=u,Aj=aj×j=1JPUj|Uj1=uj1,Xj=xj,Aj1=aj1×PXj|Uj1=uj1,Xj1=xj1,Aj1=aj1dui1duiJdxi1dxiJ (1)

where P(xj|·) denotes the distribution of visit‐specific measured confounding xj and P(Uj|·) denotes the distribution of visit‐specific unmeasured confounding Uj.

Several causal approaches have been proposed for estimating time‐varying treatment effect when U is observed [21, 22, 25, 26, 27]. The sequential latent ignorability treatment assumption does not hold without conditioning on U, leading to unidentifiability of the average potential outcome in (1). The two proposed extended Bayesian sensitivity analysis approaches discussed in the following section can be applied to return a bias‐correct causal estimand, following a plug‐in type of estimation with a researcher‐specified plausible range of the time‐varying unmeasured confounding (i.e., on the strength and direction of the relationship between the unmeasured confounding and the measured variables).

3. Method

3.1. Bayesian Latent Variable Sensitivity Analysis

We proposed a Bayesian latent variable sensitivity analysis following the line of work similar to Greenland et al. [28] and McCandless et al. [10] Under a Bayesian framework, one can naturally quantify the estimation uncertainty that arises from the latent confounding variable using posterior probabilistic inference and can incorporate prior evidence, expert knowledge, and external data on the distribution of the unmeasured confounding and the association between the unmeasured confounding and measured variables via prior specification. We assume 𝒟i is an exchangeable sequence of real‐valued random quantities over patient index with unknown parameters α, γ, τ, and β characterizing the treatment assignment model, the observed confounder model, the latent confounder model, and the outcome model, respectively. Let Λ={α,γ,τ,β} be the set of model parameters. Specifically, we denote λ={αU,γU,τU,βU} as the set of bias parameters that quantify the association between the single, hypothesized time‐varying unmeasured confounding Uij and time‐varying measured variables [11]. αU represents the association between treatment A and unmeasured confounding U, γU represents the association between measured confounding X and unmeasured confounding U, τU represents the association between unmeasured confounder U and other measured variables, and βU represents the association between outcome Y and unmeasured confounder U. The likelihood of the observed data given parameters over n subjects and J visits for a binary time‐varying U is

i=1nP𝒪i|Λ=i=1nui1=01uiJ=01PYi|Ai,Xi,Ui,β×j=1JPAij|Aij1,Xij,Uij,αj×PUij|Uij1,Aij1,Xij,τj×PXij|Xij1,Aij1,Uij1,γj. (2)

We assume the parameters to be a priori independent, such that f(Λ)=f(β)f(α)f(γ)f(τ). Thus, the posterior distribution can be decomposed as f(Λ|O)=f(β|𝒪)f(α|𝒪)f(γ|𝒪)f(τ|𝒪) (see Appendix B). Under Bayesian g‐computation, APO is estimated using posterior predictive inference, where

EYi(a)|𝒪=ΛEYi(a)|Λf(Λ|𝒪)dΛ. (3)

To carry out the sensitivity analysis, we focus on specifying the prior distributions of the bias parameters {αU,γU,τU,βU}, which capture our assumptions and knowledge about the unmeasured confounding across visits. When subject‐matter expertise or external data are available, we recommend using these to center and scale the priors for the bias parameters in a clinically interpretable way [11]. For example, by encoding plausible odds ratios or mean differences for the effect of the unmeasured confounder on treatment and outcome. For a binary outcome, we could consider βUUnif(2,2) on the log odds scale, which corresponds to an odds ratio ranging between exp(2) and exp(2) for the effect of U on the outcome Y. In settings where such information is limited, weakly informative priors can be used [29, 30].

3.1.1. On Partial Identification and Bayesian Sensitivity Analysis

Under the latent variable formulation, the observed data likelihood is written as (2). The bias parameters λ={αU,γU,τU,βU} are not point identified from the observed data 𝒪, and any causal estimand that depends on λ cannot be consistently estimated from 𝒪 alone. Thus, with U unobserved, the APO, ψ(a), is not point identified. Following the terms introduced in Gustafson [31, 32], a model is partially identified when the identification region is not a singleton, so posterior uncertainty does not collapse to a point as n. Formally, let 𝒪 denote the true observed data law of 𝒪i, define the set of parameter values consistent with 𝒪 by Ω(𝒪)=Λ:PΛ(𝒪i·)=𝒪(𝒪i·) with corresponding identification region for ψ(a) as Ψa(𝒪)=ψ(a;Λ):ΛΩ(𝒪). A convenient way to formalize partial identification can be considered via intuitive Bayesian reparameterization, which is called transparent parameterization [31]. Specifically, Λ can be re‐parameterized into ϕ=(ϕI,ϕNI) such that the observed data model depends only on ϕI (identified), while ϕNI represents the nonidentified portion. Under Bayesian latent variable sensitivity analysis, it is natural to treat ϕNI as containing the bias parameters (the components of α,γ,τ,β governing associations with U), while ϕI collects the observed data parameters that are estimable from 𝒪. Under this reparameterization, any causal estimand expressible as a functional ψ=g(ϕI,ϕNI) (e.g., APO/ATE), the marginal posterior can satisfy a large sample limit where f(ψ|𝒪)1g(ϕI,ϕNI)dψf(ϕNI|ϕI)dϕNI,n. This limiting posterior distribution is supported on the identification region of the causal estimand, and the posterior uncertainty generally does not shrink to a point even with arbitrarily large samples (a key feature for partially identified Bayesian models). Because ϕNI is not learned from 𝒪, the limiting posterior depends on the prior f(ϕNI|ϕI). This also explains why the influence of the prior on bias parameters does not vanish with increasing n when the confounding is truly unobserved [11, 31, 32].

3.1.2. On Computational Considerations

Bayesian causal estimation can be carried out via g‐computation [21, 33]. We will generate posterior samples of the bias and nonbiased parameters and plug them into Equation (3) to obtain the posterior predicted distribution of E[Yi(a)]. Given a set of posterior draws of all parameters, Λs, the APO is computed in two steps for each Monte Carlo iteration s as follows (suppressing covariates):

  • 1.

    given Λs, calculate Yis(a), i=1,,n over j=1,,J visits, with E[Yis(a)]=xiJxi1uiJui1E[Yi(a)|xi,ui,Aij=aij]j=1JP(Uij|uij1,xij,Aij1=aij1)P(Xij|uij1,xij1,Aij1=aij1)dui1duiJdxi1dxiJ

  • 2.

    with Yis(a), i=1,,n, calculate mean over i.

Under the full Bayesian estimation following the joint likelihood in step (2), the unmeasured confounder U is predicted at each Monte Carlo iteration along with posterior draws of all model parameters. However, the imputed unmeasured confounder is not directly used to estimate the APO; instead, its posterior distribution, which is conditioned on past unmeasured confounders, past treatment, and measured variables, is used. In this paper, we set the unmeasured confounders at each visit to be binary, which denotes the presence or absence of unmeasured confounding in the observed data. In practice, one can treat U as a continuous, time‐varying variable and proceed with the same estimation steps outlined above.

Partial identification can have direct implications for posterior computation. In particular, Gustafson [32] highlights that computation is often a “bottleneck” in partially identified models and off‐the‐shelf MCMC algorithms may exhibit very poor mixing. This phenomenon echoes with the general structure of partially/nonidentified Bayesian models. Under a transparent reparameterization, the posterior for the identified component concentrates as n, while the conditional posterior for the nonidentified component remains prior‐driven [31]. In our implementation, our inferential targets are causal estimands such as the APOs and ATEs obtained through posterior predictive g‐computation. We thus prioritize convergence assessment for the posterior draws of these causal estimands. In practice, we recommend convergence diagnostics with additional care in assessing the sensitivity of the Bayesian computation to the choices of priors for these bias parameters. For more complex longitudinal settings (e.g., more visits), additional strategies may be needed, including more informative priors grounded in external knowledge.

3.2. Sensitivity Function Approach With Time‐Varying Unmeasured Confounding

We define the generalized sensitivity function to quantify the unmeasured time‐varying confounding as follows

cj,aJ,xJ=EY(a)|Aj=aj,Xj=xjEY(a)|Aj=1aj,Aj1=aj1,Xj=xj (4)

where aJ and xJ are the observed treatment history and measured confounder history for visits {1,,J} [6, 19, 20]. The sensitivity function directly captures the net difference in Y(a) between those at visit j treated with aj and those treated with 1aj, who have the same covariates and treatment history leading to visit j. When the sequential ignorability assumption holds (i.e., Y(a)Aj|Aj1,Xj), the sensitivity function c(j,aJ,xJ) is valued at zero indicating that there is no presence of time‐varying unmeasured confounding at visit j. When the sequential ignorability assumption is violated in the presence of unmeasured confounding, the APO can be expressed using the sensitivity function as (see Appendix C for derivation),

E[Y(a)]=E[Y|A=a]XJX1j=1Jcj,aJ,xJ×P1aj|aj1,xjPxj|xj1,aj1×Px1dx1dxJ, (5)

where the bias in the estimation of APO from unmeasured confounding is

Bias=XJX1j=1Jcj,aJ,xJP1aj|aj1,xj×Pxj|xj1,aj1Px1dx1dxJ. (6)

Therefore, the average causal effect (ATE) comparing any two distinct treatment assignments aJ and aJ is

EYaJEYaJ=EY|aJEY|aJXJX1j=1Jcj,aJ,xJP1aj|aj1,xjPxj|xj1,aj1Px1+j=1Jcj,aJ,xJP1aj|aj1,xjPxj|xj1,aj1Px1dx1dxJ. (7)

A common approach to gauge the impact of unmeasured confounding is to perform a sensitivity analysis in which the causal effect is recalculated over a grid of plausible (unmeasured) confounding strengths. While informative, this strategy merely illustrates how the estimate might vary. A more principled alternative is to account for the bias due to unmeasured confounding directly, producing a bias‐corrected causal effect estimate [17, 19] Additionally, within a Bayesian framework, this correction naturally propagates both sampling variability and the uncertainty encoded in the sensitivity function, yielding a coherent posterior distribution for the causal effect.

YSF=Yj=1Jcj,AJ,XJP1aj|Aj1,Xj. (8)

Mathematically, we can show that replacing observed outcome Yi with YiSF can effectively remove the bias in Equation (7); details are presented in Appendix C. Consider the causal effect between any pair of treatments a and a using the adjusted outcomes YiSF, the estimate of the causal effect is ATE=E[YSF|AJ=aJ]E[YSF|AJ=aJ]. Several causal estimation approaches for time‐varying treatment and confounding can be applied to estimate causal effect given the bias‐corrected YSF, including the marginal structural models (MSM) [6] and the Bayesian marginal structural models (BMSM) [22, 23]. In this study, we implemented BMSMs to provide a Bayesian estimation extension to the sensitivity function approach.

The sensitivity function approach relies on the specification of the unidentifiable sensitivity function. Methodologies exist for devising functional forms of the sensitivity function. Interpretation of the sensitivity function for the point‐treatment setting with cross‐sectional data can be found in Hu et al. [19]. We can consider the following strategies for specifying the sensitivity function c(·):

  1. Leverage subject‐matter expertise to assume a plausible distribution for c(·), as in Brumback et al. [6] and Li et al. [17]. The c(·) can be expressed as a scalar parameter α or as a function of the measured covariates and treatment.

  2. For a binary outcome, c(·) denotes the expected difference between two probabilities on the outcome, with a natural bound of [1,1]; For a continuous outcome, c(·) denotes the difference between two expected potential outcome functions. This is naturally bounded by the differences between the minimum and the maximum value of the outcome.

  3. c(·) can also be specified to represent the residual confounding from the conditional outcome model that is not explained by measured covariates and treatment [34]. In Hu et al. [19], an estimated R2 from the conditional outcome model was used to capture residual confounding for a binary outcome.

3.2.1. Bayesian Marginal Structural Models With Sensitivity Function

Following Saarela et al. [22], the estimation of the marginal treatment effect proceeds by maximizing the expected utility function (e.g., the log‐likelihood of the marginal outcome model given treatment history) for a new subject following Bayesian decision theory and importance sampling. Let u(Θ) be the utility function for subject i. Bayesian marginal structural models maximize the utility function with respect to the Θ, the causal parameter of interest (i.e., the marginal treatment effect parameters), and the natural choice of the utility function would be the log‐likelihood of the marginal treatment effect outcome model with sensitivity function corrected outcome. Let Dn denote the complete observed data and 𝒟i denote the complete observed data of a new subject i. The expectation of our utility function can be expressed using posterior predictive inference and the importance sampling technique for a new subject, such that

Eu(Θ)|Dn=dilogPyiSF|ai;ΘP(𝒟i|Dn)P𝒪(𝒟i|Dn)P𝒪𝒟i|Dnd𝒟i. (9)

Let wi=P(𝒟i|Dn)P𝒪(𝒟i|Dn), which denotes the subject‐specific importance sampling weight and can be derived further as [22],

wi=𝔼αj=1JPAij|Aij1,α|a1,,an)𝔼βj=1JP𝒪Aij|Xij,Aij1,β|x1,,xn,a1,,an). (10)

We estimate the marginal treatment effect parameters Θ by maximizing Equation (9) with respect to Θ. This is achieved in a two‐step estimation process where in the first step we estimate the importance sampling weights and in the second step we use the nonparametric Bayesian Bootstrap to approximate P𝒪(𝒟i|Dn). Under the Bayesian bootstrap, P(π), the bootstrap sampling weights are sampled from Dirn(1,,1). The marginal treatment effect parameter Θ given the sensitivity function is then estimated via,

Θ^=argmaxθ1Bb=1Bi=1nπi(b)w^i×logPyij=1Jcj,aj,xjP1aj|aj1,xj|ai; Θ (11)

where the importance sampling treatment assignment weights, wi are estimated by the posterior mean of the predictive sequential treatment assignment density under and 𝒪 given the observed data. When B, πi(b)BE(πi). A point estimate of Θ in Equation (11) can be returned by Monte Carlo integration over the Dirichlet πi draws or by approximating πi at its expected value 1n. The estimation uncertainty can be captured in terms of the sampling probability distribution of π following the approximate Bayesian weighted likelihood bootstrap [35]. We obtain a posterior distribution of Θ by repeatedly drawing π from the uniform Dirichlet distribution and maximizing the π weighted expected utility function.

As emphasized by Robins, Hernán and Wasserman [22], factorization‐based Bayes procedures under independent priors generally cannot yield uniformly consistent inference for causal parameters in high‐dimensional observational settings, and incorporating propensity scores within a fully generative Bayesian model is inherently challenging (See discussion and rejoinder in Saarela et al. for details). Our BMSM formulation is not a “strict” Bayesian analysis based on a joint likelihood factorization for all observed processes and independent priors on treatment and outcome model parameters. Instead, this approach aligns with generalized or loss‐based Bayesian procedures, where posterior predictive quantities are combined with a parametric marginal utility function to define an estimator of interest and is regarded as a semi‐parametric approach [23, 35, 36].

4. Simulation

We conducted a series of simulation experiments to evaluate the effectiveness of these two proposed methods. We considered the following simulation scenarios: time‐varying unmeasured confounding (Figure 2a), time‐invariant unmeasured confounding (Figure 2b), and no unmeasured confounding. Under time‐varying unmeasured confounding, we considered three cases of unmeasured time‐varying confounding: one binary unmeasured time‐varying confounder, one continuous unmeasured time‐varying confounder, and two time‐varying unmeasured confounders (one binary and one continuous). Data‐generating details were outlined in the Supporting Information.

FIGURE 2.

FIGURE 2

Longitudinal causal diagram with latent variables as unobserved confounders in simulation settings.

We considered two sample sizes n=500 and n=1000 and compared the following causal analyses: (i) a naive MSM fitted to the observed data without the adjustment of unmeasured confounding (defined as the “worst‐case” analysis), (ii) a second MSM fitted to the complete data treating the unmeasured confounder as a measured variable (defined as the “best‐case” analysis), (iii) the time‐varying sensitivity function approach using frequentist MSMs, (iv) the time‐varying sensitivity function approach using Bayesian MSMs, (v) the proposed Bayesian latent variable sensitivity approach with time‐invariant U (BSA time‐invariant U), and (vi) the proposed Bayesian latent variable sensitivity approach with time‐varying U (BSA time‐varying U). For the sensitivity function approach, the visit‐specific sensitivity function c(j,aJ,xJ) is first set to its true data‐generating value to isolate the performance under correctly specified sensitivity function. In practice, c(·) is unknown and we impose a plausible range, where the resulting credible/confidence intervals would naturally incorporate this additional source of uncertainty. We added another sensitivity function specification where the visit‐specific sensitivity functions are drawn from a uniform distribution centered at the true data‐generating value with a margin of error twice in size of the residual confounding obtained from the outcome model. Similar to the steps discussed in the data application in Hu et al. [19], we use the residual standard deviation estimated from the conditional outcome model, σ^. The sensitivity function will fall within the plausible range of ±hσ^, where h=2. For the Bayesian latent variable approach, we assigned bias parameters in the treatment model with a prior of Unif(2,2), which implied odds ratios for the association between U and A that range from exp(2)=0.14 to exp(2)=7.39. We specified the priors for the bias parameters in the outcome model with Unif(10,10) (scaled to match the simulated true value, see Supporting Information for details). In our simulation study, we employ relatively diffuse uniform priors for illustration. Practical guidance on how to specify a clinically informative sensitivity function and bias parameters is discussed in our data application. We provided our simulation R code on GitHub, https://github.com/reidbrok/SensitivityAnalysis_TimeVarying.

For all simulation scenarios, the causal parameter of interest was the causal contrast in the outcome between “always treated” and “never treated”, denoted as E(Y(1))E(Y(0)). We considered each simulation setting with ns=1000 replications and reported the estimated mean (or posterior mean) of the causal effect as 1nsATES, relative bias (RB)=1nss=1nsATE^sATEATE, empirical standard deviation of ATE (ESD)=1ns(ATE^sATE)2, average standard deviation of ATE (ASD)=1nssd(ATES), and the 95% coverage probability (CP). For Bayesian approaches, the ASD reports the posterior standard deviation of the estimated ATE averaged over simulation replicates, and the ESD is computed from the posterior means across replicates.

In scenarios involving time‐varying unmeasured confounding, as shown in Table 1, the BSA time‐varying U and the two sensitivity function approaches produced posterior means of the ATE that were close to the data‐generating value, with relatively small finite sample bias under our simulation design. Importantly, the true ATE is not identifiable unless the sensitivity parameter is correctly specified. When it is correctly specified, the posterior mean of the ATE is close to the true ATE. We emphasize that, because the models with unmeasured confounding are not fully identified, these findings do not imply classical consistency [11, 32]. The sensitivity function approach with both frequentist and Bayesian MSMs returned a smaller ESD as expected, where the sensitivity parameters are centered at the true data‐generating values. The bias‐corrected outcome YiSF can exhibit reduced residual variability relative to the naive MSM that ignores unmeasured confounding. When we increase the uncertainty around plausible values of the sensitivity function (e.g., h=2), we observed increased variability of ASD across iterations and higher CP. Given partial identification of the BSA approach, we expect the posterior uncertainty not to substantially decrease with increasing sample size, and our simulation results illustrate this behavior. Compared to the other approaches, when the sample size increases from n=500 to n=1000 (comparing setting 1 to setting 4 in Table 1 and Figure 3), we do not observe large reductions in ESD and ASD.

TABLE 1.

Simulation results for the estimated causal parameter E[Y(1,1,1)]E[Y(0,0,0)] over 1000 replications among different time‐varying confounding settings, including posterior predictive mean, relative bias (RB), empirical standard deviation (ESD), average standard deviation (ASD), and 95% CP.

Setting Estimator Mean RB ESD ASD CP
n = 500, time‐varying Bernoulli U True ATE = −10.27 MSM U included −10.28 −0.12 0.66 0.61 92.6
MSM U excluded −11.48 −11.76 0.60 0.59 43.7
Sensitivity Function (MSM) −10.33 −0.59 0.49 0.59 98.0
Sensitivity Function (BMSM) −10.34 −0.64 0.49 0.57 97.6
Sensitivity Function (MSM, h=2) −10.33 −0.58 0.49 0.72 99.4
Sensitivity Function (BMSM, h=2) −10.33 −0.64 0.49 1.15 100.0
BSA time‐invariant U −10.58 −3.06 0.76 1.04 97.1
BSA time‐varying U −9.77 4.90 0.91 1.58 99.1
n = 500, time‐varying Normal U True ATE = −9.74 MSM U included −9.77 −0.35 0.73 0.56 90.2
MSM U excluded −10.46 −7.35 0.38 0.42 60.6
Sensitivity Function (MSM) −9.69 0.52 0.32 0.42 99.4
Sensitivity Function (BMSM) −9.69 0.52 0.31 0.38 98.1
Sensitivity Function (MSM, h=2) −9.69 0.53 0.32 0.67 100.0
Sensitivity Function (BMSM, h=2) −9.69 0.51 0.32 1.01 100.0
BSA time‐invariant U −10.08 −3.49 0.41 0.63 98.1
BSA time‐varying U −9.59 1.55 0.48 1.11 99.9
n = 500, two time‐varying Us, one Normal U, one Bernoulli U True ATE = −10.40 MSM U included −10.43 −0.34 0.74 0.68 92.6
MSM U excluded −11.84 −13.88 0.58 0.57 30.8
Sensitivity Function (MSM) −10.57 −1.67 0.46 0.57 97.3
Sensitivity Function (BMSM) −10.57 −1.70 0.46 0.55 97.1
Sensitivity Function (MSM, h=2) −10.57 −1.68 0.46 0.69 99.3
Sensitivity Function (BMSM, h=2) −10.57 −1.68 0.46 1.11 100.0
BSA time‐invariant U −1.21 88.17 1.68 4.06 40.0
BSA time‐varying U −10.20 1.87 0.91 1.58 99.3
n = 1000, Time‐Varying Bernoulli U True ATE = −10.27 MSM U included −10.26 0.13 0.44 0.44 95.5
MSM U excluded −11.47 −11.72 0.41 0.41 18.4
Sensitivity Function (MSM) −10.33 −0.54 0.33 0.41 99.2
Sensitivity Function (BMSM) −10.33 −0.56 0.33 0.41 99.3
Sensitivity Function (MSM, h=2) −10.33 −0.54 0.33 0.51 99.9
Sensitivity Function (BMSM, h=2) −10.33 −0.56 0.33 0.82 100.0
BSA time‐invariant U −10.48 −1.99 0.82 0.88 93.1
BSA time‐varying U −9.67 5.88 0.99 1.43 96.8

Abbreviations: BMSM, Bayesian marginal structural models; BSA, Bayesian Sensitivity Analysis approach; MSM, marginal structural models.

FIGURE 3.

FIGURE 3

Estimates of causal effect ATE among 1000 replications. Setting 1: n=500 with time‐varying binary U; Setting 2: n=500 with time‐varying continuous U; Setting 3: n=500 with two unmeasured confounder s, one continuous, one binary; Setting 4: n=1000 with time‐varying binary U; The ATE results that could be achieved if U were observed and the naive ATE estimators excluding U are also presented. Dashed lines mark the true ATE.

The BSA time‐invariant U performed relatively well in settings with a single binary or continuous unmeasured time‐varying confounder. However, the BSA time‐invariant U performed poorly when data were generated with two time‐varying unmeasured confounders. This was a clear indication that when working with longitudinal causal data, one should consider implementing time‐varying U. In the simulation settings where data were generated in the absence of unmeasured confounding (Table S1), the BSA time‐invariant U performed better than the BSA time‐varying U in terms of relative bias and CP. When the true data‐generating mechanism involved a time‐invariant binary unmeasured confounder (Table S1), all methods except the naive estimator produced relatively unbiased point estimates. The BSA time‐varying U maintained good performance, suggesting flexibility even when the unmeasured confounder did not vary over time.

5. Application to Pediatric PSC Registry Data

The objective of the data analysis was to quantify the effectiveness of oral vancomycin therapy (OVT) for pediatric primary sclerosing cholangitis (PSC) using a multicenter PSC registry. We applied the proposed longitudinal sensitivity analysis to this clinical dataset with time‐varying treatment and confounding. PSC is a chronic cholestatic liver disease characterized by ongoing inflammation, destruction, and fibrosis of intrahepatic and extrahepatic bile ducts [37, 38]. OVT has garnered substantial interest as a potential treatment for PSC. Deneau et al. [39] utilized propensity score matching to estimate the effectiveness of OVT initiated at the time of diagnosis, compared to ursodeoxycholic acid (UCDA) and no treatment. They conducted a cross‐sectional causal analysis and concluded that neither OVT nor UDCA received at the time of diagnosis as the first‐line treatment improved biochemical or histopathological outcomes at 1 year. They also reported that patients who received OVT as their initial therapy were more likely to present with mild fibrosis. More recently, Ricciuto et al. [40] investigated the association between OVT and inflammatory bowel disease (IBD) outcomes in children with PSC‐IBD, again focusing on 1‐year clinical and biochemical endpoints. Both studies were based on the same registry used in our data application, and both adopt a follow‐up structure where key biomarkers are assessed at annual intervals. PSC patients can switch to or from OVT after diagnosis, and the effectiveness of OVT through the course of PSC after diagnosis remains unknown. It is of great clinical interest to estimate the time‐varying effect of OVT.

The multinational Pediatric PSC Consortium research registry included patients diagnosed with PSC before age 18 years at any participating site. To qualify, patients had to meet PSC diagnostic criteria through cholestatic biochemistry and consistent imaging or histopathology, as outlined by Deneau et al. [39, 41]. We utilized a subset of the full registry dataset and the use of the clinical data are intended solely for the purpose of illustrating methodology and not to infer any clinical conclusions. Our data analysis was restricted to subjects who had complete measurements of GGT at the time of diagnosis and two years post‐diagnosis. Exclusion criteria were patients with missing PSC onset dates and those who had received OVT before their PSC diagnosis. However, patients who underwent liver transplantation during the follow‐up period were still considered for inclusion in the study.

The primary outcome was the log‐GGT at 2 years after diagnosis. Patients were defined as being exposed to OVT at each follow‐up visit if they received OVT during the preceding year, based on recorded start and stop dates. Baseline covariates included age at PSC diagnosis, sex, PSC phenotype (large‐ vs small‐duct), concurrent inflammatory bowel disease (IBD), autoimmune hepatitis (AIH) overlap, Metavir fibrosis stage, prior hepatobiliary events, steroid use, ursodeoxycholic acid (UDCA) use, and baseline GGT. Several variables were assessed both at baseline and at the 1‐year follow‐up (IBD, AIH overlap, Metavir stage, hepatobiliary events, steroid and UDCA use, and log‐GGT). For each visit, IBD and AIH overlaps were defined based on whether a diagnosis was recorded on or before that visit date. Metavir fibrosis stage at each visit was taken from the closest liver biopsy performed within the 12 months preceding the visit. Hepatobiliary events were coded as having occurred if an event date was on or before the visit date. We were interested in estimating the changes in the mean of log‐GGT at 2 years after diagnosis between patients who were exposed to OVT between 0 to 1 year and between 1 and 2 years (OVT = 11, “always treated”) and patients who were OVT‐free over 2 years (OVT = 00, “never treated”). The proposed causal diagram is provided in Figure 4.

FIGURE 4.

FIGURE 4

Longitudinal causal diagram between OVT, log‐GGT, and confounders. Uj, Xj, and OVTj represent latent confounders, observed confounders, and treatment at visit j, respectively. ln(GGT) represents log‐GGT at 2 years. X0 and X1 represent a set of confounders, including age at diagnosis, sex, PSC phenotype at diagnosis, and time‐varying log‐GGT, hepatobiliary events, concurrent IBD, overlapping AIH, Metavir fibrosis stage, steroid and UDCA use at baseline and 1 year.

5.1. Guided Clinically Informed Sensitivity Analysis for Unmeasured Confounding

To illustrate how subject matter knowledge can be used to specify clinically interpretable sensitivity parameters, we used Metavir fibrosis stage (stage III & IV versus stage I & II) as a template time‐varying unmeasured confounder. A higher Metavir stage is often clinically associated with disease activity (and thus cholestatic biomarkers such as GGT) and treatment decisions. We used this variable to motivate an informative specification on the sensitivity/bias parameters. We carried out the following causal analysis: (i) the conventional MSMs analysis without Metavir fibrosis stage, (ii) the sensitivity function approach with BMSMs and clinical knowledge on Metavir fibrosis stage, (iii) the BSA model without clinical knowledge on Metavir fibrosis stage, (iv) the BSA model with clinical knowledge on Metavir fibrosis stage, and (v) the conventional MSMs analysis including Metavir fibrosis stage.

For subject i, let Ai1{0,1} denote OVTInline graphic exposure at baseline and Ai2{0,1} denote OVTInline graphic exposure at 1 year. We denote Yi for log‐GGT at 2 years, Zi for time‐invariant covariates (age at diagnosis, sex and PSC type), and Xi0 and Xi1 for measured time‐varying covariates at baseline and year 1, respectively. We define the binary template confounder Metavir fibrosis stage as Ui0 and Ui1. Because Metavir fibrosis stage is observed in our cohort, we can verify the direction of confounding implied by the Metavir fibrosis stage and inform the plausible range of the bias parameters and sensitivity function. We fit visit‐specific treatment models to quantify the association between Metavir fibrosis stage and OVT use, and an outcome regression to quantify the association between Metavir fibrosis stage and outcome. The treatment models and outcome model are specified as following

logitPAi1=1|Zi,Xi0,Ui0=α10+α1ZZi+α1XXi0+α1UUi0, (12)
logitPAi2=1|Ai1,Zi,Xi0,Xi1,Ui0,Ui1=α20+α2AAi1+α2ZZi+α20XXi0+α21XXi1+α20UUi0+α21UUi1, (13)
Yi=βY0+β1Ai1+β2Ai2+βZZi+βX0Xi0+βX1Xi1+βU0Ui0+βU1Ui1+εi,εi𝒩0,σY2. (14)

The fitted coefficients {α^1U,α^2U0,α^2U1,β^U0,β^U1} quantify the strength of association between Metavir stage and OVT and between Metavir stage and outcome. We implemented the conventional frequentist MSMs model using the R package WeightIt [42] with stabilized weights and estimated our targeted causal effect using a weighted regression with bootstrap variance. The visit‐specific conditional treatment assignment model in (12) and (13) was fitted via logistic regression.

5.1.1. Clinically Informed Specification of BSA and Sensitivity Function

We can specify Uniform priors for the BSA bias parameters centered at these calibration estimates, λu|κUnifλu^κse^(λu^),λu^+κse^(λu^),λu{α1U,α2U0,α2U1,βU0,βU1}. We can take κ=2 as a default (approximately reflecting a 95% Wald interval) and perform sensitivity analyses over alternative choices of κ to reflect stronger or weaker prior informativeness.

Because the Metavir fibrosis stage is measured, we can obtain an intuitive, visit‐specific center for c by first estimating the potential outcomes Yi(a1,a2) for each subject under each treatment regimen (a1,a2) with U treated as observed. One can use parametric g‐computation to calculate Yi(a1,a2) given U and plug it into the sensitivity function formulation in (4). We specify plausible ranges around the calibrated centers using uncertainty about the magnitude of residual confounding at each visit. For a sensitivity multiplier h>0 (e.g., h{1,2}), we set cj,a1,a2Unifc^j,a1a2hσ^Y,c^j,a1a2+hσ^Y. We propagate uncertainty in c by Monte Carlo sampling and re‐estimating the target causal contrast under the sensitivity function procedure described in Section 3.2 to obtain bias‐corrected YSF followed by estimating ATE using MSM or BMSM. In this data application, we implemented BMSM using the R package bayesmsm [43].

For noninformative sensitivity function specification, we used cj,a1,a2Unif0hσ^Y,0+hσ^Y,h=2. For noninformative BSA bias parameter priors, we used Unif(5,5) and Unif(2,2) for intercepts and coefficients, respectively. Diffuse normal priors centered at 0 with precision 0.01 for intercepts and 0.1 for coefficients. For BSA and sensitivity function with BMSM, we saved 15 000 MCMC draws using 25 000 burn‐in iterations and 25 000 further iterations, with every fifth sample being gathered. MCMC convergence was evaluated using Geweke's Z‐score and traceplots (See Figures S3 and S4) [44]. All statistical analyses were conducted using R software (version 4.3.2) and Just Another Gibbs Sampler (JAGS, version 4.3.0) [45].

The final cohort included 377 PSC patients diagnosed between July 1988 and December 2017. Of these, 322 patients were OVT‐free over the first 2 years after diagnosis, 19 patients were prescribed OVT only between 1 and 2 years after diagnosis, and 36 patients were prescribed OVT between 0 to 1 year and remained on OVT at 2 years. The majority of the patients were male (58.1%) with the average age at baseline of 12.3 years (4.1 SD). In addition, 57% of patients were diagnosed with IBD before PSC onset. We observed some differences between OVT exposure groups in sex, concurrent IBD diagnosis, baseline GGT and APRI, and baseline exposure to other medications, including steroids and aminosalicylates, indicating an imbalanced baseline profile (Table S2). The estimated effect comparing OVT 11 versus 00 was similar across the conventional MSM (with or without Metavir stage), the sensitivity function analysis, and the BSA analysis, indicating robustness of the estimated effect to plausible residual confounding induced by fibrosis stage in this cohort (Table 2). Details on the informatively specified sensitivity function and BSA bias parameters are provided in the Tables S3 and S4.

TABLE 2.

Estimated treatment effect of OVT on study outcomes while treating Metavir fibrosis stage as the unmeasured confounder.

OVT on end‐study measured ln(GGT): 11 vs 00 Mean SD 95% CI
MSM (Metavir fibrosis stage excluded) −0.20 0.22 (−0.63, 0.22)
Sensitivity function with noninformative center and h=2 −0.18 0.23 (−0.63, 0.27)
Sensitivity function with informative center and h=2 −0.21 0.23 (−0.66, 0.24)
BSA with noninformative prior −0.24 0.21 (−0.63, 0.18)
BSA with clinical informative prior −0.23 0.22 (−0.65, 0.20)
MSM (Metavir fibrosis stage included) −0.22 0.21 (−0.64, 0.20)

Note: The columns are mean, standard deviation, and 95% CI of the posterior predictive distribution of the causal effect.

Abbreviations: BSA, Bayesian sensitivity analysis; CI, credible interval or confidence interval; ln(GGT), natural logarithm transformed gamma‐glutamyl transferase; MSM, marginal structural models; OVT, oral vancomycin therapy.

5.1.2. More on the Clinical Interpretation of the Informative Sensitivity Functions

Using Metavir fibrosis stage as a template time‐varying unmeasured confounder, we obtained the following calibrated centers for the sensitivity functions on the log(GGT) scale: c^1,00=0.005, c^1,01=0.001, c^1,10=0.01, c^1,11=0.002, and c^2,00=0.029, c^2,01=0.021, c^2,10=0.02, c^2,11=0.022. A positive c^j,a1,a2 indicates that (conditional on the measured history) the subgroup that follows the regimen at visit j has a higher counterfactual mean log(GGT) under the target regimen than the subgroup that does not, consistent with worse latent prognosis in that subgroup due to unmeasured fibrosis stage; a negative c^j,a1,a2 indicates the reverse. In our cohort, the baseline centers are close to 0, suggesting limited residual confounding at the baseline OVT decision after adjusting for measured covariates, whereas the informative centers are larger in magnitude at 1 year, suggesting more residual confounding at year 1. The sign pattern c^2,a1,a2>0 when a2=0 and c^2,a1,a2<0 when a2=1 indicates that patients receiving OVT at year 1 tend to have slightly better latent prognosis (e.g., milder fibrosis and hence lower counterfactual log‐GGT). Under the calibrated centers, the sign pattern suggests that any residual bias from omitting fibrosis stage would be expected to be small and, if anything, to act toward attenuating the apparent benefit of OVT as observed in Table 2.

6. Discussion

In this study, we introduced two Bayesian approaches for causal sensitivity analysis in the presence of unmeasured time‐varying confounding: the Bayesian latent variable approach and the Bayesian sensitivity function approach. The latent variable approach models time‐varying unmeasured confounding as hidden variables within the causal model, enabling the integration of external data or prior knowledge and offering greater conceptual and interpretative clarity in applied settings. In contrast, the sensitivity function approach directly characterizes the net bias induced by unmeasured time‐varying confounding without explicitly modelling latent variables, thereby avoiding distributional assumptions; however, this approach may be less interpretable in practice. To the best of our knowledge, this is the first study to formalize the derivation of both approaches and to provide a comprehensive comparison through simulation.

The Bayesian latent variable approach incorporates treatment, outcome, and covariate model‐specific bias parameters to quantify the relationship between unobserved and observed confounders. This is in line with other probabilistic sensitivity analysis methods that leverage prior knowledge of the bias parameters to conceptualize the impact of time‐varying unmeasured confounding, which naturally captures estimation uncertainty. Our BSA approach follows partial identification [31, 32], thus can exhibit challenging posterior computation, especially when weakly informative priors are placed on nonidentified components. This observation aligns with the “folk theorem” heuristic from Bayesian computation: when computation struggles, it is often a signal to revisit the model (e.g., parameterization, scale, or prior regularization) rather than merely running longer chains. In application, we advocate for careful convergence diagnostics, and we recommend using clinical/external knowledge to specify priors when feasible. The Bayesian sensitivity function approach with Bayesian marginal structural models has a natural connection to the frequentist sensitivity function approach with frequentist marginal structural models. Bayesian causal estimation under this method can be performed semi‐parametrically or nonparametrically, following maximization of the weighted utility function via Bayesian nonparametric bootstrap [22, 36, 46, 47]. As noted in the accompanying commentary by Robins, Hernán and Wasserman [22], such procedures differ from fully generative Bayesian analyses and do not generally yield uniformly consistent inference for causal parameters under arbitrary high‐dimensional observational data‐generating mechanisms. We view the sensitivity function approach with BMSM as a principled Bayesian‐flavored sensitivity analysis tool that coherently propagates uncertainty from treatment modelling and sensitivity function specification into causal contrasts, rather than as a fully generative Bayesian causal model.

Our simulation study reveals that the proposed Bayesian latent variable approach with a time‐varying latent confounder offers a practical strategy for addressing unmeasured confounding in longitudinal settings and can be extremely useful when there is historical or external data on the unmeasured confounding. While the sensitivity function methods can yield more efficient and unbiased estimates, they rely on the correct specification of the sensitivity function and are difficult to interpret and explain clinically. We recommend in practice to conduct both the Bayesian latent variable approach and the Bayesian sensitivity function approach, and to discuss the sensitivity analysis results with clinical collaborators to ensure sound and interpretable conclusions. Caution is warranted in settings where the unmeasured confounding structure is complex, such as when multiple confounders with differing temporal patterns are present. In such cases, the latent variable formulation underlying the BSA approach may be misspecified, potentially limiting its validity, as reflected in our simulation results, where the Bayesian latent variable approach with a time‐invariant latent variable performs poorly when the simulated causal data contains two time‐varying unmeasured confounders.

The Bayesian latent variable approach relied on the correct parametric model specification of the treatment, outcome, measured, and unmeasured confounding variables, while the Bayesian sensitivity function approach relied on the correct “guess” of the sensitivity function. Our simulation study did not consider scenarios of a mis‐specified conditional outcome model (e.g., the true outcome model features nonlinear terms where the outcome model in BSA is specified linearly) and scenarios where there is a skewed time‐varying unmeasured confounder in the simulated data. These more complicated causal structures can occur in data applications. Future work will explore this limitation by extending these two Bayesian causal sensitivity approaches with flexible estimation algorithms, such as Bayesian additive regression tree [19]. While this study focuses on a binary treatment and a continuous or binary end‐of‐study outcome, future research will explore more complex longitudinal causal structures. These include scenarios with repeatedly measured outcomes, multiple treatments, and time‐to‐event outcomes.

In conclusion, this study presents a Bayesian sensitivity analysis framework that effectively incorporates uncertainty surrounding bias parameters to provide bias‐corrected causal effect estimates. Our work contributes to the broader goal of improving the reliability and validity of observational studies in clinical and epidemiological research. Future research will build on these foundations, extending the methodology to more complex longitudinal causal structures.

Funding

This work was supported by the National Institutes of Health (Grant Nos. KL2TR001065, 8UL1TR000105) and the Data Sciences Institute at the University of Toronto (Grant No. DSI‐SFMY2R2P05).

Conflicts of Interest

The authors declare no conflicts of interest.

Supporting information

Data S1: sim70481‐sup‐0001‐Supinfo.pdf.

SIM-45-0-s001.pdf (177.9KB, pdf)

Acknowledgments

Dr. Liu is supported by the University of Toronto Data Sciences Institute Seed Funding for Methodologists (DSI‐SFMY2R2P05). This research was enabled in part by computing support provided by the Digital Research Alliance of Canada (alliancecan.ca). The reported PSC analysis and data were supported by PSC Partners Seeking A Cure, the Primary Children's Hospital Foundation, and the National Center for Advancing Translational Sciences of the National Institutes of Health under Award Numbers KL2TR001065 and 8UL1TR000105 (formerly UL1RR025764). The content is solely the responsibility of the authors and does not necessarily represent the official views of the National Institutes of Health.

Appendix A. Identifiability With Unmeasured Confounding

EYi(a)=xi1ui1EYi(a)|xi1,ui1Pui1|xi1Pxi1dui1dxi1=xi1ui1EYi(a)|Ai1=ai1,xi1,ui1Pui1|xi1Pxi1dui1dxi1=xi1xi2ui1ui2EYi(a)|Ai1=ai1,xi1,ui1,xi2,ui2,θPui2|Ai1=ai1,ui1,xi2,xi1×Pxi2|Ai1=ai1,ui1,xi1Pui1|xi1Pxi1dui2dui1dxi2dxi1=xiJxi1uiJui1EYi(a)|Aij=aij,Xi,UiPUij|Uij1,Xij,Aij1=aij1×PXij|Uij1,Xij1,Aij1=aij1PUi1|Xi1PXi1dui1duiJdxi1dxiJ=xiJxi1uiJui1EYi(a)|xi,ui,Aij=aijj=2JPUij|uij1,xij,Aij1=aij1×PXij|uij1,xij1,Aij1=aij1PUi1|xi1PXi1dui1duiJdxi1dxiJ (A1)

where P(Xij|·) denotes the distribution of visit‐specific covariates Xij and P(Uij|·) denotes the distribution of visit‐specific unmeasured confounding Uij.

Appendix B. Posterior Distribution of the Bayesian Sensitivity Analysis

f(Λ|O)=j=1Ji=1nui1=01uiJ=01PYi|Ai,Xi,Ui,βf(β)βi=1nui1=01uiJ=01PYi|Ai,Xi,Ui,βf(β)dβ×i=1nui1=01uiJ=01PAij|Aij1,Xij,Uij,αf(α)αj=1Ji=1nui1=01uiJ=01PAij|Aij1,Xij,Uij,αf(α)dα×i=1nui1=01uiJ=01PUij|Uij1,Aij1,Xij,τf(τ)τj=1Ji=1nui1=01uiJ=01PUij|Uij1,Aij1,Xij,τf(τ)dτ×i=1nui1=01uiJ=01PXij|Xij1,Aij1,Uij1,γf(γ)γj=1Ji=1nui1=01uiJ=01PXij|Xij1,Aij1,Uij1,γf(γ)dγ=f(β|O)f(α|O)f(γ|O)f(τ|O) (B1)

Appendix C. Sensitivity Function Derivation

With the sensitivity function defined as

cj,aJ,xJ=EY(a)|Aj=aj,xjEY(a)|Aj=1aj,Aj1=aj1,xj (C1)

where aJ and xJ are the observed treatment history and measured confounder history for visits = {1,,J}.

E[Y(a)]=x1A1EY(a)|A1,x1PA1|x1Px1dx1=x1EY(a)|A1=a1,x1Pa1|x1Px1+EY(a)|A1=1a1,x1P1a1|x1Px1dx1=x2x1A2A1EY(a)|A2,x2PA2|A1,x2Px2|A1,x1PA1|x1Px1dx1dx2=x2x1EY(a)|A2=a2,x2PA2=a2|A1=a1,x2Px2|A1=a1,x1PA1=a1|x1Px1dx1dx2=xJx1AJA1EY(a)|AJ,xJPAJ|AJ1,xJ1PxJ1|AJ1,xJ2PA1|x1Px1dx1dxJ=EY|AJ=aJxJx1j=1Jcj,aJ,xJP1aj|aj1,xjPxj|xj1,aj1Px1dx1dxJ (C2)

We can use YiSF to remove the confounding bias following Equation (C2), where

YSF=Yj=1Jc(j,AJ,XJ)P(1aj|Aj1,Xj) (C3)

The estimation of the average potential outcome based on the adjusted outcome YSF removes the bias from (C2)

EY|AJ=aJxJx1j=1Jcj,aJ,xJP1aj|aj1,xjPxj|xj1,aj1Px1dx1dxJ=xJx1EY|AJ=aJ,XJ=xJj=1Jcj,aJ,xJP1aj|aj1,xjPxJ|xJ1,aJ1Px1dx1dxJ=xJx1EYj=1Jcj,aJ,xJP1aj|aj1,xj|AJ=aJ,XJ=xJPxJ|xJ1,aJ1Px1dx1dxJ=xJx1EYSF|AJ=aJ,XJ=xJPxJ|xJ1,aJ1Px1dx1dxJ (C4)

If the sensitivity function for any distinct pair of treatment sequences is zero then the APO formulation (C2) is simplified to the conventional g‐formula with no unmeasured confounding. We can write out the causal effect on any pairwise average treatment effect as,

ATE=EYaJEYaJ=EY|aJxJx1j=1Jcj,aJ,xJP1aj|aj1,xjPxj|xj1,aj1Px1dx1dxJEY|aJxJx1j=1Jcj,aJ,xJP1aj|aj1,xjPxj|xj1,aj1Px1dx1dxJ=EY|aJEY|aJxJx1j=1Jcj,aJ,xJP1aj|aj1,xjPxj|xj1,aj1Px1+j=1Jcj,aJ,xJP1aj|aj1,xjPxj|xj1,aj1Px1dx1dxJ (C5)

Data Availability Statement

Access to data from the Pediatric PSC Consortium may be available upon request to the registry sponsor.

References

  • 1. Liu K., Tomlinson G., Reed A. M., et al., “Pilot Study of the Juvenile Dermatomyositis Consensus Treatment Plans: A CARRA Registry Study,” Journal of Rheumatology 48, no. 1 (2021): 114–122. [DOI] [PubMed] [Google Scholar]
  • 2. Blair A., Warsame K., Naik H., Byrne W., Parnia A., and Siddiqi A., “Identifying Gaps in COVID‐19 Health Equity Data Reporting in Canada Using a Scorecard Approach,” Canadian Journal of Public Health 112 (2021): 352–362. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 3. Rubin D. B., “Randomization Analysis of Experimental Data: The Fisher Randomization Test Comment,” Journal of the American Statistical Association 75, no. 371 (1980): 591–593. [Google Scholar]
  • 4. Von Elm E., “STROBE Initiative. The Strengthening the Reporting of Observational Studies in Epidemiology (STROBE) Statement: Guidelines for Reporting Observational Studies,” Annals of Internal Medicine 147 (2007): 573–577. [DOI] [PubMed] [Google Scholar]
  • 5. Greenland S., “Multiple‐Bias Modelling for Analysis of Observational Data,” Journal of the Royal Statistical Society: Series A (Statistics in Society) 168, no. 2 (2005): 267–306. [Google Scholar]
  • 6. Brumback B. A., Hernán M. A., Haneuse S. J., and Robins J. M., “Sensitivity Analyses for Unmeasured Confounding Assuming a Marginal Structural Model for Repeated Measures,” Statistics in Medicine 23, no. 5 (2004): 749–767. [DOI] [PubMed] [Google Scholar]
  • 7. Rosenbaum P. R. and Rubin D. B., “Assessing Sensitivity to an Unobserved Binary Covariate in an Observational Study With Binary Outcome,” Journal of the Royal Statistical Society. Series B, Statistical Methodology 45, no. 2 (1983): 212–218, 10.1111/j.2517-6161.1983.tb01242.x. [DOI] [Google Scholar]
  • 8. Phillips C. V., “Quantifying and Reporting Uncertainty From Systematic Errors,” Epidemiology 14, no. 4 (2003): 459–466. [DOI] [PubMed] [Google Scholar]
  • 9. Steenland K. and Greenland S., “Monte Carlo Sensitivity Analysis and Bayesian Analysis of Smoking as an Unmeasured Confounder in a Study of Silica and Lung Cancer,” American Journal of Epidemiology 160, no. 4 (2004): 384–392. [DOI] [PubMed] [Google Scholar]
  • 10. McCandless L. C., Gustafson P., and Levy A. R., “A Sensitivity Analysis Using Information About Measured Confounders Yielded Improved Uncertainty Assessments for Unmeasured Confounding,” Journal of Clinical Epidemiology 61, no. 3 (2008): 247–255, 10.1016/j.jclinepi.2007.05.006. [DOI] [PubMed] [Google Scholar]
  • 11. McCandless L. C. and Gustafson P., “A Comparison of Bayesian and Monte Carlo Sensitivity Analysis for Unmeasured Confounding,” Statistics in Medicine 36, no. 18 (2017): 2887–2901, 10.1002/sim.7298. [DOI] [PubMed] [Google Scholar]
  • 12. McCandless L. C. and Somers J. M., “Bayesian Sensitivity Analysis for Unmeasured Confounding in Causal Mediation Analysis,” Statistical Methods in Medical Research 28, no. 2 (2019): 515–531, 10.1177/0962280217729844. [DOI] [PubMed] [Google Scholar]
  • 13. Rose E. J., Moodie E. E., and Shortreed S. M., “Monte Carlo Sensitivity Analysis for Unmeasured Confounding in Dynamic Treatment Regimes,” Biometrical Journal 65, no. 5 (2023): 2100359. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 14. Franks A. M., D'Amour A., and Feller A., “Flexible Sensitivity Analysis for Observational Studies Without Observable Implications,” Journal of the American Statistical Association 115, no. 532 (2020): 1730–1746, 10.1080/01621459.2019.1604369. [DOI] [Google Scholar]
  • 15. Zhang B. and Tchetgen Tchetgen E. J., “A Semi‐Parametric Approach to Model‐Based Sensitivity Analysis in Observational Studies,” Journal of the Royal Statistical Society: Series A (Statistics in Society) 185, no. Supplement_2 (2022): S668–S691, 10.1111/RSSA.12946. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 16. Dorie V., Harada M., Carnegie N. B., and Hill J., “A Flexible, Interpretable Framework for Assessing Sensitivity to Unmeasured Confounding,” Statistics in Medicine 35, no. 20 (2016): 3453–3470, 10.1002/sim.6973. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 17. Li L., Shen C., Wu A. C., and Li X., “Propensity Score‐Based Sensitivity Analysis Method for Uncontrolled Confounding,” American Journal of Epidemiology 174, no. 3 (2011): 345–353, 10.1093/aje/kwr096. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 18. Shardell M. and Ferrucci L., “Joint Mixed‐Effects Models for Causal Inference With Longitudinal Data,” Statistics in Medicine 37, no. 5 (2018): 829–846, 10.1002/SIM.7567. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 19. Hu L., Zou J., Gu C., Ji J., Lopez M., and Kale M., “A Flexible Sensitivity Analysis Approach for Unmeasured Confounding With Multiple Treatments and a Binary Outcome With Application to SEER‐Medicare Lung Cancer Data,” Annals of Applied Statistics 16, no. 2 (2022): 1014. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 20. Cheng C., Hu L., and Li F., “Doubly Robust Estimation and Sensitivity Analysis for Marginal Structural Quantile Models,” Biometrics 80, no. 2 (2024): ujae045. [DOI] [PubMed] [Google Scholar]
  • 21. Keil A. P., Daza E. J., Engel S. M., Buckley J. P., and Edwards J. K., “A Bayesian Approach to the g‐Formula,” Statistical Methods in Medical Research 27, no. 10 (2018): 3183–3204. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 22. Saarela O., Stephens D. A., Moodie E. E., and Klein M. B., “On Bayesian Estimation of Marginal Structural Models,” Biometrics 71, no. 2 (2015): 279–288. [DOI] [PubMed] [Google Scholar]
  • 23. Liu K., Saarela O., Feldman B. M., and Pullenayegum E., “Estimation of Causal Effects With Repeatedly Measured Outcomes in a Bayesian Framework,” Statistical Methods in Medical Research 29, no. 9 (2020): 2507–2519. [DOI] [PubMed] [Google Scholar]
  • 24. Rubin D. B., “Bayesian Inference for Causal Effects: The Role of Randomization,” Annals of Statistics 6, no. 1 (1978): 34–58, 10.1214/aos/1176344064. [DOI] [Google Scholar]
  • 25. 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 7, no. 9–12 (1986): 1393–1512. [Google Scholar]
  • 26. Robins J. M., “Marginal Structural Models Versus Structural Nested Models as Tools for Causal Inference,” in Statistical Models in Epidemiology, the Environment, and Clinical Trials (Springer, 2000), 95–133. [Google Scholar]
  • 27. Van Der Laan M. J. and Rubin D., “Targeted Maximum Likelihood Learning,” International Journal of Biostatistics 2, no. 1 (2006): 1–38. [Google Scholar]
  • 28. Greenland S., “The Impact of Prior Distributions for Uncontrolled Confounding and Response Bias: A Case Study of the Relation of Wire Codes and Magnetic Fields to Childhood Leukemia,” Journal of the American Statistical Association 98, no. 461 (2003): 47–54, 10.1198/01621450338861905. [DOI] [Google Scholar]
  • 29. Gelman A., Jakulin A., Pittau M. G., and Su Y. S., “A Weakly Informative Default Prior Distribution for Logistic and Other Regression Models,” Annals of Applied Statistics 2, no. 4 (2008): 1360–1383, 10.1214/08-aoas191. [DOI] [Google Scholar]
  • 30. Ghosh J., Li Y., and Mitra R., “On the Use of Cauchy Prior Distributions for Bayesian Logistic Regression,” Bayesian Analysis 13, no. 2 (2018): 359–383, 10.1214/17-ba1051. [DOI] [Google Scholar]
  • 31. Gustafson P., “Bayesian Inference for Partially Identified Models,” International Journal of Biostatistics 6, no. 2 (2010): 1–20. [DOI] [PubMed] [Google Scholar]
  • 32. Gustafson P., Bayesian Inference for Partially Identified Models: Exploring the Limits of Limited Data (CRC Press, 2015). [DOI] [PubMed] [Google Scholar]
  • 33. Oganisian A., Untangling Sample and Population Level Estimands in Bayesian Causal Inference (2025). arXiv preprint arXiv:2508.15016.
  • 34. Hogan J. W., Daniels M. J., and Hu L., “A Bayesian Perspective on Assessing Sensitivity to Assumptions About Unobserved Data,” in Handbook of Missing Data Methodology (CRC Press, 2014), 405–434. [Google Scholar]
  • 35. Newton M. A. and Raftery A. E., “Approximate Bayesian Inference With the Weighted Likelihood Bootstrap,” Journal of the Royal Statistical Society. Series B, Statistical Methodology 56, no. 1 (1994): 3–26. [Google Scholar]
  • 36. Luo Y., Stephens D. A., Graham D. J., and McCoy E. J., “Assessing the Validity of Bayesian Inference Using Loss Functions,” (2021). arXiv preprint arXiv:2103.04086.
  • 37. Chapman R. W., Arborgh B., Rhodes J., et al., “Primary Sclerosing Cholangitis: A Review of Its Clinical Features, Cholangiography, and Hepatic Histology,” Gut 21, no. 10 (1980): 870–877. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 38. LaRusso N. F., Wiesner R. H., Ludwig J., and MacCarty R. L., “Current Concepts. Primary Sclerosing Cholangitis,” New England Journal of Medicine 310, no. 14 (1984): 899–903. [DOI] [PubMed] [Google Scholar]
  • 39. Deneau M. R., Mack C., Mogul D., et al., “Oral Vancomycin, Ursodeoxycholic Acid, or no Therapy for Pediatric Primary Sclerosing Cholangitis: A Matched Analysis,” Hepatology 73, no. 3 (2021): 1061–1073. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 40. Ricciuto A., Liu K., El‐Matary W., et al., “Oral Vancomycin Is Associated With Improved Inflammatory Bowel Disease Clinical Outcomes in Primary Sclerosing Cholangitis‐Associated Inflammatory Bowel Disease (PSC‐IBD): A Matched Analysis From the Paediatric PSC Consortium,” Alimentary Pharmacology & Therapeutics 59, no. 10 (2024): 1236–1247. [DOI] [PubMed] [Google Scholar]
  • 41. Deneau M. R., El‐Matary W., Valentino P. L., et al., “The Natural History of Primary Sclerosing Cholangitis in 781 Children: A Multicenter, International Collaboration,” Hepatology 66, no. 2 (2017): 518–527. [DOI] [PubMed] [Google Scholar]
  • 42. Greifer N., WeightIt: Weighting for Covariate Balance in Observational Studies (2025). R package version 1.5.1.
  • 43. Liu K., Yan X., and Urner M., Bayesmsm: Fitting Bayesian Marginal Structural Models for Longitudinal Observational Data (2025). R package version 1.0.0.
  • 44. Geweke J., Evaluating the Accuracy of Sampling‐Based Approaches to the Calculation of Posterior Moments. Technical Report (Federal Reserve Bank of Minneapolis, 1991). [Google Scholar]
  • 45. Plummer P., Morris M. E., and Dunai J., “Assessment of Unilateral Neglect,” Physical Therapy 83, no. 8 (2003): 732–740. [PubMed] [Google Scholar]
  • 46. Stephens D. A., Nobre W. S., Moodie E. E., and Schmidt A. M., “Causal Inference Under Mis‐Specification: Adjustment Based on the Propensity Score (With Discussion),” Bayesian Analysis 18, no. 2 (2023): 639–694. [Google Scholar]
  • 47. Luo Y., Liu K., Singh R., and Graham D. J., “A Longitudinal Bayesian Framework for Estimating Causal Dose‐Response Relationships,” arXiv preprint arXiv:2505.20893, (2025).

Associated Data

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

Supplementary Materials

Data S1: sim70481‐sup‐0001‐Supinfo.pdf.

SIM-45-0-s001.pdf (177.9KB, pdf)

Data Availability Statement

Access to data from the Pediatric PSC Consortium may be available upon request to the registry sponsor.


Articles from Statistics in Medicine are provided here courtesy of Wiley

RESOURCES