https://doi.org/10.5281/zenodo.20677995
search.json
[
{
"objectID": "index.html",
"href": "index.html",
"title": "Computational Causal Inference for Applied Researchers",
"section": "",
"text": "Preface\nA question often asked by anyone is “what would have happened if we had done this instead?” The answer is impossible to know for certain, but there are mathematical methods that allow us to estimate this answer. These methods are called causal inference. This book introduces the concepts of causal inference from a beginner’s perspective and leads the interested reader to numerous approaches to answer these impossible questions.\nThe purpose of many health studies is to estimate the effect of an exposure on an outcome. It is not always ethical to assign an exposure to individuals in randomised controlled trials; instead, observational data and appropriate study design must be used. There are major challenges with observational studies, one of which is confounding that can lead to biased estimates of the causal effects. Controlling for confounding is commonly performed by simple adjustment for measured confounders; although, often this is not enough. Recent advances in the field of causal inference have dealt with confounding by building on classical standardisation methods. However, these recent advances have progressed quickly with a relative paucity of computational-oriented applied tutorials, contributing to some confusion in the use of these methods among applied researchers.\nIn this book, we show the computational implementation of different causal inference estimators from a historical perspective, where different estimators were developed to overcome the limitations of the previous ones. We introduce the potential outcomes framework, illustrate the use of different methods using examples from health care settings, and most importantly, we provide reproducible and commented code in R and Stata for researchers to apply in their own observational studies.\nThe code can be accessed at github.com/migariane/TutorialCausalInferenceEstimators.",
"crumbs": [
"Preface"
]
},
{
"objectID": "index.html#who-this-book-is-for",
"href": "index.html#who-this-book-is-for",
"title": "Computational Causal Inference for Applied Researchers",
"section": "Who this book is for",
"text": "Who this book is for\nThis book is targeted towards epidemiologists, statisticians, psychologists, economists, sociologists, political scientists, and computer scientists — anyone interested in learning and applying causal inference methods to real-world data.",
"crumbs": [
"Preface"
]
},
{
"objectID": "index.html#author-biographies",
"href": "index.html#author-biographies",
"title": "Computational Causal Inference for Applied Researchers",
"section": "Author Biographies",
"text": "Author Biographies\nDr Miguel Angel Luque-Fernandez is an Associate Professor of Biostatistics in the Department of Statistics and Operations Research at the University of Granada (UGR), Spain, and an Honorary Associate Professor at the London School of Hygiene and Tropical Medicine (LSHTM). He holds a PhD in Epidemiology and Public Health (UGR/ULB), an MSc in Biostatistics (Newcastle), an MSc in Epidemiology (ULB), and a BSc in Mathematics and Statistics (Open University). His research focuses on causal inference methods, comparative effectiveness research, and computational epidemiology.\nDr Matthew J. Smith is a researcher at the London School of Hygiene and Tropical Medicine, specialising in causal inference methods and their application to population health research.",
"crumbs": [
"Preface"
]
},
{
"objectID": "chapters/chapter1/index.html",
"href": "chapters/chapter1/index.html",
"title": "1 Introduction",
"section": "",
"text": "1.1 Causal inference\nThe first chapter provides a brief introduction to causal inference and its links to public health, economics, and society.\nCausal inference is the process of determining whether a variable causes a change in another variable. It involves identifying causal relationships between variables based on data and statistical analysis. Causal inference is important because it allows us to understand how the world works and make informed decisions based on that understanding. For example, in medicine, we use causal inference to determine whether a particular treatment is effective and to identify potential side effects. In public policy, we use causal inference to assess the impact of interventions on social outcomes, such as crime rates, educational attainment, and economic growth.\nHowever, determining causality is not always straightforward. Correlation between two variables does not necessarily imply causation, and there may be other factors, known as confounding variables, that are responsible for the observed relationship. Causal inference methods attempt to control for confounding variables and identify the true causal relationship between variables.\nTo make causal inferences, we need to go beyond mere associations between variables and determine whether a change in one variable actually causes a change in the other variable. This involves controlling for confounding factors and using methods such as randomized controlled trials (RCT), natural experiments, and observational studies to isolate the causal effect. For example, suppose we are interested in determining whether a new drug is effective in reducing blood pressure. A randomized controlled trial might be conducted, where a group of patients are randomly assigned to receive either the new drug or a placebo. By controlling for other factors that could affect blood pressure, such as diet and exercise, and randomly assigning patients to groups, we can attribute any differences in blood pressure between the two groups to the drug and infer a causal relationship. In an RCT, participants are randomly assigned to either a treatment group (where they receive the intervention being studied) or a control group (where they do not receive the intervention). This random assignment helps to balance out potential confounding factors between the two groups, making it more likely that any observed differences between the groups are due to the treatment.\nIn observational studies, this randomisation process is often not possible because it might be unethical or unfeasible to allocate individuals to certain treatments (or exposures, policies, etc.) i.e., smoking. Since, in observational studies, individuals cannot be randomly assigned to a treatment group, statistical methods are required to control for confounding and to infer causal effects.\nCausal inference is important for applied researchers because it allows them to make informed decisions and draw meaningful conclusions about the world. By understanding the true causal relationships between variables, applied researchers can develop effective interventions, evaluate the impact of policies and treatments, and gain a deeper understanding of how different factors interact to produce outcomes. For example, consider a public health researcher who is interested in understanding the relationship between air pollution and respiratory illness. Without causal inference, the researcher might observe a correlation between higher levels of air pollution and higher rates of respiratory illness, but would not be able to determine whether air pollution actually causes respiratory illness. By using causal inference methods the researcher can attempt to control for confounding factors and isolate the causal effect of air pollution on respiratory illness. This information can be used to develop targeted interventions to reduce air pollution and improve public health outcomes.\nCausal inference is also important for evaluating the effectiveness of medicine, policies, economics, societal changes, and other contexts. By understanding the true causal relationships between variables, researchers can determine whether a particular policy is effective, and identify factors that may be limiting its effectiveness. This information can be used to make more informed decisions about resource allocation and program design.\nOverall, causal inference is an essential tool for applied researchers in a wide range of fields, from public health to economics to education. By understanding the true causal relationships between variables, researchers can make more informed decisions and develop more effective interventions, leading to improved outcomes for individuals and communities.",
"crumbs": [
"Foundations",
"<span class='chapter-number'>1</span> <span class='chapter-title'>Introduction</span>"
]
},
{
"objectID": "chapters/chapter1/index.html#causal-inference-roadmap",
"href": "chapters/chapter1/index.html#causal-inference-roadmap",
"title": "1 Introduction",
"section": "1.2 Causal inference roadmap",
"text": "1.2 Causal inference roadmap\nConstructing a causal analysis in a structured manner is necessary to obtain unbiased effect estimates and robust conclusions for real-world evidence. The Causal Roadmap (Figure 1.1) offers a framework that can be adapted to the vast majority of studies to generate real-world evidence. The Causal Roadmap begins with defining the causal question of interest, stating whether the data and assumptions can be used to answer the question of interest, performing suitable statistical analyses, and assessing whether alternative conclusions could be obtained under alternate assumptions. The rest of this section describes each step in more detail.\n\n\n\n\n\n\nFigure 1.1: Causal Inference Roadmap as detailed in (Dang et al., 2023).\n\n\n\nStep 1: Causal question, model, and estimand\nFirst, a causal question is defined. The question encapsulates the population of interest (eligibility criteria), the treatment (or exposure), the follow-up period (time from starting-point to end-point), the outcome of interest, and the causal estimand. The causal estimand is a description of the statistical estimate that answers the question (e.g., causal risk difference, causal relative risk, causal odds ratio).\nThe causal model is a graphical tool that helps to identify the causal pathways between the exposure and the outcome. The causal model is commonly shown using a directed acyclic graph (DAG): detailed explanation of causal models is in Section 1.3. Briefly, a diagram for the causal model shows what we know and, importantly, what we do not know about how the data is generated in the real world. The diagram is created using background knowledge, advice from experts, and assumptions about other possible variables.\nIt is important at this stage to go back to the causal question, we must critique whether the causal model is able to answer the causal question. The causal model could have identified a variable that has been overlooked and, if so, the causal question needs to be adapted: we call this process “redefining the causal question”.\nStep 2: Consider the observed data\nThe causal model from Step 1 illustrates our knowledge of how the exposure causes the outcome and provides the necessary information that we need to answer the causal question. The observed data, on the other hand, can differ from the causal model. The difference can occur in the way the observed data was measured. For example, research has shown that obesity is strongly associated with cardiovascular disease. One way to measure obesity is by using body mass index (i.e., \\(weight(kg)/height (m^{2})\\)). However, body mass index (BMI) cannot distinguish between body fat and muscle mass, thus the BMI will be overestimated amongst people with lots of muscle mass and will be underestimated amongst people with very little muscle mass. Alternatively, obesity might be a variable that confounds the association between treatment and risk of mortality, but if obesity is not measured (thus not recorded in the data), we are unable to adjust for obesity. In such cases, we must go back to Step 1 to redefine the question of interest.\nStep 3: Identifiability assumptions\nIf the observed data is sufficient to answer the causal question, we must first make certain assumptions. The main assumptions. also known as (AKA) as identifiability assumptions, are conditional exchangeability, consistency, no interference, and positivity. Identifiability in causal inference refers to the fact that the main assumptions are necessary before one can infer a causal effect, they are discussed in more detail in Section 1.5. The identifiability assumptions provide a way of writing the causal question (a hypothetical two-world causal contrast in terms of potential outcomes see 1.4) in terms of a model for the observed data.\nStep 4: Define the statistical estimand\nIf the identifiability assumptions are deemed plausible, we can move on to defining the statistical estimand. The statistical estimand is an algebraic definition of the causal question but in terms of the observed data. For example, the average treatment effect (ATE) measured by the risk difference is given by\n\\[ ATE \\quad = \\quad E_{w} (P[Y=1 \\mid A=1, \\textbf{W}] - P[Y=1 \\mid A=0, \\textbf{W}]) \\]\nand is the expected difference (causal risk difference) in the outcome (Y) between two exposure groups (A) conditioned on the set of variables that confound the exposure-outcome relationship (W). More details on estimands and measures of association are given in Section 1.6.\nStep 5: Statistical model and estimator\nThe statistical model defines the set of possible data distributions between the outcome, exposure, and covariates. We must consider the functional form of the variables and their relationships to one another (e.g., non-linear terms, time-varying effects, interactions [effect modification], etc.). With the rise in quality and availability of machine-learning methods, the statistical model is at less risk of misspecification: a common source of bias.\nOnce the statistical model has been defined, the next step is to choose the estimator. In large part, this book focuses on the various statistical estimators that can be used, along with the suitability to certain data. The choice of the statistical estimator is determined by the performance of the estimator in terms of bias, 95% confidence interval (CI) coverage, type I error rate, and precision.\nStep 6: Sensitivity analysis\nOnce the statistical estimator provides a quantitative value for our causal question, we must go back to the identifiability assumptions and ask how our result would change if the assumptions were violated. For example, if we were not able to measure a potentially important variable, then our result is potentially biased. We would need to assess whether the unmeasured variable is a strong confounder of the relationship between the treatment and the outcome. This topic of sensitivity analysis is revisited in Chapter 8.\nStep 7: Alternative study designs\nWe might often find that multiple study designs are feasible to answer the causal question. The researcher will then need to consider which study design is feasible, and ethical, whether results will be obtained in time for a policy-related decision, and other statistical properties (e.g., power, correct type I and II error rates, bias, coverage, precision, etc.). We do not go into alternative study designs in this book, we refer the interested reader to (Dang et al., 2023) for more details.",
"crumbs": [
"Foundations",
"<span class='chapter-number'>1</span> <span class='chapter-title'>Introduction</span>"
]
},
{
"objectID": "chapters/chapter1/index.html#sec-causalDAGs",
"href": "chapters/chapter1/index.html#sec-causalDAGs",
"title": "1 Introduction",
"section": "1.3 Causal diagrams",
"text": "1.3 Causal diagrams\nIntroduce causal diagrams, which are graphical representations of causal relationships. Explain how they can be used to identify confounding variables and to determine which variables should be controlled for in an analysis.\n\n1.3.1 Directed Acyclic Graphs\nThe distribution of the observed data can be shown as a graphical representation (Figure 1.2): these diagrams are known as direct acyclic graphs (DAG). When constructing DAGs, subject-matter knowledge must be used to ensure the conditional exchangeability assumption holds.\n\n\n\n\n\n\nFigure 1.2: Sufficient set of variables to control for confounding. Y: outcome, A: treatment, W: confounders.\n\n\n\nThis causal diagram makes several assumptions: all variables that confound the exposure-outcome relationship are included in W, there are no intermediate variables, and there is no residual confounding. Therefore, the set of covariates included in W suffices to assume the conditional mean independence to estimate the ATE. To more formally illustrate DAGs, we first define some terminology along with examples using the DAG in ?fig-DAG1.\n\nPath: A path is any series of nodes from \\(W_{k}\\) to \\(W_{l}\\) connected by an edge in any direction (i.e., the edge can be “\\(\\rightarrow\\)” or “\\(\\leftarrow\\)”). For example, \\(W_{3} \\rightarrow W_{4} \\leftarrow W_{2} \\rightarrow A \\leftarrow W_{5}\\) is one of the paths from \\(W_{3}\\) to \\(W_{5}\\).\nDirect path: A direct path is a path between nodes that involves only forward edges. For example, \\(W_{3} \\rightarrow W_{4} \\rightarrow W_{1} \\rightarrow A \\rightarrow Y\\), is a direct path between \\(W_{3}\\) and \\(Y\\) since it contains only forwards edges (i.e., “\\(\\rightarrow\\)”).\nParent and child: \\(W_{k}\\) is a parent of \\(W_{l}\\), and \\(W_{l}\\) is a child of \\(W_{k}\\), if \\(W_{k} \\rightarrow W_{l}\\). In ?fig-DAG1, \\(W_{3}\\) is a parent of \\(W_{4}\\), and \\(W_{4}\\) is a child of \\(W_{3}\\).\nAncestor and Descendant: \\(W_{k}\\) is an ancestor of \\(W_{l}\\), and \\(W_{l}\\) is a descendant of \\(W_{k}\\), if there is a direct path from \\(W_{k}\\) to \\(W_{l}\\). In ?fig-DAG1, \\(W_{3}\\) is an ancestor of \\(W_{1}\\), thus \\(W_{1}\\) is a descendant of \\(W_{3}\\).\nCollider: A node \\(W_{k}\\) is a collider between \\(W_{k-1}\\) and \\(W_{l}\\) if it receives both edges (i.e., \\(W_{k-1} \\rightarrow W_{k} \\leftarrow W_{l}\\)). For example, \\(W_{4}\\) is a collider along the path \\(W_{3} \\rightarrow W_{4} \\leftarrow W_{2}\\).\nInstrumental variable: A node is an instrumental variable if it satisfies these assumptions:\n\nThe node is correlated with \\(A\\),\nthe node is not correlated with \\(Y\\), and\nthe node is not correlated with a confounder that affects \\(Y\\). In ?fig-DAG1, \\(W_{5}\\) is an instrumental variable since it satisfies all three assumptions.\n\nConditional instrumental variable: A node is a conditional instrumental variable if it satisfies 6(a) and 6(b), conditioning on nodes that are confounders of \\(A \\rightarrow Y\\). In ?fig-DAG1, \\(W_{4}\\) is an instrumental variable conditional on \\(W_{1}\\), \\(W_{2}\\) and \\(W_{3}\\).\n\nIn ?fig-DAG1, one would need to condition on \\(W_{1}\\), \\(W_{2}\\), and \\(W_{3}\\) to sufficiently control for confounding. Without conditioning on these variables, the crude association between \\(A \\rightarrow Y\\) is biased (i.e., different from the true causal effect).\nA collider for a certain pair of variables (e.g., outcome and exposure) is a third variable that is caused by both of them. In DAG terminology, a collider is the variable in the middle of an inverted fork (i.e. variable C in A → C ← Y).(Pearl, 2009; Pearl & Robins, 1995) Using regression to control for a collider, or stratifying the analysis concerning a collider, can introduce a spurious association between its causes, which can potentially introduce non-causal associations between the exposure and the outcome. This has been used to explain why the medical literature contains many paradoxical findings, where established risk factors appear protective for the outcome.(Brian W. Whitcomb, 2009; Hailey R. Banack, 2013; Miguel Angel Luque-Fernandez, 2016; S. Hernandez-Diaz, 2006) For instance, numerous studies have reported a paradoxical protective effect of maternal cigarette smoking during pregnancy on pre-eclampsia, which has been named the pre-eclampsia smoking paradox. This paradox is due to gestational age at delivery, which is a collider between smoking (exposure) and pre-eclampsia (outcome).(Miguel Angel Luque-Fernandez, 2016) However, the magnitude of the resulting bias will depend on the associations between the collider and the two parent variables.\nA note on backdoor paths\nTo ensure conditional exchangeability holds, variables along the path from \\(A\\) to \\(Y\\) must be conditioned on. This is known as Pearl’s backdoor criterion.(Judea, 1994) In ?fig-DAG1, conditioning on only \\(W_{1}\\), \\(W_{2}\\), and \\(W_{3}\\) was sufficient to control for confounding. There are no other paths through \\(W_{4}\\) (or \\(W_{5}\\)) that does not already control for \\(W_{1}\\), \\(W_{2}\\), or \\(W_{3}\\). In other words, if one wanted to navigate from \\(W_{4}\\) to \\(Y\\), one would have to go through either \\(W_{1}\\), \\(W_{2}\\), or \\(W_{3}\\), which are already controlled for.\n\n\n1.3.2 Impact of colliders\nTo illustrate the induced association of conditioning on a collider, three variables are defined A (unrelated to B), B (unrelated to A), and C (collider, a child of A and B). The association between these variables are shown in ?fig-DAG4. We now simulate some data for A, B and C and tabulate the data in Tables Table 1.1, Table 1.2, and Table 1.3.\nIn Table 1.1, there is an equal number of those with A=1 amongst levels of B. In the DAG above, A does not cause B, so the estimate of the causal effect (i.e., odds ratio) should be 1.00.\n\n\n\nTable 1.1\n\n\n\n\n\n\nB=1\nB=0\nTotal\n\n\n\n\nA=1\n20\n20\n40\n\n\nA=0\n80\n80\n160\n\n\nTotal\n100\n100\n200\n\n\n\n\n\n\nIn Table 1.2, those with C=1 are less likely to have A=1 (n=15) compared to those with C=0 (n=25). In the DAG above, A is associated with C, so the estimate of the causal effect (i.e., odds ratio) from Table 1.2 is 1.47.\n\n\n\nTable 1.2\n\n\n\n\n\n\nC=1\nC=0\nTotal\n\n\n\n\nA=1\n15\n25\n40\n\n\nA=0\n75\n85\n160\n\n\nTotal\n90\n110\n200\n\n\n\n\n\n\nIn Table 1.3, those with C=1 are much less likely to have B=1 (n=30) compared to those with C=0 (n=70). In the DAG above, B is associated with C, so the estimate of the causal effect (i.e., odds ratio) from Table 1.3 is 3.50.\n\n\n\nTable 1.3\n\n\n\n\n\n\nC=1\nC=0\nTotal\n\n\n\n\nB=1\n30\n70\n100\n\n\nB=0\n60\n40\n100\n\n\nTotal\n90\n110\n200\n\n\n\n\n\n\nA marginal association between A and B has an odds ratio of 1.00 Table 1.1. This is a marginal association because we do not condition on the collider. The marginal associations between A and C, and B and C, are also explored to assess whether conditioning on the collider could potentially bias the association between A and B. From the above, it is clear that the associations (odds ratios) between A and C (and B and C) are very different from 1.00. Suggesting that conditioning on the collider (C) will induce a bias. To illustrate this, we now condition on the collider. If the collider did not induce bias, we should expect an odds ratio of the association between A and B to be 1.00 for both values of C (i.e., where C is 0 or 1).\nConditional associations\nTable Table 1.4 shows the tabulation of the association between A and B within levels of C. The association between A and B, conditional on C = 1, has an odds ratio (OR) of:\n\\[ \\text{OR}_{C=1} = \\frac{(21/9)}{(54/6)} = 0.26 \\]\nThe association between A and B, conditional on C = 0, has an odds ratio of:\n\\[ \\text{OR}_{C=0} = \\frac{(59/11)}{(26/14)} = 2.89 \\]\n\n\n\nTable 1.4\n\n\n\n\n\n\nC=1: B=1\nC=1: B=0\nC=0: B=1\nC=0: B=0\nTotal\n\n\n\n\nA=1\n9\n6\n11\n14\n40\n\n\nA=0\n21\n54\n59\n26\n160\n\n\nTotal\n30\n60\n70\n40\n200\n\n\n\n\n\n\nThus, since each of the odds ratios for the association between A and B within levels of C do not equate to 1.00, conditioning on the collider will induce bias in the association between A and B. Conditioning on a descendent (or child) of a collider induces the same problem as conditioning on the collider itself. However, conditioning on an ancestor (or parent) of a collider does not induce bias. This is because the information about the collider that is contained in the ancestor is independent of A and B.",
"crumbs": [
"Foundations",
"<span class='chapter-number'>1</span> <span class='chapter-title'>Introduction</span>"
]
},
{
"objectID": "chapters/chapter1/index.html#sec-POframework",
"href": "chapters/chapter1/index.html#sec-POframework",
"title": "1 Introduction",
"section": "1.4 Counterfactual (potential outcomes) framework",
"text": "1.4 Counterfactual (potential outcomes) framework\nWe first introduce the language of the Potential Outcomes Framework also known as (a.k.a) Neyman-Rubin Potential Outcomes framework.(Rubin, 2007) To illustrate the framework we use an empirical example based on intensive care medicine.(Connors et al., 1996) The study, set in intensive care units of five United States teaching hospitals between 1989 and 1994, evaluated the effectiveness of right heart catheterisation (RHC) on short-term mortality (30 days) of 5,735 critically ill adult patients (2,184 received a RHC and 3,551 did not received it) receiving care for 1 of 9 prespecified disease categories. In this illustration, let Y, the outcome, denote the vital status of the patient in an intensive care unit (ICU) at 30 days after admission. Let A denote the exposure variable for whether or not the patient received RHC during their stay at the ICU. Let (W) include the set of confounders, with C denoting a binary confounder.\nIn this RHC study, each patient has two potentially observed outcomes (i.e., \\(Y^{a}\\)), where the first is \\(Y(1)\\) if they received RHC, and the second is \\(Y(0)\\) if they did not receive RHC (Rubin, 1974). We say “potentially observed” because only one of these two outcomes can ever be observed since each patient only receives one of the treatments. As an example from Table 1.5, Patient 1 has two potential outcomes: firstly, \\(Y(0) = 1\\) says that if this patient did not receive RHC then they would have died within 30 days, and secondly, \\(Y(1) = 0\\) says that if they had received RHC then they would not have died within 30 days. l,\n\n\n\nTable 1.5: Potential outcomes framework: C = Binary confounder, A = Binary treatment, Y = Binary outcome, Y(0) = Potential outcome for A=0, Y(1) = Potential outcome for A=1\n\n\n\n\n\nPatient\nY\nA\nC\n\\(Y(0)\\)\n\\(Y(1)\\)\n\n\n\n\n1\n1\n0\n0\n1\n0\n\n\n2\n1\n1\n1\n1\n1\n\n\n3\n1\n1\n1\n0\n1\n\n\n4\n0\n1\n0\n0\n0\n\n\n5\n1\n0\n1\n1\n1\n\n\n6\n0\n1\n1\n0\n0\n\n\n7\n1\n0\n0\n1\n1\n\n\n8\n0\n1\n1\n0\n0\n\n\n9\n1\n1\n0\n1\n1\n\n\n\n\n\n\nA common estimand in causal inference is the average treatment effect (ATE). The ATE is a function of the underlying distribution of the counterfactual outcomes, which can be estimated non-parametrically or parametrically.(J. Robins, 1986) The ATE is defined by an average of the difference of two random variables (i.e., the potential outcomes \\(Y^{1}\\) and \\(Y^{0}\\)). (Gutman & Rubin, 2015; Rubin, 2007) The ATE in the example above can be estimated as the contrast between the potential outcomes under different treatment levels (i.e., the difference between \\(E[Y^{1}] - E[Y^{0}]\\)).(Rubin, 2005)\nPotential outcomes are so named because they are outcomes that could potentially be observed had the patient been assigned \\(A=a\\). However, in observational studies, only one outcome is observed for each individual. To estimate causal effects, we must make certain assumptions to identify potential outcomes from the observed data, then estimate the estimand.(J. Robins, 1986) The necessary assumptions are outlined in the next section.",
"crumbs": [
"Foundations",
"<span class='chapter-number'>1</span> <span class='chapter-title'>Introduction</span>"
]
},
{
"objectID": "chapters/chapter1/index.html#sec-identifiabilityassumptions",
"href": "chapters/chapter1/index.html#sec-identifiabilityassumptions",
"title": "1 Introduction",
"section": "1.5 Identifiability assumptions",
"text": "1.5 Identifiability assumptions\nConditional exchangeability and identification\nThe first assumption is conditional exchangeability. In randomised studies, conditional (and marginal) exchangeability holds because the treated individuals, had they not been treated, would have had the same average potential outcomes as the untreated, and vice versa. This cannot be guaranteed in observational studies, but it can be assumed to hold if the unmeasured risk factors of the outcome are equally distributed between the treated and the untreated groups, conditional on the measured confounders. Thus, using the language of the potential outcomes, the conditional exchangeability assumption (a.k.a conditional independence, unconfoundedness or ignorability) is:\n\\[\nY^{a} \\amalg A\\mid \\textbf{W} \\; \\forall \\; a \\in \\{0, 1\\},\n\\]\nThis states that, conditional on the set of observed confounders W, the actual exposure level \\(A\\) is independent of each of the potential outcomes. Thus, the conditional mean independence is given \\(E[Y^{a} \\mid A=1, \\textbf{W}=w] = E[Y^{a} \\mid A=0, \\textbf{W}=w] = E[Y^{a} \\mid \\textbf{W}=w] \\; \\forall \\, a \\in{0,1}.\\)\nPositivity\nPositivity holds if the conditional probability of being treated or exposed (and similarly for being untreated) is greater than zero. Therefore, if P(W=w) > 0, then\n\\[\nP(A=a\\mid \\textbf{W}=w) > 0 \\; \\forall \\; \\textbf{W} \\in \\textbf{w}, a \\in \\{0, 1\\}.\n\\]\nWhen this assumption is violated, it is typically because the target population is poorly defined (i.e, attempting to estimate the effect of a treatment on people who would never receive it).\nCounterfactual consistency\nCounterfactual consistency holds if the observed outcome for all treated individuals equals their outcome had they been treated, and likewise for untreated individuals. For example, in Table 1.5, Patient 1’s observed outcome equals their potential outcome had they not been treated (\\(Y = Y^{a} = 1\\)), Patient 2’s observed outcome equals their potential outcome had they been treated (\\(Y = Y^{1} = 1\\)). The consistency assumption means that the definition of the treatment, and outcome, is consistent for each patient. Analytically, consistency is represented by:\n\\[\nY = A Y^{1} + (1-A)Y^{0},\n\\]\nNon-interference\nAside from exchangeability, positivity, and consistency, there are other notable assumptions. It is further assumed that there is no interference. This is commonly called Stable Unit Treatment Value Assumption (SUTVA). This assumption is closely related to the consistency assumption, in that non-interference (or SUTVA) states that there is only one version of the exposure and that a patient’s potential outcome is not influenced by the treatment of another patient.(Schomaker, 2020)",
"crumbs": [
"Foundations",
"<span class='chapter-number'>1</span> <span class='chapter-title'>Introduction</span>"
]
},
{
"objectID": "chapters/chapter1/index.html#sec-estimands",
"href": "chapters/chapter1/index.html#sec-estimands",
"title": "1 Introduction",
"section": "1.6 Estimands",
"text": "1.6 Estimands\nCommonly, an observational study aims to answer a scientific question that characterises the effect of an exposure or treatment on an outcome. This question is translated to an estimand for which an estimate will provide a relevant answer to the exposure-outcome relationship. Statistical methods are the tools used to obtain an estimate from the data. Within the causal framework, these statistical methods are called estimators. They are mathematical functions that use the observed values of the observations in the sample (i.e., a function of the random variables) and generate the quantitative value for the estimand. The estimators are represented by algebraic equations that explicitly describe a function of the realised observations.\nAn estimand is a quantity of interest in a causal analysis that represents the specific causal effect that a researcher aims to estimate. The average treatment effect (ATE) is an example of an estimand. The ATE is defined as the average difference in the outcome variable between a group of individuals who received a treatment and a group of individuals who did not receive the treatment. It represents the average causal effect of the treatment on an outcome of interest in a population.\nThe ATE is algebraically defined as\n\\[\n\\text{ATE} \\, = \\, E[Y = 1 \\mid A=1] - E[Y = 1 \\mid A=0].\n\\]\nThis is currently in terms of unobserved potential outcomes. For example, we can only observe what happens when an individual is treated or untreated, but not both. To estimate the ATE from our data, we can apply the identifiability assumptions (Section 1.5) and derive the ATE in terms of observable data. Note that \\(Y^{a}\\) is the potential outcome of an individual, with measured confounders \\(\\textbf{W}\\), had they received treatment \\(A=a\\)\nFirst, by the law of total probability\n\\[P[Y^{a}=1] \\, = \\, \\sum_{w} P[Y^{a}=1 \\,|\\, \\textbf{W}=w]\\,P(\\textbf{W}=w)\\]\nBy conditional exchangeability\n\\[P[Y^{a}=1] \\, = \\, \\sum_{w} P[Y^{a}=1 \\,|\\,A=a,\\textbf{W}=w]\\,P(\\textbf{W}=w)\\]\nThis is possible since we are assuming that within levels of \\(\\textbf{W}\\), the predictors of the outcome are equally distributed between the treated and non-treated groups. That is, we have achieved what would happen if patients were randomised to each treatment group. If we also assume consistency\n\\[P[Y^{a}=1] \\, = \\, \\sum_{w} P[Y=1 \\,|\\,A=a,\\textbf{W}=w]\\,P(W=w)\\]\nThus, under these assumptions, the statistical estimand for the ATE is defined as\n\\[\n\\sum_{w} P[Y=1 \\,|\\,A=1,\\textbf{W}=w]\\,Pr(W=w) \\,-\\, \\sum_{w} P[Y=1 \\,|\\,A=0,\\textbf{W}=w]\\,P(\\textbf{W}=w).\n\\]\nMany estimands could be estimated. One common alternative to the ATE is the average treatment effect among the treated (ATT):\n\\[\n\\text{ATT}\\,=\\,E[Y^{1} \\mid A=1] - E[Y^{0} \\mid A=1]\n\\]\nApplying the assumptions above, the statistical estimand for the ATT is\n\\[\n\\sum_{w} P[Y=1 \\,|\\,A=1,\\textbf{W}=w]\\,P(\\textbf{W}=w \\mid A=1) \\,-\\, \\sum_{w} P[Y=1 \\,|\\,A=0,\\textbf{W}=w]\\,P(\\textbf{W}=w \\mid A=1).\n\\]\nIn the above, for both the ATE and ATT, we have transitioned from a setting where we have unobserved potential outcomes to a setting where we can estimate our causal estimand using the distribution of the observed data (J. M. Robins, 1999). Conditional exchangeability requires all confounders to be measured and accounted for in the analysis.\nThere are many different types of estimands that can be used in causal inference, and the choice of estimand depends on the research question and study design. There are many other estimands used for causal analysis. The conditional average treatment effect (CATE) represents the causal effect of a treatment on the outcome for specific subgroups of individuals, rather than the average effect over the entire population. Average causal effect of the untreated (ACEU) represents the average causal effect of not receiving the treatment on the outcome.\n\n1.6.1 Choice of causal estimand\nHow does one choose a suitable causal estimand? In randomised controlled trials (RCT) there is no choice. The ATE, ATT, and ATU are all equivalent in RCTs because, due to randomisation, the distribution of baseline characteristics will be similar between the treatment groups. However, in quasi-experimental and observational studies these estimands will differ because the distribution of baseline characteristics are likely to differ between treatment groups.\nA good starting point when choosing the estimand is to ask “for whom should the treatment effect be estimated?”. A causal estimand asks what would happen if the treatment were to be given to, or withheld from, a particular population. (Greifer & Stuart, 2023) provide an in-depth discussion of the choice of estimands, which we paraphrase here.\nAverage Treatment Effect (ATE)\nThe ATE asks how the outcome would differ between a setting where the treatment was given to all patients and a setting where the treatment was withheld from all patients. The ATE is useful when two differing treatments could be given to the population but it is unclear which of the two would be more beneficial. The ATE could also be used for assessing whether a policy could be unilaterally implemented, that is applied to some of the population but not all.\nAverage Treatment Effect in the Treated (ATT)\nThe ATT asks how the outcome of treated patients would change if they had not received the treatment. The ATT is the effect of withholding the treatment from those who would have received it. This estimand is useful when a decision needs to be made on an intervention that occurs in a particular population. For example, a decision needs to be made on whether to continue a treatment amongst those who are currently being treated, or a decision on whether preventing a harmful exposure would improve health outcomes amongst those who are currently exposed.\nAverage Treatment Effect in the Untreated (ATU)\nThe ATU is asks how would the outcome of untreated patients change if they had received the treatment? The ATU is the effect of expanding the treatment to those who do not receive it. This estimand is useful when a decision needs to be made on whether a treatment that is not given to a group of patients should continue to not be given to these patients. For example, consider a treatment that reduces the risk of cancer amongst those who are at high risk, but it is not known whether the treatment reduces the risk of cancer amongst those with low risk (and do not currently receive the treatment). The question is whether one should continue withholding the treatment or whether the low-risk patients would benefit from receiving the treatment.\n\n\n1.6.2 Choice of statistical estimand\nThe causal estimand is written in terms of potential outcome notation. It relies on being able to observe two hypothetical potential outcomes and we are not able to observed both of them in the real world. The statistical estimand, however, can be written in terms of the observed data if the identifiability assumptions are plausible.\nThere are numerous statistical estimands to choose from; some of the more common statistical estimands are:\nCausal risk difference\n\\[\n\\operatorname{P}\\{Y^{1}=1\\}-\\operatorname{P}\\{Y^{0}=1\\}\n\\]\nCausal risk ratio\n\\[\n\\frac{\\operatorname{P}\\{Y^{1}=1\\}}{\\operatorname{P}\\{Y^{0}=1\\}}\n\\]\nCausal log-odds ratio\n\\[\n\\log \\left[\\frac{\\operatorname{P}\\{Y^{1}=1\\}}{1-\\operatorname{P}\\{Y^{1}=1\\}}\\right] - \\log \\left[\\frac{\\operatorname{P}\\{Y^{0}=1\\}}{1-\\operatorname{P}\\{Y^{0}=1\\}}\\right]\n\\]\nThe choice for the measure of association depends on the form of the exposure and the outcome, but also on what might be easier to interpret in the context of the study.\n\nA note on estimands, estimators, and estimates\nEstimands represent the target of estimation in causal analysis and should not be confused with estimators, which are statistical methods (or algorithms) that are used to estimate the value of an estimand. Estimators are used to compute a numerical estimate of the causal effect of interest based on the available data.\nAn easy way to distinguish between these is to think of estimands as the name of a cake you would like to bake, think of estimators as the method (or recipe) you will use to make that cake, and the estimate is the cake that comes out of the oven.\nThere are many different types of estimators used in causal inference, including regression-based methods, propensity score methods, instrumental variables, and machine learning algorithms. The choice of estimator depends on the selected estimand and the study design, and can impact the results of a causal analysis.",
"crumbs": [
"Foundations",
"<span class='chapter-number'>1</span> <span class='chapter-title'>Introduction</span>"
]
},
{
"objectID": "chapters/chapter1/index.html#conclusion",
"href": "chapters/chapter1/index.html#conclusion",
"title": "1 Introduction",
"section": "1.7 Conclusion",
"text": "1.7 Conclusion\nOften, medical research is interested in estimating cause and effect relationships. These relationships are first considered through hypothetical research questions, such as “what would happen if our patients were given a different treatment?”, “how effective is this health policy?”, or “what would have happened if the patients were not exposed to some harmful substance?”. These questions are hypothetical scenarios because we only ever observe what happens when individuals are exposed or unexposed, but not both.\nIn randomised studies, causal effects can be estimated because individuals are randomly allocated to a treatment. A suitable randomisation process minimises the possibility of confounding. In epidemiological studies, this randomisation process is often unethical or infeasible. For example, if we were to investigate the effect of long-term tobacco smoking on the chances of developing lung cancer, it would be unethical to assign individuals to smoke tobacco. Instead, we can use statistical methods within a causal framework, whilst making certain assumptions, to estimate the cause-and-effect relationship.\nThe statistical methods used within the causal framework differ from other statistical methods with respect to their formality. The causal inference roadmap specifies the required criteria to estimate causal effects.(Petersen & Laan, 2014)\nIn this book we show how a range of causal inference methods can be applied to estimate a cause-and-effect relationship. We emphasise that these methods should only be used after the necessary steps have been satisfied in the causal inference roadmap (i.e., research question, assumptions, data generating distributions, etc.).\nAs practical epidemiologists and biostatisticians, we focus on the use of applied statistics. Thus, we aim to disseminate computational knowledge for executing and utilizing the various causal inference methods discussed in this book. This text offers practical code examples in R, Stata, and Python for users who wish to explore further.",
"crumbs": [
"Foundations",
"<span class='chapter-number'>1</span> <span class='chapter-title'>Introduction</span>"
]
},
{
"objectID": "chapters/chapter1/index.html#glossary",
"href": "chapters/chapter1/index.html#glossary",
"title": "1 Introduction",
"section": "1.8 Glossary",
"text": "1.8 Glossary\n\nATE\n\nAverage Treatment Effect\n\nATT\n\nAverage Treatment Effect among the treated\n\nATU\n\nAverage Treatment Effect among the non treated\n\nDAG\n\nDirected Acyclic Graph\n\nRCT\n\nRandomized Controlled Trial\n\nTMLE\n\nTargeted Maximum Likelihood Estimation\n\n\n\n\n\n\nBrian W. Whitcomb, N. J. P., Enrique F. Schisterman. (2009). Quantification of collider‐stratification bias and the birthweight paradox. Paediatric and Perinatal Epidemiology, 23(5), 394–402. https://doi.org/10.1111/j.1365-3016.2009.01053.x\n\n\nConnors, A. F., Speroff, T., Dawson, N. V., Thomas, C., Harrell, F. E., Wagner, D., Desbiens, N., Goldman, L., Wu, A. W., Califf, R. M., Fulkerson, W. J., Vidaillet, H., Broste, S., Bellamy, P., Lynn, J., & Knaus, W. A. (1996). The effectiveness of right heart catheterization in the initial care of critically ill patients. Journal of the American Medical Association, 276(11), 889–897. https://doi.org/10.1001/jama.276.11.889\n\n\nDang, L. E., Gruber, S., Lee, H., Dahabreh, I. J., Stuart, E. A., Williamson, B. D., Wyss, R., Díaz, I., Ghosh, D., Kıcıman, E., & al., et. (2023). A causal roadmap for generating high-quality real-world evidence. Journal of Clinical and Translational Science, 7(1), e212. https://doi.org/10.1017/cts.2023.635\n\n\nGreifer, N., & Stuart, E. A. (2023). Choosing the causal estimand for propensity score analysis of observational studies. arXiv. https://arxiv.org/abs/2106.10577\n\n\nGutman, R., & Rubin, D. B. (2015). Estimation of causal effects of binary treatments in unconfounded studies. Stat Med, 34(26), 3381–3398.\n\n\nHailey R. Banack, J. S. K. (2013). The “obesity paradox” explained. Epidemiology, 24(3), 461–462. https://doi.org/10.1097/ede.0b013e31828c776c\n\n\nJudea, P. (1994). A probabilistic calculus of actions. Proceedings of UAI-94, 454–462.\n\n\nMiguel Angel Luque-Fernandez, U. V., Helga Zoega. (2016). Deconstructing the smoking-preeclampsia paradox through a counterfactual framework. European Journal of Epidemiology, 31(6), 613–623. https://doi.org/10.1007/s10654-016-0139-5\n\n\nPearl, J. (2009). Causality: Models, reasoning, and inference. Cambridge University Press.\n\n\nPearl, J., & Robins, J. M. (1995). Probabilistic evaluation of sequential plans from causal models with hidden variables. Uncertainty in Artificial Intelligence, 11, 444–453.\n\n\nPetersen, M. L., & Laan, M. J. van der. (2014). Causal models and learning from data. Epidemiology, 25(3), 418–426. https://doi.org/10.1097/ede.0000000000000078\n\n\nRobins, J. (1986). 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(9), 1393–1512. https://doi.org/https://doi.org/10.1016/0270-0255(86)90088-6\n\n\nRobins, J. M. (1999). Association, causation, and marginal structural models. Synthese, 121(1/2), 151–179. https://doi.org/10.2307/20118224\n\n\nRubin, D. B. (1974). Estimating causal effects of treatments in randomized and nonrandomized studies. Journal of Educational Psychology, 66(5), 688.\n\n\nRubin, D. B. (2005). Causal inference using potential outcomes. Journal of the American Statistical Association, 100(469), 322–331. http://dx.doi.org/10.1198/016214504000001880\n\n\nRubin, D. B. (2007). The design versus the analysis of observational studies for causal effects: Parallels with the design of randomized trials. Stat Med, 26(1), 20–36.\n\n\nS. Hernandez-Diaz, M. A. H., E. F. Schisterman. (2006). The birth weight \"paradox\" uncovered? American Journal of Epidemiology, 164(11), 1115–1120. https://doi.org/10.1093/aje/kwj275\n\n\nSchomaker, M. (2020). Regression and causality. arXiv:2006.11754. http://arxiv.org/abs/2006.11754",
"crumbs": [
"Foundations",
"<span class='chapter-number'>1</span> <span class='chapter-title'>Introduction</span>"
]
},
{
"objectID": "chapters/chapter2/index.html",
"href": "chapters/chapter2/index.html",
"title": "2 Regression adjustment",
"section": "",
"text": "2.1 Regression methods\nRegression adjustment is a powerful statistical tool that allows one to control for confounding in complex settings where other methods, such as matching or stratification, do not work. This chapter will introduce the concept of confounding and the regression adjustment method to control for it.\nNote: This chapter contains a lot of content from this paper.(Luque-Fernandez et al., 2019)\nConfounding bias in epidemiological studies occurs when there are shared causes for both treatment or exposure, henceforth (A) and outcome, henceforth (Y) that can fully or partially explain the observed association between A and Y. To control for confounding randomization is classically used in experimental settings before the study design. However, when these tools fail or in observational studies it is critical to address confounding during the analysis stage. Classically, stratification serves as a well-recognized analytical technique to manage confounding. This approach involves evaluating the association of interest within separate groups that display similar characteristics with respect to the confounders. The principle of stratification is simple: It removes the variability of confounding elements within each group, ensuring these do not impact the treatment outcome relationship.\nHowever, despite being highly effective, stratification’s application becomes limited when faced with numerous confounding variables, as it results in overly small groupings that hinder practical comparisons due to insufficient data for precise estimation (i.e., sparsity due to increasing dimensionality on the data).\nRegression methods for adjusting confounding variables incorporate details about interventions and prognostic factors into a regression formula within a modeling context:\n\\[y_{ij} = \\beta_{0j} + \\beta_{1j}x_{i1} + \\beta_{2j}x_{i2} + \\cdots + \\beta_{pj}x_{ip} + \\epsilon_{ij},\\]\nwhere:\nRegression models are often fit within the generalized linear modeling framework. In a generalized linear model (GLM), the link function describes the relationship between Y, and A, adjusted for the set of confounders. It converts probabilities of Y into a continuous measure, enabling the modeling of relationships within a linear regression framework, offering all the advantages of including the outcome predictors in the model as quantitative variables without categorization, and the ability to assess trends with ordinal-scale confounders.\nCommon link functions include: i) the Identity link for linear regression models with continuous, normally distributed responses; ii) the Logit link for binary outcomes, like disease presence; iii) the Probit link, transforming binary responses to a standard normal distribution; iv) the Log link for positively skewed responses, such as counts or proportions; and v) the Inverse link for continuous, positively skewed responses. For binary outcomes, to assess the model coefficient for the adjusted A effect, the odds ratio [OR] is used as a useful estimand. Other estimands that regression models can also calculate are the risk ratio [RR] and the absolute risk or risk difference [RD].\nThe interpretation of the regression coefficients is straightforward. A regression coefficient indicates how the outcome changes with a change in the treatment or exposure of interest, holding the other model predictors constant. This is a conditional estimate effect. It is important to highlight that in simple linear models, this is equivalent to the marginal effect, i.e., the overall treatment effect. However, when interaction terms are added between A and some confounders, models become more complex. In such cases, the coefficient for A might only represent its effect within a reference group, i.e., a conditional effect and not the overall effect. When moving away from linear models, the connection between conditional effects and overall marginal effects can deteriorate considerably. It might seem natural to assume that dividing a population into various subgroups and then estimating the effect within each subgroup would produce an overall marginal effect that is simply a weighted combination of these subgroup-specific effects. However, this relationship holds only for certain causal measures—specifically those that are collapsible, such as RD and RR. In contrast, ORs exhibit non-collapsibility (see Chapter 3 for more details on collapsibility), which means that the marginal odds ratio might be either larger or smaller than any of the conditional ORs derived from subgroups in the regression model.(Brian W Whitcomb, 2021)",
"crumbs": [
"Foundations",
"<span class='chapter-number'>2</span> <span class='chapter-title'>Regression adjustment</span>"
]
},
{
"objectID": "chapters/chapter2/index.html#regression-methods",
"href": "chapters/chapter2/index.html#regression-methods",
"title": "2 Regression adjustment",
"section": "",
"text": "\\(y_{ij}\\): represents the i-the observation of the j-th dependent variable.\n\\(\\beta_{0j}\\): is the intercept for the j-th dependent variable.\n\\(\\beta_{kj}\\): is the regression coefficient for the k-th predictor variable (xk) on the j-th dependent variable.\n\\(x_{ik}\\): represents the i-th observation of the k-th predictor variable.\np: This is the total number of predictor variables.\n\\(\\epsilon_{ij}\\): represents the error term for the i-th observation of the j-th dependent variable.",
"crumbs": [
"Foundations",
"<span class='chapter-number'>2</span> <span class='chapter-title'>Regression adjustment</span>"
]
},
{
"objectID": "chapters/chapter2/index.html#confounding-and-collider-biases",
"href": "chapters/chapter2/index.html#confounding-and-collider-biases",
"title": "2 Regression adjustment",
"section": "2.2 Confounding and collider biases",
"text": "2.2 Confounding and collider biases\nA confounder can fully or partially explain the observed association between exposure (A) and outcome (Y). This bias i.e., “confounding bias”, makes for example the effect measure from a binary treatment (A) on the binary outcome (Y) i.e., the raw OR, to diverge from its true causal effect, i.e., the true marginal causal OR. The expression “association is not causation” illustrates clearly the importance of accounting for confounding bias.\nRegression models can be a viable approach for confounding adjustment; however, it requires assuming no effect modification. Alternatively, the generalization of standardization, via the G-Formula(Robins, 1986), could be used to improve adjustment, minimize residual confounding, and allow for causal interpretation without randomization (see Chapter four). Moreover, in certain cases, the introduction of a specific type of confounder known as a “collider” into a regression model can result in bias in the regression coefficient estimates for the treatment effect (A), even though it could potentially enhance the model’s overall goodness of fit.\nDirect Acyclic Graphs (DAGs), which are informed by expertise in the subject area, play a crucial role in identifying such colliders. Identifying whether a confounder is a collider requires careful consideration of the true unobserved data-generating process and the interrelationships among variables within a given context.(N. Pearce, 2014)\nIn general, incorporating a collider into a regression model is discouraged if the goal is to estimate causal effects, as it can introduce bias. However, if the model is aimed at prediction, including colliders might be beneficial if it decreases prediction error.\nTo illustrate both concepts, we use a linear regression modeling framework to adjust for confounding in a set of boxes containing R software commented code. We introduce three scenarios to illustrate the differences in adjusting for confounders or colliders ?fig-DAG2. In ?fig-DAG2 (panel A), the causal effect of \\(A\\) on \\(Y\\) is confounded by \\(W\\). In ?fig-DAG2 (panel B), the causal effect of \\(A\\) on \\(Y\\) is not confounded but adjusting for the collider \\(C\\) induces a bias. Lastly, in ?fig-DAG2 (panel C), there are no confounders but conditioning on the collider \\(C\\) opens a back-door path through \\(W1\\) and \\(W2\\).\n\n\nShow the code\ngraph LR\n subgraph PanelA[\"Panel A\"]\n W((W)) --> A[A]\n W --> Y[Y]\n A --> Y\n end\n subgraph PanelB[\"Panel B\"]\n A2[A] --> C((C))\n Y2[Y] --> C\n A2 --> Y2\n end\n subgraph PanelC[\"Panel C\"]\n W1((W1)) --> A3[A]\n W1 --> C3((C))\n W2((W2)) --> C3\n W2 --> Y3[Y]\n A3 --> Y3\n end\n\n\n\n\n\n\n\n\n\n\n\nData consistent with the directed acyclic graph (DAG) depicted in ?fig-DAG2 was generated (Box ?lst-datasimple), following a process akin to that described by (Luque-Fernandez et al., 2018): The confounder, represented by \\(W\\) in ?fig-DAG2, was simulated as a standard normal random variable, characterized by a mean of 0 (\\(\\mu=0\\)) and a variance of 1 (\\(\\sigma^{2}=1\\)). The generation of the exposure, \\(A\\), was contingent upon the value of \\(W\\), incorporating an error term with a standard normal distribution. Subsequently, the outcome, \\(Y\\), was generated as a function of both \\(A\\) and \\(W\\), with an additional error term also drawn from a standard normal distribution. These assumptions establish linear relationships between the variables and a simulated causal effect of \\(A\\) on \\(Y\\) with a coefficient of 0.3. Linear regression models, both unadjusted (fit1) and adjusted for \\(W\\) (fit2), were then employed to estimate associations between \\(A\\) and \\(Y\\).\nBox ?lst-datasimple: Generate data consistent with ?fig-DAG2 (panel A)\nlibrary(visreg) # load package to visualize regression output\nlibrary(ggplot2)# load package to visualize regression output\nlibrary(patchwork) # https://patchwork.data-imaginist.com/\n\nN <- 1000 # sample size\nset.seed(777)\nW <- rnorm(N) # confounder\nA <- 0.5 * W + rnorm(N) # exposure\nY <- 0.3 * A + 0.4 * W + rnorm(N) # outcome\nfit1 <- lm(Y ~ A) # crude model\nfit2 <- lm(Y ~ A + W) # adjusted model\n\n# visualize crude and adjusted models\na = visreg (fit1 , \"A\" , gg = TRUE , line = list ( col = \"blue\") ,\n points = list ( size = 2 , pch = 1 , col = \"black\") ) + theme_classic ()\nb = visreg (fit2 , \"A\" , gg = TRUE , line = list ( col = \"blue\") ,\n points = list (size = 2 , pch = 1 , col = \"black\") ) + theme_classic ()\npatchwork <- a + b + plot_layout (guides = \"collect\")\npatchwork + plot_annotation(\n tag_levels = 'A',\n title = 'Regression adjustment: Confounding bias',\n subtitle = 'A: lm (Y ~ A); B: lm (Y ~ A + W)',\n caption = 'Disclaimer: In-house'\n)\nThe first regression analysis, without conditioning on W, illustrates this bias. The estimated coefficient for \\(A\\) (0.472) exhibits an upward bias compared to the true causal effect (0.3) specified in the simulation. In contrast, the second regression adds \\(W\\) as a covariate, effectively closing the open back-door path. This approach yields a more accurate estimate of the causal effect (0.289), closer to the true value. The remaining residual difference of 0.011 can be attributed to sampling variability.\nFigure 2.1 shows the confounding bias based on the slope from the linear adjustment contrasting A without adjustment for W versus B with adjustment for W.\n\n\n\n\n\n\nFigure 2.1: Regression adjustment: univariate (A), bivariate adjustement (B) models fit for the linear association between Y and A.\n\n\n\n?fig-DAG2 highlights the key role of \\(W\\) as a confounder in this causal structure. Its unique position without parent nodes indicates that it is not influenced by any other variable in the DAG. Consequently, \\(W\\) is generated independently within the model. However, both \\(A\\) and \\(Y\\) share a common parent in \\(W\\), creating an open back-door path between them. This path explains the potential for confounding bias.\nIn contrast to ?fig-DAG2 (panel A), where the causal arrows originate from node \\(W\\), ?fig-DAG2 (panel B) presents a different causal structure with arrows directed toward node \\(C\\) from both \\(A\\) and \\(Y\\). Conditioning on \\(C\\) in this scenario, through methods such as regression or stratification, introduces collider bias. This arises because node \\(C\\) acts as a collider on the path \\(A \\rightarrow C \\leftarrow Y\\), where two causal pathways converge.\nTo illustrate this concept, consider a scenario where the wetness of the ground (\\(C\\)) is solely influenced by rain (\\(A\\)) and an automatic sprinkler (\\(Y\\)) set on a timer. In this case, knowing that the ground is wet (conditioning on \\(C\\)) while simultaneously observing that it did not rain (negating path \\(A \\rightarrow C\\)) implies that the sprinkler must be on (positive effect on \\(C\\) via path \\(Y \\rightarrow C\\)). Failing to account for the collider \\(C\\) in the analysis might lead to the erroneous conclusion that rain negatively influences sprinkler usage, despite pre-existing knowledge of their independence.(Pearl, 2009)\nViolation of the ignorability assumption due to collider conditioning: conditioning on a collider variable, such as \\(C\\) in ?fig-DAG2 (panel B), can induce a spurious association between the exposure (\\(A\\)) and the potential outcomes (\\(Y(a)\\)). This undermines the conditional ignorability assumption (\\(Y(a)\\perp A \\mid W, C\\)), which requires the exposure to be independent of the potential outcomes given the conditioning set (see Chapter One).\n?fig-DAG2 (panel B) illustrates this concept. Conditioning on \\(C\\) opens the back-door path (\\(A \\rightarrow C \\leftarrow Y\\)) previously blocked by the collider itself. This opens a channel for the effect of \\(A\\) on \\(Y\\) to indirectly influence the observed association between \\(A\\) and \\(Y(a)\\). As a result, the observed association becomes a mixture of both the causal effect of \\(A\\) on \\(Y\\) and the spurious association induced by the back-door path. This confounds the interpretation of the association, as it is no longer solely attributable to the direct causal effect of \\(A\\) on \\(Y\\). Therefore, conditioning on a collider can lead to spurious associations, hindering the identification of true causal relationships from observational data.\n?fig-DAG2 (panel C) gives another, more complex collider structure usually known as M-bias, in which the collider (\\(C\\)) is the effect of a common cause (\\(W1\\)) of the exposure (\\(A\\)) and a common cause (\\(W2\\)) of the outcome (\\(Y\\)). There is only one back-door path, and it is already blocked by the collider (\\(C\\)); thus we do not need to control for anything. This is the difference between confounders and colliders: a path will be open if one does not adjust for confounders but blocked if adjustment is made. For colliders, it is the other way around. However, some could consider \\(C\\) to be a classical confounder as it is associated with both \\(A\\), via (\\(A \\leftarrow W1 \\rightarrow C\\)), and with \\(Y\\), via a path that does not go through \\(A\\) (\\(C \\leftarrow W2 \\rightarrow Y\\)), and it is not in the causal pathway between \\(A\\) and \\(Y\\). However, controlling for \\(C\\) will introduce a collider bias. If one were to use the traditional characteristics used to identify confounders (i.e., a third variable [\\(W\\)] associated with both the exposure [\\(A\\)] and the outcome [\\(Y\\)] that is not on the causal pathway between \\(A\\) and \\(Y\\)), then one could confuse a collider with a confounder.\n?fig-DAG2 (panel C) presents a more intricate collider structure exhibiting M-bias, where the collider, \\(C\\), is influenced by both $W$1, a common cause with exposure \\(A\\), and $W$2, a common cause with outcome \\(Y\\). Notably, a single back-door path exists, but collider \\(C\\) already blocks it, eliminating the need for adjustment. This highlights a fundamental distinction between confounders and colliders: while adjusting for confounders reveals potential causal effects by unblocking paths, adjusting for colliders like \\(C\\) inadvertently introduces bias by opening blocked paths, leading to the M-bias phenomenon.\nHowever, some may misinterpret \\(C\\) as a traditional confounder. It is indeed associated with both \\(A\\) (via $W$1) and \\(Y\\) (via $W$2), and it lies outside the direct causal pathway between \\(A\\) and \\(Y\\). Despite these characteristics, controlling for \\(C\\) would induce collider bias, highlighting the critical distinction between association and causation. Therefore, relying solely on the conventional properties of confounders (association with both exposure and outcome, off-pathway location) can lead to misidentification and spurious inferences when dealing with colliders like \\(C\\). This underscores the importance of carefully considering the underlying causal structure and potential collider bias before implementing adjustment strategies.\nBuilding upon the simulated scenario depicted in ?fig-DAG2 (panel B), we replicate the data generation process through a simplified linear mechanism outlined in Box ?lst-datacomplex. Initially, we draw variable \\(A\\) from a standard normal distribution conditioned on the confounder \\(W\\). Subsequently, we generate outcome \\(Y\\) as the sum of the effect of \\(A\\), the confounder \\(W\\), and an error term. Similarly, variable \\(C\\) is generated as a function of both \\(A\\) and \\(Y\\), incorporating additional error. This revised configuration, as illustrated in ?fig-DAG2 (panel B), establishes both \\(A\\) (exposure) and \\(Y\\) (outcome) as parents of \\(C\\) (collider), creating a common effect situation. We then proceed to analyze the data by fitting two models: an adjusted model for \\(W\\) excluding the collider (fit3) and a model that incorporates the collider (fit4), also referred to as the collider model). Notably, the true causal coefficient of exposure \\(A\\) is established as 0.3, with the collider \\(C\\) demonstrating coefficients of 1.0 for both its association with exposure \\(A\\) and outcome \\(Y\\).\nBox ?lst-datacomplex: To generate data consistent with ?fig-DAG2 (panel B)\nN <- 1000 # sample size\nset.seed (777)\nW <- rnorm(N) # confounder\nA <- 0.5 * W + rnorm(N) # exposure\nY <- 0.3 * A + + 0.4 * W + rnorm(N) # outcome\nC <- 1 * A + 1 * Y + rnorm(N) # collider\nfit3 <- lm (Y ~ A + W) # adjusted model for confounder\nfit4 <- lm (Y ~ A + C) # adjusted model for collider\n\n# visualize adjusted models\ng1 <- visreg (fit3 , \"A\" , gg = TRUE , line = list ( col = \"blue\") ,\n points = list (size = 2 , pch = 1 , col = \"black\") ) + theme_classic () +\n coord_cartesian (ylim = c ( -4 , 4))\ng2 <- visreg (fit4 , \"A\" , gg = TRUE , line = list ( col = \"red\") ,\n points = list (size = 2 , pch = 1 , col = \"black\") ) + theme_classic () +\n coord_cartesian (ylim = c ( -4 , 4))\npatchwork <- g1 + g2 + plot_layout (guides = \"collect\")\npatchwork + plot_annotation(\n tag_levels = 'A',\n title = 'Regression adjustment: Collider bias',\n subtitle = 'A: lm (Y ~ A + W); B: lm (Y ~ A + C)',\n caption = 'Disclaimer: In-house')\nIn contrast to the previous section, ignoring the collider variable \\(C\\) in the regression model resulted in an estimate of the true coefficient for \\(A\\) (0.3) that was remarkably close, at 0.298. However, adjusting for \\(C\\) introduced a substantial bias, leading to an estimate of -0.3 as depicted in Figure 2.2. While the model incorporating the collider (fit4) performs competitively from a predictive standpoint, as evidenced by its lower Akaike Information Criterion (AIC), it paradoxically alters the direction of the association between \\(A\\) and \\(Y\\). This phenomenon, where conditioning on the collider introduces bias while ignoring it does not, arises when both \\(A\\) and \\(Y\\) are positively correlated with the collider. Thus, in this specific case, including the collider in the regression model introduces a bias while excluding it does not.\n\n\n\n\n\n\nFigure 2.2: Regression adjustment: confounding bias (A), collider bias (B) models fit for the linear association between Y and A.",
"crumbs": [
"Foundations",
"<span class='chapter-number'>2</span> <span class='chapter-title'>Regression adjustment</span>"
]
},
{
"objectID": "chapters/chapter2/index.html#motivating-example",
"href": "chapters/chapter2/index.html#motivating-example",
"title": "2 Regression adjustment",
"section": "2.3 Motivating example",
"text": "2.3 Motivating example\nTo illustrate the impact of conditioning on a collider variable, we simulated a dataset with 1,000 observations focusing on the relationship between dietary sodium intake, age, and systolic blood pressure (SBP). The example is fully available and reproducible at the GitHub repository: https://github.com/migariane/ColliderApp, and there is also an online available ShinyApp at: https://watzile.shinyapps.io/EpiCollider/\nHypertension affects nearly one-third of the American population, with over half exhibiting uncontrolled hypertension. Extensive evidence confirms a positive association between cumulative daily sodium intake (grams) exceeding recommended levels and elevated SBP (mmHg). Moreover, advancing age brings about anatomical and physiological changes in the kidneys, compromising their ability to regulate extracellular fluid volume and composition. Notably, these changes include diminished glomerular filtration rate and an impaired capacity to maintain water and sodium homeostasis in response to external factors. Additionally, age-related structural modifications in the arteries contribute to the observed association between age and SBP.\nThe strong association between age and both high SBP and impaired sodium homeostasis poses a challenge for assessing the true relationship between sodium intake (SOD) and SBP. Age acts as a potential confounder in this scenario, residing on the causal pathway between SOD and SBP as illustrated in ?fig-DAG3. This implies that controlling for age solely based on its association with both the exposure (SOD) and the outcome (SBP) could introduce bias into the estimated effect of SOD on SBP.\nFurther complicating the analysis is the role of proteinuria (PRO). High levels of 24-hour urinary protein excretion are observed in response to both sustained high SBP and increased dietary sodium intake, as shown in ?fig-DAG3. This places proteinuria in the position of a potential collider variable. Controlling for proteinuria in the presence of unmeasured common causes with both SOD and SBP (represented by the arrow converging on PRO in ?fig-DAG3) could introduce collider bias, potentially underestimating or overestimating the true effect of SOD on SBP. Therefore, researchers conducting such analyses should carefully consider the potential for both confounding and collider bias. Controlling for age remains crucial when its influence on SBP pathways is understood and adequately represented in the model. However, if the underlying physiological mechanisms are incompletely understood, or if proteinuria is mistakenly conceptualized as a confounder, controlling for it could lead to biased estimates.\n\n\nShow the code\ngraph TD\n AGE((AGE)) --> SOD((SOD))\n AGE --> SBP((SBP))\n SOD --> SBP\n SOD --> PRO((PRO))\n SBP --> PRO\n\n\n\n\n\n\n\n\n\n\n\nThis section focuses on simulating data to illustrate the paradoxical effect of 24-hour dietary sodium intake (grams) on systolic blood pressure (SBP) after conditioning on a potential collider, urinary proteinuria. The simulated data will be based on the structural relationships depicted in the DAG presented in ?fig-DAG3 (see Box ?lst-data for details).\nBox ?lst-data provides a function to simulate data for this example. The true causal effect of sodium intake on systolic blood pressure (SBP) is represented by a beta coefficient of 1.05, as shown in the formula for SBP: systolic blood pressure \\(=\\beta_{1} \\cdot sodium + \\beta_{2} \\cdot age + \\epsilon\\), where \\(\\beta_{1} = 1.05\\), \\(\\beta_{2} = 2.0\\), and \\(\\epsilon\\) denotes a standard normally distributed error term. Additionally, the coefficients for the association of proteinuria (PRO) with SBP and sodium intake are 2.0 and 2.8, respectively, as specified in the formula for PRO: PRO \\(= \\beta_{1} \\cdot SBP + \\beta_{2} \\cdot Sodium + \\epsilon\\), where \\(\\beta_{1} = 2.0\\), \\(\\beta_{2} = 2.8\\), and \\(\\epsilon\\) represents a standard normally distributed error term.\nBox ?lst-data: Data generation consistent with ?fig-DAG3\ngenerateData <- function(n, seed){\n set.seed(seed)\n Age_years <- rnorm(n, 65, 5)\n Sodium_gr <- Age_years / 18 + rnorm(n)\n sbp_in_mmHg <- 1.05 * Sodium_gr + 2.00 * Age_years + rnorm(n)\n hypertension <- ifelse(sbp_in_mmHg > 140, 1, 0)\n Proteinuria_in_mg <- 2.00*sbp_in_mmHg + 2.80*Sodium_gr + rnorm(n)\n data.frame(sbp_in_mmHg, hypertension, Sodium_gr, Age_years, Proteinuria_in_mg)\n}\n\nObsData <- generateData(n = 1000, seed = 777)\nThree linear regression models were employed (Box ?lst-linear) to explore the association between sodium intake and systolic blood pressure (SBP):\n\nUnadjusted model: This basic model examined the crude relationship between sodium intake and SBP.\nModel adjusted for age: Recognizing age as a potential confounder, this model controlled for its influence on the association.\nModel adjusted for age and proteinuria: Expanding upon the previous model, proteinuria was included as a potential collider variable due to its possible influence on both sodium intake and SBP.\n\nThe algebraic specifications of these models are presented below. Additionally, Box ?lst-linear provides R code for model fitting and visualization.\nModel 1:\n\\[\\text{SBP} \\quad = \\quad \\beta0 + \\beta1 \\cdot Sodium + \\epsilon\\]\nModel 2:\n\\[\\text{SBP} \\quad = \\quad \\beta0 + \\beta1 \\cdot Sodium + \\beta2 \\cdot Age + \\epsilon\\]\nModel 3:\n\\[\\text{SBP} \\quad = \\quad \\beta0 + \\beta1 \\cdot Sodium + \\beta2 \\cdot Age + \\beta3 \\cdot Proteinuria + \\epsilon\\]\nBox ?lst-linear: Linear regression models in R\nlibrary(broom) # load packages to visualize regression model's output\nlibrary(visreg)\n\n## Models Fit\nfit1 <- lm(sbp_in_mmHg ~ Sodium_gr, data = ObsData); tidy(fit0)\nfit2 <- lm(sbp_in_mmHg ~ Sodium_gr + Age_years, data = ObsData); tidy(fit2)\nfit3 <- lm(sbp_in_mmHg ~ Sodium_gr + Age_years + Proteinuria, data = ObsData); tidy(fit3)\n\n## Models visualization\npar(mfrow = c(1, 3))\nvisreg(fit1, ylab = 'SBP in mmHg', line = list(col = 'blue'),\n points = list(cex = 1.5, pch = 1), jitter = 10, bty = 'n')\n\nvisreg(fit2, ylab = 'SBP in mmHg', line = list(col = 'blue'),\n points = list(cex = 1.5, pch = 1), jitter = 10, bty = 'n')\n\nvisreg(fit3, ylab = 'SBP in mmHg', line = list(col = 'red'),\n points = list(cex = 1.5, pch = 1), jitter = 10, bty = 'n')\nTo further investigate the association between sodium intake and hypertension, defined as a binary outcome (systolic blood pressure \\(\\geq\\) 140 mmHg = 1, \\(<\\) 140 mmHg = 0), we employed three logistic regression models. The first model served as a baseline, excluding any adjustments. The second model incorporated age as a potential confounder, while the third additionally adjusted for proteinuria, identified as a collider variable due to its potential influence on both sodium intake and hypertension. Notably, these models mirrored the specifications previously described, with the exception of the binary outcome variable (hypertension). Box ?lst-forest demonstrates the R code for fitting and visualizing these models as a forest plot.\nBox ?lst-forest: Multiplicative scale visualization using a forest plot function\n## Models fit on multiplicative scale\n library(dplyr)\n library(forestplot)\n fit3 <- glm(hypertension ~ Sodium_gr, family=binomial(link='logit'), data=ObsData)\n or <- round(exp(fit3$coef)[2], 3) # conditional odds ratio from logistic model\n ci95 <- exp(confint(fit3))[-1,] # 95% CI of odds ratio\n fit4 <- glm(hypertension ~ Sodium_gr + Age_years, family = binomial(link = 'logit'), data = ObsData)\n or <- round(exp(fit4$coef)[2], 3)\n ci95 <- exp(confint(fit4))[2,]\n fit5 <- glm(hypertension ~ Sodium_gr + Age_years + Proteinuria_in_mg, family = binomial(link = 'logit'), data = ObsData)\n or <- round(exp(fit5$coef)[2], 3)\n ci95 <- exp(confint(fit5))[2,]\n\n## Forest plot (see supplementary material for accessing the complete code)\n fp <- rbind(result1, result2, result3); fp %>% or_graph()\nEffect of conditioning on a collider\nFigure 2.3 depicts the estimated effect of sodium intake on systolic blood pressure (SBP) after conditioning on a collider variable, along with corresponding 95% confidence intervals. The adjusted regression line represents the predicted SBP conditional on the median value of age (Figure 2.3 panel B) or both age and proteinuria (Figure 2.3 panel C). Notably, unlike the unadjusted and bivariate models in Figure 2.3 (panels A and B, respectively), the collider-adjusted model in Figure 2.3 (panel C) reveals a negative association between sodium intake and SBP. Here, a one-unit increase in sodium intake is associated with a predicted decrease of 0.9 mmHg in SBP.\n\n\n\n\n\n\nFigure 2.3: Collider effect for the illustration: univariate (A), bivariate (B) and multivariate (C) models fit for the linear association between systolic blood pressure and 24-h sodium dietary intake, adjusted for age acting as a confounder and proteinuria acting as a collider, n=1000.",
"crumbs": [
"Foundations",
"<span class='chapter-number'>2</span> <span class='chapter-title'>Regression adjustment</span>"
]
},
{
"objectID": "chapters/chapter2/index.html#monte-carlo-simulation",
"href": "chapters/chapter2/index.html#monte-carlo-simulation",
"title": "2 Regression adjustment",
"section": "2.4 Monte-Carlo simulation",
"text": "2.4 Monte-Carlo simulation\nThe code employed for conducting Monte-Carlo simulations on the additive scale, utilizing the same parameters as outlined in Box ?lst-data, is presented in Box ?lst-MCsim. Within the linear model, the simulated causal effect of 24-hour sodium intake on SBP was 1.05 mmHg. The coefficients corresponding to the associations between proteinuria (PRO) and SBP, as well as PRO and sodium intake, were 2.0 and 2.8, respectively. Upon completion of 1000 simulation iterations, the estimated additive effect of 24-hour sodium intake on SBP was determined to be -0.91 mmHg. This indicates a decrease of -0.91 units in SBP for every unit increase in sodium intake. Notably, conditioning on proteinuria, a collider variable, introduced a relative bias of 13.3%.\nBox ?lst-MCsim: Monte Carlo simulations\n# Monte Carlo Simulations\n R<-1000\n true <- rep(NA, R)\n collider <- rep(NA, R)\n se <- rep(NA, R)\n set.seed(050472)\n\n for(r in 1: R) {\n if (r%%10 == 0) cat(paste('This is simulation run number', r, '\\n'))\n\n# Function to generate data\n generateData <- function(n){\n Age_years <- rnorm(n, 65, 5)\n Sodium_gr <- Age_years / 18 + rnorm(n)\n sbp_in_mmHg <- 1.05 * Sodium_gr + 2.00 * Age_years + rnorm(n)\n Proteinuria_in_mg <- 2.00 * sbp_in_mmHg + 2.80 * Sodium_gr + rnorm(n)\n data.frame(sbp_in_mmHg, Sodium_gr, Age_years, Proteinuria_in_mg)\n }\n\n ObsData <- generateData(n=10000)\n\n# True effect\n true[r] <- summary(lm(sbp_in_mmHg ~ Sodium_gr + Age_years, data = ObsData))$coef[2,1]\n\n# Collider effect\n collider[r] <- summary(lm(sbp_in_mmHg ~ Sodium_gr + Age_years + Proteinuria_in_mg, data = ObsData))$coef[2,1]\n se[r] <- summary(lm(sbp_in_mmHg ~ Sodium_gr + Age_years + Proteinuria_in_mg, data = ObsData))$coef[2,2]\n }\n\n# Estimate of sodium true effect\n mean(true)\n\n# Estimate of sodium biased effect in the model including the collider\n mean(collider)\n\n# simulated standard error/confidence interval of outcome regression\n lci <- (mean(collider) - 1.96*mean(se)); mean(lci)\n uci <- (mean(collider) + 1.96*mean(se)); mean(uci)\n\n# Bias\n Bias <- (true - abs(collider)); mean(Bias)\n\n# % Bias\n relBias <- ((true - abs(collider)) / true); mean(relBias) * 100\n\n# Plot bias\n plot(relBias)\nWithin the framework of this data-generating structure, the presence of a collider variable introduces regression dilution bias (also known as regression attenuation), reducing the observed association between sodium intake and SBP compared to the true causal effect. To induce a paradoxically negative association (i.e., sodium intake protective against SBP), the strength of the collider-exposure association (\\(\\alpha_{1}\\)) and collider-outcome association (\\(\\alpha_{2}\\)) must increase relative to the magnitude of the true causal effect. While equating \\(\\alpha_{1}\\) and \\(\\alpha_{2}\\) may not be entirely realistic, it serves as a useful simplification for illustrating how bias magnitude changes as these associations vary.\nBeyond the classic scenario of conditioning on a collider in the analysis, two further situations warrant attention:\n\nCollider Effect and Sample Selection: When sample selection is guided by either a measured or unmeasured common effect of the exposure and outcome, collider bias can emerge. Recent studies highlight the potential for even subtle influences on sample selection to induce misleading estimates. Unfortunately, addressing this bias can be challenging, as information on selection mechanisms may be lacking.\nM-Bias: Balancing Collider and Confounder Control: M-bias arises when the collider also functions as a confounder. In this setting, understanding the trade-off between collider and confounder control becomes crucial. M-bias, while potentially comparable in magnitude to classical confounding, is often negligible unless associations between the collider and confounders are very strong (e.g., relative risk \\(>\\) 8). Therefore, prioritizing confounder control is generally recommended in M-bias situations.\n\nCollider Inclusion in Regressions:\nThese investigations explored situations where adding a collider variable to a linear regression model improved model fit but introduced bias in coefficient estimates. It is important to note that\n\nCollider Identification: DAGs, informed by subject-matter knowledge, play a vital role in identifying colliders. This involves critically examining the unobserved data-generation process and variable relationships within the specific research context.\nPrediction vs. Explanation: The decision to include or exclude a collider depends on the study’s objective. In studies seeking causal understanding in epidemiology, colliders should generally be excluded to avoid biased effect estimates and confounding through back-door paths. Conversely, for purely predictive purposes, including colliders may be beneficial if it improves model accuracy.\n\nImplications for Epidemiological Research:\nGiven that most epidemiological research aims to explain causal relationships, awareness of collider variables is crucial to avoid paradoxical associations. By carefully considering collider effects and potential biases, epidemiologists can ensure the robustness and interpretability of their causal estimates.",
"crumbs": [
"Foundations",
"<span class='chapter-number'>2</span> <span class='chapter-title'>Regression adjustment</span>"
]
},
{
"objectID": "chapters/chapter2/index.html#glossary",
"href": "chapters/chapter2/index.html#glossary",
"title": "2 Regression adjustment",
"section": "2.5 Glossary",
"text": "2.5 Glossary\n\nAIC\n\nAkaike Information Criterion\n\nDAG\n\nDirected Acyclic Graph\n\nGLM\n\nGeneralized Linear Model\n\nOR\n\nOdds Ratio\n\nRD\n\nRisk Difference\n\nRR\n\nRisk Ratio\n\n\n\n\n\n\nBrian W Whitcomb, A. I. N. (2021). Defining, quantifying, and interpreting “noncollapsibility” in epidemiologic studies of measures of “effect.” American Journal of Epidemiology, 190(5), 697–700. https://doi.org/10.1093/aje/kwaa267\n\n\nLuque-Fernandez, M. A., Redondo-Sanchez, D., & Schomaker, M. (2019). Effect Modification and Collapsibility in Evaluations of Public Health Interventions. American Journal of Public Health, 109(3), e12–e13. https://doi.org/10.2105/AJPH.2018.304916\n\n\nLuque-Fernandez, M. A., Schomaker, M., Rachet, B., & Schnitzer, M. E. (2018). Targeted maximum likelihood estimation for a binary treatment: A tutorial. Statistics in Medicine, 37(16), 2530–2546. https://doi.org/10.1002/sim.7628\n\n\nN. Pearce, L. R. (2014). Commentary: Three worlds collide: Berkson’s bias, selection bias and collider bias. International Journal of Epidemiology, 43(2), 521–524. https://doi.org/10.1093/ije/dyu025\n\n\nPearl, J. (2009). Causality: Models, reasoning, and inference. Cambridge University Press.\n\n\nRobins, J. M. (1986). A new approach to causal inference in mortality studies with sustained exposure periods – application to control of the healthy worker survivor effect. Mathematical Modeling, 7, 1393–1512.",
"crumbs": [
"Foundations",
"<span class='chapter-number'>2</span> <span class='chapter-title'>Regression adjustment</span>"
]
},
{
"objectID": "chapters/chapter3/index.html",
"href": "chapters/chapter3/index.html",
"title": "3 G-formula",
"section": "",
"text": "3.1 Introduction\nThe g-formula, also known as the g-computation formula, is a fundamental method in causal inference used to estimate the causal effect of interventions using observational data. It was introduced by James Robins in the 1980s to address challenges posed by time-dependent confounding in longitudinal studies. Traditional epidemiological methods, such as regression models and stratification-based approaches, often failed to account for time-varying confounders affected by prior treatment, leading to biased estimates. The g-formula emerged as a solution to these limitations, offering a mathematically rigorous way to estimate causal effects under specific assumptions.\nBefore the g-formula, causal inference heavily relied on approaches such as stratification and regression, which struggled with complex confounding structures, particularly in longitudinal studies where confounders change over time. In response, Robins built upon the potential outcomes framework, originally developed by Donald Rubin and Jerzy Neyman, to introduce the g-methods. These methods include the g-formula, Inverse Probability of Treatment Weighting (IPTW), and G-estimation for Structural Nested Models, all of which aim to handle time-dependent confounding. The introduction of the g-formula represented a significant advancement by enabling researchers to estimate counterfactual outcomes more accurately.\nThe g-formula gained attention in the 1990s as researchers applied it to public health and epidemiology, particularly in studying long-term interventions such as HIV treatment and smoking cessation programs. As computational power increased in the 2000s, the method became more widely used in complex, high-dimensional datasets. During this period, software implementations in statistical programming languages such as R and Stata made the g-formula more accessible to applied researchers. By the 2010s, further extensions of the method allowed for the consideration of competing risks, dynamic treatment regimes, and personalized medicine applications.\nMathematically, the g-formula estimates the counterfactual mean outcome under a given intervention by standardizing observed data. It is expressed as:\n\\[ E[Y^a] = \\sum_{w} E[Y \\mid A = a, W = w] P(W = w) \\]\nIn this formula, \\(Y^{a}\\) represents the potential outcome under the intervention \\(A = a\\), \\(\\textbf{W}\\) denotes confounders (which may be time-dependent), and \\(A\\) refers to the treatment or exposure of interest. By iteratively predicting the outcome based on observed covariates, the g-formula helps to adjust for confounding and provides an unbiased estimate of the causal effect under the assumption of no unmeasured confounding, positivity, and consistency.\nThe g-formula has found applications across multiple disciplines, including epidemiology, public health, and health policy. Researchers have used it to evaluate the long-term effects of healthcare interventions, assess drug effectiveness, and inform clinical decision-making. Despite its wide applicability, the g-formula has some limitations. It requires correct model specification for all variables involved in the causal pathway, making it sensitive to model misspecification. Additionally, the method can be computationally intensive, particularly in large datasets, and relies on the assumption of no unmeasured confounding, which may not always hold in observational studies.\nIn recent years, modern advancements have extended the g-formula’s capabilities. Approaches such as Monte Carlo G-computation allow for the simulation of potential outcomes under various interventions, while the integration of machine learning methods helps to relax parametric assumptions and improve predictive accuracy. Furthermore, combining the g-formula with approaches like Targeted Maximum Likelihood Estimation (TMLE) has enabled more efficient and robust causal effect estimation.\nOverall, the g-formula represents a major milestone in the evolution of causal inference, providing researchers with a powerful tool to estimate causal effects in complex observational settings. Its continued development and integration with modern statistical techniques ensure that it remains relevant in tackling pressing questions in public health and medicine.",
"crumbs": [
"G-Methods",
"<span class='chapter-number'>3</span> <span class='chapter-title'>G-formula</span>"
]
},
{
"objectID": "chapters/chapter3/index.html#contrast-between-conditional-and-marginal-estimates",
"href": "chapters/chapter3/index.html#contrast-between-conditional-and-marginal-estimates",
"title": "3 G-formula",
"section": "3.2 Contrast between conditional and marginal estimates",
"text": "3.2 Contrast between conditional and marginal estimates",
"crumbs": [
"G-Methods",
"<span class='chapter-number'>3</span> <span class='chapter-title'>G-formula</span>"
]
},
{
"objectID": "chapters/chapter3/index.html#effect-modification-collapsibility",
"href": "chapters/chapter3/index.html#effect-modification-collapsibility",
"title": "3 G-formula",
"section": "3.3 Effect modification, collapsibility",
"text": "3.3 Effect modification, collapsibility\n(HETMOR content)\nThe American Journal of Public Health’s series, “Evaluating Public Health Interventions,” provides highly practical advice for public health researchers. Part eight of this series offers a strong introduction to estimating the effects of time-invariant public health interventions. The authors of this particular article propose that modern causal inference methods offer no inherent advantage over traditional multivariable regression modeling when considering bias and efficiency.\nHowever, this assertion doesn’t always hold true. Specifically, the concepts of effect modification and collapsibility play crucial roles in determining the appropriateness of using regression for estimating causal effects. Understanding these concepts is essential for validating the use of regression in such analyses.\nCancer epidemiology example\nTo discuss these concepts, we are looking at an example from cancer epidemiology. In this example, we are interested in the effect of dual treatment therapy (radio- and chemotherapy), compared to single therapy (chemotherapy only) on the probability of one-year survival among colorectal cancer patients. We know that there are confounders which affect both treatment assignment and the outcome, namely clinical stage, socioeconomic status, comorbidities, and age. Evidence shows that older patients with comorbidities have a lower probability of being offered more aggressive treatments and therefore they usually get less effective curative options. Also, colorectal cancer patients from lower socioeconomic status have a higher probability of presenting an advanced clinical stage at diagnosis, thus they usually get offered only palliative treatments.\nOur structural assumptions in the cancer epidemiology example\nThe assumptions from above can be encoded in a directed acyclic graph (DAG) (Figure 1). Here, each circle represents a variable and an arrow from A to B (A -> B) means that we assume that A causes B. The combination of these structural assumptions and appropriate statistical methods allow us to estimate the causal effect of dual therapy versus monotherapy on colorectal cancer patients’ survival.\n\n\n\n\n\n\nFigure 3.1: Y: mortality binary indicator (1 death, 0 alive). A: binary treatment for cancer with chemotherapy versus dual therapy (0 Chemo, 1 Chemo + Radiotherapy). W: w1 (age), w2 (socioeconomic status), w3 (comorbidities), w4 (cancer stage [TNM classification]).\n\n\n\nA clinician may be interested in the following question: how different would the risk of death have been had everyone received dual therapy compared to if everyone had experienced monotherapy? The causal marginal odds ratio (MOR) answers this question. Statisticians call this a “target quantity”. Each individual has a pair of potential outcomes: the outcome they would have received had they been exposed to dual treatment (A=1), denoted Y(1), and the outcome had they been unexposed, Y(0). The MOR is defined as:\n\\[ MOR = \\frac{ \\frac{P(Y(1)=1)}{(1-P(Y(1)=1))} } { \\frac{P(Y(0)=1)}{(1-P(Y(0)=1))} } \\]\nA common approach would be to use logistic regression to model the odds of mortality given the intervention, and adjust for the confounders (W) which are age (W1), socioeconomic status (W2), clinical stage (W3), and comorbidities (W4). Note that using a logistic regression, it estimates the conditional odds ratio (COR), which is:\n\\[ COR = \\frac{ \\frac{P(Y=1|A=1,W)}{(1-P(Y=1|A=1,W))} } { \\frac{P(Y=1|A=0,W)}{(1-P(Y=1|A=0,W))} } \\]\nMOR and COR are typically not identical. First, if there is effect modification, e.g. if the effect of dual therapy is different for patients with no comorbidities compared to those having hypertension, then logistic regression (possibly including an interaction of treatment with one of the confounders) will not provide a marginal effect estimate, but only the conditional effect of the respective comorbidity (hypertension). To be more precise: we obtain an odds ratio that is valid for a given group of people, say those with hypertension, but it will not give us a marginal estimate. However, we are interested in a marginal estimate because we want to know if the dual therapy works in general. Of course, one may be specifically interested in patients with hypertension, but then the OR for this group is again conditional on the other variables, for example for elderly people, from a low socioeconomic level, and advanced stage.\nSecond, the odds ratio is non-collapsible which means that the MOR is not necessarily equal to the stratum-specific odds ratio (OR), i.e. the COR. This statement holds even when W is only related to the outcome, and not the intervention, and is thus not a confounder.[2,3] In fact, it is even possible that the conditional odds ratio shows a benefit of the intervention in every stratum, but no benefit overall, i.e. marginally. This case is known as Simpson’s paradox. We encourage the reader to read the below references 2 and 3 plus Judea Pearls’ new book, The Book of Why for more insights. Please note that while the odds ratio is non-collapsible, other measures of association like the risk-difference and the risk ratios are collapsible.\nMultivariable regression versus the G-Formula\nTo identify the MOR, classical epidemiologic methods, such as standard multivariable logistic regression models, where the treatment is included as a covariate in the analysis, require the assumption that the effect measure of the treatment of interest is constant across the levels of confounders included in the model.[4] However, in observational studies evaluating the effect of public health interventions, this is often not the case (i.e. the effect of the intervention might differ across individuals with different susceptibilities or characteristics). This is essentially the first point we made in the paragraph above. The second point says that certain effect measures, like the odds ratio, suffer from non-collapsibility.\nThus, in summary, as pointed out by Spiegelman et al [1] it can a be an option to use regression models to adjust for confounding; but we need to assume no effect modification and we need to choose a measure that is collapsible, like the risk difference, rather than the OR.\nAn alternative to using multivariable regression adjustment is the G-Formula [5] (a generalization of standardization with respect to the confounder distribution). In 1986, a seminal paper [5] demonstrated that under assumptions (conditional exchangeability, positivity, consistency, and non-interference, see Appendix below), a consistent estimate of the MOR can be obtained using the G-formula. G-computation,[6] based on the estimation of the components in the G-formula, allows for a treatment effect that may vary across the levels of the confounders. Furthermore, under the assumption that the DAG above (Figure 1) is correct and the other assumptions, we can estimate the MOR using the G-formula as follows:\n\\[ MOR (G-formula) = \\frac{ \\frac{\\Sigma_{w} P(Y=1|A=1,W=w)P(W=w)}{(1-\\Sigma_{w} P(Y=1|A=1,W=w)P(W=w))}\n}{ \\frac{\\Sigma_{w} P(Y=1|A=0,W=w)P(W=w)}{(1 - \\Sigma_{w} P(Y=1|A=0,W=w)P(W=w))}\n} \\]\nwhere P(W=w) refers to the marginal probability of W.\nMonte-Carlo simulation\nWe implement a Monte Carlo simulation based on the above population-based cancer epidemiology scenario and provide the R code for replication in this GitHub repository: https://github.com/migariane/HETMOR-Causal-Inference/blob/master/MonteCarloSimulation.r. As noted above, we are interested in how different the odds of death would have been had everyone received dual therapy compared to if everyone had experienced monotherapy. This is a relevant research question that, answered at a population level, may have an important public health implications for cancer patients.\nData generating process\nWe used the R-package simcausal [7] to generate data according to the DAG introduced above. The data are (W= (W1, W2, W3, W4), A, Y) where W1 refers to age, W2 to socioeconomic status, W3 to comorbidities, and W4 to cancer stage. The detailed setup can be found here (R script for simulation). In the outcome model, we included an interaction term between treatment A and both comorbidities (W2) and cancer stage (W4), based on the plausible biological mechanism that there is an increased risk of comorbidities among older adults and a different treatment effect for those patients with and without comorbidities and advanced cancer stage. The simulation is based on a sample size of 5,000, and 10,000 simulation runs. We estimate the bias with respect to the MOR. Figure 2 shows the results of the above described Monte Carlo simulation.\n\n\n\n\n\n\nFigure 3.2: Absolute bias with respect the marginal causal odds ratio comparing the conditional odds ratio from classical multivariable logistic regression models versus the marginal odds ratio from G-computation based on the G-Formula, n = 5,000 and 10,000 simulation runs.\n\n\n\nBriefly, one can see the bias of the multivariable logistic regression model is more pronounced under effect modification but persists - due to non-collapsibility - even under no effect modification.\nIn order to be able to consistently estimate the MOR, the data must satisfy the following assumptions [8]: i) Cancer treatment is independent of the potential mortality outcomes (Y(0), Y(1)) after conditioning on W. This assumption is often referred to as “conditional exchangeability” and one cannot test it using the observed data. It implies that (within the strata of W) the mortality risk under the potential treatment A=1, i.e. P(Y(1)=1|A=1,W) equals the one under treatment A=0, i.e. P(Y(1)=1|A=0,W). In other words: the risk of death for those treated would have been the same as for those untreated if untreated subjects had received, contrary to the fact, the treatment. This assumption requires that all confounders have been measured. ii) We also assume that within strata of W every patient had a nonzero probability of receiving either of the two treatment conditions, i.e. 0 <P(A=1|W)<1 (positivity). iii) We assume consistency, which states that the counterfactuals equal the observed data under assignment to the treatment actually taken, i.e. for any individual, Y = AY(1) + (1 - A)Y(0). Also, iv) in defining an individual’s counterfactual outcome as only a function of their own treatment, we assume non-interference, meaning that the counterfactual outcome of one subject was not influenced by the treatment of any other. If our estimate of the MOR is x (>1) then we can give, for example, an interpretation that says that the chances of one year mortality are x times higher if everyone had received dual treatment compared to if everyone had received single therapy.\nIn the previous section, we showed that causal estimates provide a generalization of indirect standardisation via the g-computation. In this chapter, we show how to obtain estimates using the g-formula. “Classical” methods are those based on the g-formula using regression methods and inverse probability weights in contrast to more advanced methods such as double-robust that were developed to overcome the issues with the previous methods.",
"crumbs": [
"G-Methods",
"<span class='chapter-number'>3</span> <span class='chapter-title'>G-formula</span>"
]
},
{
"objectID": "chapters/chapter3/index.html#non-parametric-g-formula",
"href": "chapters/chapter3/index.html#non-parametric-g-formula",
"title": "3 G-formula",
"section": "3.4 Non-parametric g-formula",
"text": "3.4 Non-parametric g-formula\nRegression adjustment is one of the classical methods to control for confounding. As mentioned before, regression models require certain assumptions to obtain the correct model specification. One of these is that the effect of the exposure is constant across levels of a confounder. In other words, we assume there is no effect modification.(Luque-Fernandez et al., 2019)\nThe non-parametric g-formula, also known as g-computation, is a method for estimating causal effects by standardizing the outcome distribution over the distribution of confounders. Unlike parametric approaches, it does not impose functional form assumptions on relationships between variables. Instead, it relies on empirical estimates of conditional probabilities. This makes it a flexible approach that can be used in various observational study settings where confounding is a concern. By weighting the treatment-specific outcome probabilities by the distribution of confounders in the overall population, the non-parametric g-formula provides an estimate of the marginal treatment effect.(Robins, 1986)\n\n3.4.1 Non-parametric g-formula for one confounder\nFor a binary treatment \\(A\\) and a binary outcome \\(Y\\), given a confounder \\(W\\), the non-parametric g-formula for the average treatment effect (ATE) is expressed as:\n\\[ ATE = \\sum_{w} \\left[ E(Y \\mid A = 1, W = w) - E(Y \\mid A = 0, W = w) \\right] P(W = w). \\]\nwhere\n\\[ E(Y = 1 \\mid A = a, \\textbf{W} = w) = \\frac{P(\\textbf{W} = w, A = a, Y = 1)}{\\sum_{y} P(\\textbf{W} = w, A = a, Y = y)} \\]\nis the conditional probability of the outcome \\(Y = 1\\), given the treatment \\(A = a\\), and the set of confounders = w.\nMore generally, for a vector of confounders \\(W\\), this can be written as:\n\\[ E[Y^a] = \\sum_{w} E[Y \\mid A = a, W = w] P(W = w), \\]\nand the ATE is defined as:\n\\[ ATE = E[Y^1] - E[Y^0]. \\]\nThe g-formula can also be used to estimate the average treatment effect among the treated (ATT) and among the untreated (ATU) by standardizing over different distributions of \\(W\\):\n\\[ ATT = \\sum_{w} \\left[ E(Y \\mid A = 1, W = w) - E(Y \\mid A = 0, W = w) \\right] P(W = w \\mid A = 1), \\] \\[ ATU = \\sum_{w} \\left[ E(Y \\mid A = 1, W = w) - E(Y \\mid A = 0, W = w) \\right] P(W = w \\mid A = 0). \\]\nThese quantities correspond to different policy questions. While the ATE estimates the effect of treatment if everyone were treated versus if no one were treated, the ATT and ATU estimate effects in subgroups based on actual treatment assignment.\nlibrary(dplyr)\n\nset.seed(123)\ndata <- data.frame(\n A = rbinom(1000, 1, 0.5),\n W = rbinom(1000, 1, 0.5),\n Y = rbinom(1000, 1, 0.5)\n)\n\ncond_probs <- data %>%\n group_by(A, W) %>%\n summarise(P_Y = mean(Y), .groups = 'drop')\n\np_W <- data %>%\n group_by(W) %>%\n summarise(P_W = n() / nrow(data), .groups = 'drop')\n\np_W1 <- data %>%\n filter(A == 1) %>%\n group_by(W) %>%\n summarise(P_W1 = n() / n(), .groups = 'drop')\n\np_W0 <- data %>%\n filter(A == 0) %>%\n group_by(W) %>%\n summarise(P_W0 = n() / n(), .groups = 'drop')\n\nate <- sum((cond_probs$P_Y[cond_probs$A == 1] -\n cond_probs$P_Y[cond_probs$A == 0]) * p_W$P_W)\n\natt <- sum((cond_probs$P_Y[cond_probs$A == 1] -\n cond_probs$P_Y[cond_probs$A == 0]) * p_W1$P_W1)\n\natu <- sum((cond_probs$P_Y[cond_probs$A == 1] -\n cond_probs$P_Y[cond_probs$A == 0]) * p_W0$P_W0)\n\ncat(\"ATE:\", round(ate, 3), \"\\n\")\ncat(\"ATT:\", round(att, 3), \"\\n\")\ncat(\"ATU:\", round(atu, 3), \"\\n\")\n\nBootstrap procedure for statistical inference\nSince the g-formula involves a multi-step estimation process–first estimating conditional means and then standardizing over a distribution of confounders–closed-form standard errors are generally not available.(Efron & Tibshirani, 1993) As such, the bootstrap is a practical alternative for estimating standard errors and constructing confidence intervals.(Efron, 1982; Efron & Tibshirani, 1993)\nThe bootstrap approximates the sampling distribution of an estimator by resampling the observed data with replacement and recalculating the estimator on each resampled dataset. From the distribution of the bootstrap replicates, one can compute the standard error as the sample standard deviation. Confidence intervals can be derived using different methods depending on the shape of the bootstrap distribution:\n\nNormal-based intervals assume approximate symmetry.\nPercentile intervals use the empirical quantiles of the bootstrap estimates.\nBias-corrected and accelerated (BCa) intervals correct for bias and skewness.\n\nThe choice of interval depends on the observed shape of the bootstrap distribution.(Jung et al., 2019) Histograms or density plots are often used to guide this choice.\n\n\nR Implementation\nlibrary(boot)\n\nbootstrap_ate <- function(data, indices) {\n boot_data <- data[indices, ]\n cond_probs <- boot_data %>%\n group_by(A, W) %>%\n summarise(P_Y = mean(Y), .groups = 'drop')\n p_W <- boot_data %>%\n group_by(W) %>%\n summarise(P_W = n() / nrow(boot_data), .groups = 'drop')\n sum((cond_probs$P_Y[cond_probs$A == 1] -\n cond_probs$P_Y[cond_probs$A == 0]) * p_W$P_W)\n}\n\nset.seed(123)\nboot_results <- boot(data, statistic = bootstrap_ate, R = 1000)\n\nboot.ci(boot_results, type = c(\"norm\", \"perc\", \"bca\"))\nThis approach provides a practical method for estimating uncertainty when using the non-parametric g-formula. The next section will introduce the parametric g-formula, which can offer computational advantages when the form of the outcome model is known or correctly specified.\n\n\n\n3.4.2 Non-parametric G-formula for a Fully Saturated Regression Model\nIn practice, the conditional expectations required by the non-parametric g-formula can be estimated using regression models. When the number of confounder strata is small and all confounders are categorical, a fully saturated regression model can be used to obtain a non-parametric estimate of the conditional mean of the outcome given treatment and confounders.\nA fully saturated model includes all main effects and interactions between the treatment variable and the confounders. For example, when both the treatment variable \\(A\\) and the confounder \\(W\\) are binary, a saturated logistic regression model is given by:\n\\[ \\text{logit}(P(Y = 1 \\mid A, W)) = \\beta_0 + \\beta_1 A + \\beta_2 W + \\beta_3 A \\cdot W. \\]\nThis model allows for effect modification by \\(W\\) and does not impose restrictions on the homogeneity of treatment effects across strata.\nAfter fitting the saturated model, the predicted probabilities \\(\\widehat{P}(Y = 1 \\mid A = a, W = w)\\) for each level of \\(W\\) can be used to estimate \\(E[Y^a]\\) through standardization. The non-parametric g-formula using the fitted regression model is:\n\\[ \\widehat{E}[Y^a] = \\sum_w \\widehat{P}(Y = 1 \\mid A = a, W = w) \\cdot \\widehat{P}(W = w), \\]\nand the average treatment effect (ATE) is then:\n\\[ \\widehat{ATE} = \\widehat{E}[Y^1] - \\widehat{E}[Y^0]. \\]\nThis approach is fully non-parametric in the sense that it does not rely on parametric assumptions beyond estimating a separate mean for each treatment-confounder stratum. The non-parametric g-formula can also incorporate complex parameters, such as interactions. When there is only one confounder, including an interaction term between the confounder and the exposure creates a fully-saturated model.\n\nR Implementation (Point Estimation)\nset.seed(123)\ndata <- data.frame(\n A = rbinom(1000, 1, 0.5),\n W = rbinom(1000, 1, 0.5),\n Y = rbinom(1000, 1, 0.5)\n)\n\n# Estimate P(W)\np_W <- data %>%\n group_by(W) %>%\n summarise(P_W = n() / nrow(data), .groups = 'drop')\n\n# Fit saturated logistic regression model\nsaturated_model <- glm(Y ~ A * W, data = data, family = binomial)\n\n# Create combinations of A and W\npred_data <- data.frame(\n A = rep(0:1, each = 2),\n W = rep(0:1, times = 2)\n)\n\n# Predict outcome probabilities\npred_data$P_Y <- predict(saturated_model, newdata = pred_data, type = \"response\")\n\n# Extract predicted values\np_y1 <- pred_data$P_Y[pred_data$A == 1]\np_y0 <- pred_data$P_Y[pred_data$A == 0]\n\n# Compute ATE\nate_saturated <- sum((p_y1 - p_y0) * p_W$P_W)\ncat(\"ATE (saturated model):\", round(ate_saturated, 3), \"\\n\")\n\n\nBootstrap Inference\nAs with other g-formula implementations, there is no closed-form variance expression for the ATE when using a fully saturated model. The bootstrap provides a practical approach for inference by approximating the sampling distribution of the ATE estimator.\nlibrary(boot)\n\n# Define bootstrap function\nbootstrap_saturated <- function(data, indices) {\n d <- data[indices, ]\n\n # Estimate P(W)\n p_W <- d %>%\n group_by(W) %>%\n summarise(P_W = n() / nrow(d), .groups = 'drop')\n\n # Fit saturated model\n saturated_model <- glm(Y ~ A * W, data = d, family = binomial)\n\n # Create prediction data\n pred_data <- data.frame(\n A = rep(0:1, each = 2),\n W = rep(0:1, times = 2)\n )\n\n # Predict probabilities\n pred_data$P_Y <- predict(saturated_model, newdata = pred_data, type = \"response\")\n p_y1 <- pred_data$P_Y[pred_data$A == 1]\n p_y0 <- pred_data$P_Y[pred_data$A == 0]\n\n # Compute ATE\n sum((p_y1 - p_y0) * p_W$P_W)\n}\n\n# Run bootstrap\nset.seed(123)\nboot_results_sat <- boot(data, statistic = bootstrap_saturated, R = 1000)\n\n# Confidence intervals\nboot.ci(boot_results_sat, type = c(\"norm\", \"perc\", \"bca\"))\nThe bootstrap allows researchers to obtain standard errors and confidence intervals that reflect the uncertainty inherent in estimating the conditional expectations and the marginalization process. As with all bootstrap methods, the validity of the inference depends on a sufficiently large sample size and adequate representation of variability in the observed data.\n\n\n\n3.4.3 Functional Delta Method for Confidence Intervals\nThe Delta method is a statistical approach to derive the SE of an asymptotically normally distributed estimator. It uses a first-order Taylor approximation, which is how we approximate the distribution of a function using a tangent line (i.e., the first derivative).(Oehlert, 1992) Therefore, using the Delta method here we assume that the ATE estimate from the G-computation is normally distributed.(Kennedy, 2016)\nWhile the bootstrap is a popular and flexible approach for estimating uncertainty in causal inference, it can be computationally intensive, especially when the estimator is complex or sample sizes are large. As an alternative, the functional delta method provides an analytic approximation to the standard error and confidence interval of an estimator. It is particularly useful when the quantity of interest can be expressed as a smooth function of sample statistics, such as sample means or proportions. The delta method avoids resampling by using a Taylor series approximation to quantify how uncertainty in the inputs propagates to the final estimate.\nThe functional delta method is an extension of the classical delta method, which provides a way to approximate the variance of a function of an estimator. Suppose we have an estimator \\(\\hat{\\theta}\\) that converges in distribution to a normal distribution, and we are interested in a function \\(g(\\hat{\\theta})\\). If \\(g(\\cdot)\\) is differentiable at \\(\\theta\\), then the delta method states:\n\\[ \\sqrt{n} \\left( g(\\hat{\\theta}) - g(\\theta) \\right) \\overset{d}{\\longrightarrow} \\mathcal{N}\\left(0, \\left[ g'(\\theta) \\right]^2 \\cdot \\sigma^2 \\right), \\]\nwhere \\(g'(\\theta)\\) is the derivative of \\(g\\) at \\(\\theta\\), and \\(\\sigma^2\\) is the asymptotic variance of \\(\\hat{\\theta}\\).\nIn the case of the g-formula, we are typically interested in the average treatment effect (ATE), defined as:\n\\[ ATE = \\sum_w \\left[ E(Y \\mid A = 1, W = w) - E(Y \\mid A = 0, W = w) \\right] P(W = w). \\]\nThis is a linear combination of conditional expectations \\(E(Y \\mid A = a, W = w)\\), each of which can be estimated using sample means and weighted by the marginal distribution of \\(W\\). Since the ATE is a linear function of these sample means, we can apply the delta method to approximate the variance of the estimated ATE.\nLet us denote: - \\(\\hat{\\mu}_{a,w} = \\hat{E}(Y \\mid A = a, W = w)\\): the estimated mean outcome for treatment group \\(a\\) and stratum \\(w\\) - \\(\\hat{p}_w = \\hat{P}(W = w)\\): the proportion of the sample in stratum \\(w\\)\nThe estimated ATE is:\n\\[ \\widehat{ATE} = \\sum_w \\left( \\hat{\\mu}_{1,w} - \\hat{\\mu}_{0,w} \\right) \\hat{p}_w. \\]\nSince this is a sum of estimated means times weights, its variance can be approximated using the delta method:\n\\[ \\text{Var}(\\widehat{ATE}) \\approx \\sum_w \\hat{p}_w^2 \\left[ \\text{Var}(\\hat{\\mu}_{1,w}) + \\text{Var}(\\hat{\\mu}_{0,w}) \\right]. \\]\nEach \\(\\hat{\\mu}_{a,w}\\) is a sample mean, and its variance can be estimated as:\n\\[ \\text{Var}(\\hat{\\mu}_{a,w}) \\approx \\frac{\\hat{\\sigma}^2_{a,w}}{n_{a,w}}, \\]\nwhere \\(\\hat{\\sigma}^2_{a,w}\\) is the sample variance of \\(Y\\) among individuals with \\(A = a\\) and \\(W = w\\), and \\(n_{a,w}\\) is the number of such individuals in the sample.\nThis approximation assumes that the sample means \\(\\hat{\\mu}_{1,w}\\) and \\(\\hat{\\mu}_{0,w}\\) are approximately independent across \\(w\\), and that the weights \\(\\hat{p}_w\\) are treated as fixed (i.e., not contributing to the variance).\n\nR Implementation\n# Estimate conditional means, variances, and sample sizes\nsummary_stats <- data %>%\n group_by(A, W) %>%\n summarise(\n mu = mean(Y),\n var = var(Y),\n n = n(),\n .groups = 'drop'\n )\n\n# Separate estimates by treatment group\nmu1 <- summary_stats %>% filter(A == 1) %>% arrange(W)\nmu0 <- summary_stats %>% filter(A == 0) %>% arrange(W)\n\n# Estimate P(W)\np_W <- data %>% group_by(W) %>% summarise(p = n() / nrow(data)) %>% arrange(W)\n\n# Estimate ATE\nate_delta <- sum((mu1$mu - mu0$mu) * p_W$p)\n\n# Estimate variance using delta method\nvar_ate <- sum((p_W$p^2) * ((mu1$var / mu1$n) + (mu0$var / mu0$n)))\nse_ate <- sqrt(var_ate)\n\n# Construct 95% confidence interval\nci_lower <- ate_delta - 1.96 * se_ate\nci_upper <- ate_delta + 1.96 * se_ate\n\ncat(\"ATE (delta method):\", round(ate_delta, 3), \"\\n\")\ncat(\"SE:\", round(se_ate, 3), \"\\n\")\ncat(\"95% CI:\", round(ci_lower, 3), \"-\", round(ci_upper, 3), \"\\n\")\nThe functional delta method offers a mathematically elegant way to obtain approximate standard errors and confidence intervals, particularly when the estimand is a smooth function of averages or proportions. It provides an efficient analytic alternative to resampling-based methods, though it requires some care in variance estimation and interpretation. When the conditions for applying the delta method are met, it can be a fast and accurate tool for inference in causal effect estimation.",
"crumbs": [
"G-Methods",
"<span class='chapter-number'>3</span> <span class='chapter-title'>G-formula</span>"
]
},
{
"objectID": "chapters/chapter3/index.html#parametric-g-formula",
"href": "chapters/chapter3/index.html#parametric-g-formula",
"title": "3 G-formula",
"section": "3.5 Parametric g-formula",
"text": "3.5 Parametric g-formula\nIn contrast to the nonparametric methods (i.e., probability distribution free or infinite dimensions), parametric methods are not affected by the curse of dimensionality.(Boos & Stefanski, 2013) However, to compute the ATE parametrically we have to assume there is a particular probability distribution that fits the distribution of our data.\n\n3.5.1 Parametric G-formula for One Confounder\nThe parametric g-formula is a version of g-computation that relies on specified parametric models to estimate the conditional expectation of the outcome given treatment and confounders. Whereas the non-parametric g-formula requires estimating these expectations separately in each stratum of the confounders, the parametric version uses a model–typically regression–to summarize the outcome distribution as a function of treatment and covariates. This approach is particularly useful when the number of confounders is large, or when the confounders are continuous, making non-parametric estimation impractical due to data sparsity.\nBy imposing a functional form, the parametric g-formula can borrow strength across covariate strata and improve efficiency, though at the cost of potential bias if the model is misspecified. The key idea is to fit a model for the conditional expectation (E[Y A, W]), and then use it to predict the potential outcomes under each treatment level (A = a) for every individual, followed by averaging over the empirical distribution of the covariates.\n\nEstimation Procedure\nSuppose we are interested in estimating the average treatment effect (ATE) of a binary treatment (A) on a binary outcome (Y), adjusting for a single binary confounder (W). Using the parametric g-formula, we proceed in two steps:\n\nModel the outcome: Fit a regression model, such as logistic regression, \\[ \\text{logit}(P(Y = 1 \\mid A, W)) = \\beta_0 + \\beta_1 A + \\beta_2 W + \\beta_3 A \\cdot W. \\] This model allows for an interaction between treatment and confounder to capture potential effect modification.\nStandardize over the population: Predict potential outcomes under \\(A = 1\\) and \\(A = 0\\) for each individual in the dataset, keeping \\(W\\) fixed at its observed value. Then, compute: \\[ \\widehat{E}[Y^1] = \\frac{1}{n} \\sum_{i=1}^n \\hat{E}[Y_i \\mid A = 1, W_i], \\quad \\widehat{E}[Y^0] = \\frac{1}{n} \\sum_{i=1}^n \\hat{E}[Y_i \\mid A = 0, W_i]. \\] The average treatment effect (ATE) is given by: \\[ \\widehat{ATE} = \\widehat{E}[Y^1] - \\widehat{E}[Y^0]. \\]\n\nThis procedure estimates what would happen if, counter to fact, everyone in the sample had received treatment ((A = 1)), and separately, what would have happened if everyone had received control ((A = 0)). The difference in these averages provides an estimate of the causal effect.\n\n\nR Implementation\nset.seed(123)\ndata <- data.frame(\n A = rbinom(1000, 1, 0.5),\n W = rbinom(1000, 1, 0.5),\n Y = rbinom(1000, 1, 0.5)\n)\n\n# Fit parametric model\nparam_model <- glm(Y ~ A * W, data = data, family = binomial)\n\n# Predict counterfactual outcomes\ndata1 <- data; data1$A <- 1\ndata0 <- data; data0$A <- 0\n\npred1 <- predict(param_model, newdata = data1, type = \"response\")\npred0 <- predict(param_model, newdata = data0, type = \"response\")\n\n# Estimate ATE\nate_param <- mean(pred1 - pred0)\ncat(\"ATE (parametric g-formula):\", round(ate_param, 3), \"\\n\")\nThis approach avoids the sparsity issues of non-parametric stratification and can handle continuous confounders or high-dimensional covariates by specifying appropriate models. However, it is crucial that the model for (E[Y A, W]) is correctly specified. Misspecification can lead to biased estimates of causal effects. For this reason, model diagnostics and robustness checks should be considered when using the parametric g-formula.\n\n\nBootstrap Inference\nIn the parametric g-formula, the ATE is computed by plugging model-based predictions into a functional expression. While the parametric model may provide valid point estimates, standard errors and confidence intervals derived from the model’s internal variance estimates do not account for the entire g-computation procedure, which includes both model fitting and marginalization steps. Therefore, model-based (analytic) standard errors can be misleading.\nThe bootstrap offers a solution by approximating the full sampling distribution of the ATE through repeated resampling. Each bootstrap replicate involves refitting the outcome model and re-estimating the ATE. The resulting distribution of ATEs captures uncertainty due to both the model fitting and the g-formula estimation process.\nlibrary(boot)\n\n# Define bootstrap function for parametric g-formula\nboot_parametric <- function(data, indices) {\n d <- data[indices, ]\n model <- glm(Y ~ A * W, data = d, family = binomial)\n d1 <- d; d1$A <- 1\n d0 <- d; d0$A <- 0\n pred1 <- predict(model, newdata = d1, type = \"response\")\n pred0 <- predict(model, newdata = d0, type = \"response\")\n mean(pred1 - pred0)\n}\n\n# Run bootstrap\nset.seed(123)\nboot_results <- boot(data, statistic = boot_parametric, R = 1000)\n\n# Confidence intervals\nboot.ci(boot_results, type = c(\"norm\", \"perc\", \"bca\"))\nBootstrap confidence intervals allow for inference that reflects the entire estimation procedure, making them particularly valuable in causal inference settings where estimators are functions of several estimated components.\n\n\n\n3.5.2 Parametric G-formula for Multiple Confounders\nWhen more than one confounder is present, the parametric g-formula remains applicable by fitting a model that includes the treatment, all confounders, and optionally interaction terms. This generalization is essential in real-world applications, where multiple covariates are needed to control for confounding.\nThe process involves fitting a model for the outcome as a function of treatment and confounders, then using this model to predict potential outcomes under both treatment and control for each individual in the sample. These predictions are then averaged to estimate \\(E[Y^1]\\) and \\(E[Y^0]\\), and the difference yields the average treatment effect (ATE).\nLet \\(W = (W_1, W_2, \\ldots, W_k)\\) be a set of \\(k\\) confounders. A typical logistic regression model for a binary outcome might be written as:\n\\[ \\text{logit}(P(Y = 1 \\mid A, W)) = \\beta_0 + \\beta_1 A + \\sum_{j=1}^k \\beta_{j+1} W_j + \\sum_{j=1}^k \\gamma_j A \\cdot W_j. \\]\nIn this model: - \\(\\beta_0\\) is the intercept, representing the baseline log-odds of the outcome when all predictors are zero. - \\(\\beta_1\\) is the main effect of treatment \\(A\\), adjusted for confounders. - \\(\\beta_{j+1}\\) represents the main effect of each confounder \\(W_j\\). - \\(\\gamma_j\\) captures the interaction between treatment and confounder \\(W_j\\), allowing the treatment effect to vary across levels of the confounder (i.e., effect modification).\nBy including both main effects and interaction terms, the model can flexibly account for how treatment effects may differ across confounder strata.\nAs before, the potential outcomes are predicted under both treatment levels and averaged across the population: \\[ \\widehat{E}[Y^a] = \\frac{1}{n} \\sum_{i=1}^n \\hat{E}[Y_i \\mid A = a, W_i], \\quad \\widehat{ATE} = \\widehat{E}[Y^1] - \\widehat{E}[Y^0]. \\]\n\nR Implementation (Multiple Confounders)\nset.seed(123)\ndata <- data.frame(\n A = rbinom(1000, 1, 0.5),\n W1 = rnorm(1000),\n W2 = rbinom(1000, 1, 0.4),\n W3 = sample(1:3, 1000, replace = TRUE)\n)\n\n# Generate outcome with some treatment effect and confounding\ndata$Y <- rbinom(1000, 1, plogis(-0.5 + 0.8 * data$A - 0.3 * data$W1 +\n 0.5 * data$W2 - 0.2 * (data$W3 == 2)))\n\n# Fit logistic regression with treatment, confounders, and interactions\nparam_model <- glm(Y ~ A * (W1 + W2 + factor(W3)), data = data, family = binomial)\n\n# Predict under treatment and control\ndata1 <- data; data1$A <- 1\ndata0 <- data; data0$A <- 0\n\npred1 <- predict(param_model, newdata = data1, type = \"response\")\npred0 <- predict(param_model, newdata = data0, type = \"response\")\n\n# Estimate ATE\nate_multi <- mean(pred1 - pred0)\ncat(\"ATE (multiple confounders):\", round(ate_multi, 3), \"\\n\")\nThis model can include both categorical and continuous covariates and their interactions with treatment. If the number of covariates is large or the model becomes overly complex, regularization (e.g., LASSO) or machine learning methods can be used to model \\(E[Y \\mid A, W]\\), though uncertainty estimation requires more advanced tools.\nIt is essential to use domain knowledge to decide which variables and interactions to include. Including unnecessary interaction terms may increase variance, while omitting important ones can introduce bias. As with simpler models, the results depend on the correctness of the model. Diagnostics such as those in Section 3.6.3 should be applied to assess model adequacy.\n\n\nBootstrap for Confidence Intervals\nAs with simpler cases, there is no closed-form variance for the ATE from the parametric g-formula with multiple confounders. Since the estimation involves both model fitting and standardization, model-based standard errors may not be valid. The bootstrap provides a practical solution.\nThe bootstrap resamples the data with replacement, refits the model in each resample, and recalculates the ATE. This gives an empirical sampling distribution of the ATE estimate. The standard deviation of the bootstrap estimates provides an estimate of the standard error, and confidence intervals can be derived using:\n\nNormal approximation – assumes bootstrap estimates are normally distributed.\nPercentile method – uses the 2.5% and 97.5% percentiles of the bootstrap estimates.\nBias-corrected and accelerated (BCa) – adjusts for bias and skewness in the bootstrap distribution.\n\nR Implementation:\nlibrary(boot)\n\n# Define bootstrap function\nboot_multi <- function(data, indices) {\n d <- data[indices, ]\n model <- glm(Y ~ A * (W1 + W2 + factor(W3)), data = d, family = binomial)\n d1 <- d; d1$A <- 1\n d0 <- d; d0$A <- 0\n pred1 <- predict(model, newdata = d1, type = \"response\")\n pred0 <- predict(model, newdata = d0, type = \"response\")\n mean(pred1 - pred0)\n}\n\n# Run bootstrap\nset.seed(123)\nboot_results_multi <- boot(data, statistic = boot_multi, R = 1000)\n\n# Display confidence intervals\nboot.ci(boot_results_multi, type = c(\"norm\", \"perc\", \"bca\"))\nThe bootstrap allows inference that reflects the full complexity of the g-computation procedure, making it an essential complement to the parametric g-formula when dealing with multiple confounders.\n\n\n\n3.5.3 Model Diagnostics and Robustness Checks\nBecause the validity of the parametric g-formula relies on the correct specification of the outcome model \\(E[Y \\mid A, W]\\), it is essential to assess the adequacy of the model. Several strategies can be used to evaluate model fit and robustness:\n\nAssess model fit: Use standard regression diagnostics such as the Hosmer-Lemeshow test, plots of observed vs predicted values, and residual analyses. Check calibration across strata of \\(A\\) and \\(W\\).\nCheck for non-linearity and interactions: For continuous covariates, consider using splines or polynomial terms. For categorical covariates, assess whether interactions with \\(A\\) are needed.\nEvaluate effect modification: Test whether the effect of \\(A\\) varies across levels of \\(W\\). Failing to include necessary interaction terms can bias the ATE.\nCompare with non-parametric estimates: If feasible, compare the parametric g-formula estimate with the non-parametric version. Discrepancies may indicate model misspecification.\nCross-validation: Use resampling methods such as \\(k\\)-fold cross-validation to assess the predictive performance and generalizability of the model.\nSensitivity analysis: Explore how the estimated ATE changes under alternative model specifications, such as omitting interaction terms or using different link functions.\n\nConducting thorough model diagnostics strengthens confidence in the parametric g-formula and helps avoid misleading causal inferences due to model misspecification. When diagnostics suggest lack of fit, more flexible methods–such as the non-parametric g-formula or targeted maximum likelihood estimation (TMLE)–may be warranted.",
"crumbs": [
"G-Methods",
"<span class='chapter-number'>3</span> <span class='chapter-title'>G-formula</span>"
]
},
{
"objectID": "chapters/chapter3/index.html#glossary",
"href": "chapters/chapter3/index.html#glossary",
"title": "3 G-formula",
"section": "3.6 Glossary",
"text": "3.6 Glossary\n\nDR methods\n\nDouble robust methods\n\n\n\n\n\n\nBoos, D. D., & Stefanski, L. A. (2013). Essential statistical inference: Theory and methods. Springer.\n\n\nEfron, B. (1982). The jackknife, the bootstrap and other resampling plans (Vol. 38). SIAM.\n\n\nEfron, B., & Tibshirani, R. (1993). An introduction to the bootstrap (Vol. 57). Chapman & Hall. http://www.loc.gov/catdir/enhancements/fy0730/93004489-d.html\n\n\nJung, K., Lee, J., Gupta, V., & Cho, G. (2019). Comparison of bootstrap confidence interval methods for GSCA using a monte carlo simulation. Frontiers in Psychology, 10, 2215. https://doi.org/10.3389/fpsyg.2019.02215\n\n\nKennedy, E. H. (2016). Semiparametric theory and empirical processes in causal inference (pp. 141–167). Springer.\n\n\nLuque-Fernandez, M. A., Redondo-Sanchez, D., & Schomaker, M. (2019). Effect modification and collapsibility in evaluations of public health interventions. American Journal of Public Health, 109(3), e12–e13. https://doi.org/10.2105/AJPH.2018.304916\n\n\nOehlert, G. W. (1992). A note on the delta method. American Statistician, 46(1), 27–29. https://doi.org/10.1080/00031305.1992.10475842\n\n\nRobins, J. (1986). 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(9), 1393–1512. https://doi.org/https://doi.org/10.1016/0270-0255(86)90088-6",
"crumbs": [
"G-Methods",
"<span class='chapter-number'>3</span> <span class='chapter-title'>G-formula</span>"
]
},
{
"objectID": "chapters/chapter4/index.html",
"href": "chapters/chapter4/index.html",
"title": "4 Methods Based on the Propensity Score",
"section": "",
"text": "4.1 Introduction\nIn observational studies, estimating causal effects is complicated by the presence of confounding—systematic differences in baseline characteristics between treatment groups. While one approach to adjusting for confounding is through outcome modeling (e.g., the g-formula), an alternative strategy involves balancing the distribution of confounders between treatment groups. This is the central idea behind propensity score methods.\nThe propensity score, introduced by (Rosenbaum & Rubin, 1983), is defined as the probability of receiving the treatment given a set of observed covariates: \\[\ne(W) = P(A = 1 \\mid W),\n\\] where \\(A\\) is the binary treatment indicator and \\(W\\) is a vector of observed covariates. The key insight is that, under certain assumptions, conditioning on the propensity score is sufficient to control for confounding. Specifically, if treatment assignment is strongly ignorable given the covariates \\(W\\), then it is also ignorable given the scalar quantity \\(e(W)\\). That is: \\[\nY^0, Y^1 \\perp A \\mid e(W),\n\\] where \\(Y^0\\) and \\(Y^1\\) are the potential outcomes under control and treatment, respectively.\nThis property makes the propensity score a powerful tool: it allows us to reduce a potentially high-dimensional confounding problem into a one-dimensional balancing problem. By adjusting for the propensity score—rather than all covariates directly—we can remove confounding bias due to observed covariates, provided certain conditions are met.\nIn settings with multiple confounders, the validity of the propensity score relies heavily on correctly modeling the propensity score. In a perfectly randomized experiment, exchangeability is inherent due to the randomization process. However, in an observational study, conditional exchangeability can only be assumed if all confounders have been accurately captured by the propensity score. To fully exploit this conditional exchangeability, the propensity score, which is inherently unknown, must be appropriately modeled using the available data.\nIn this chapter, we explore the range of methods built upon the propensity score. These include: - Matching, where treated and control individuals with similar propensity scores are compared; - Stratification, where the data are divided into strata (e.g., quintiles) of the propensity score and comparisons are made within strata; - Covariate adjustment using the propensity score, where the score is included as a covariate in a regression model; - Inverse probability of treatment weighting (IPTW), which uses the propensity score to create a pseudo-population in which treatment is independent of covariates; - And doubly robust estimators, which combine propensity score modeling with outcome modeling.\nEach method has strengths and limitations. Unlike outcome modeling approaches such as the g-formula, propensity score methods do not rely on specifying the correct model for the outcome. Instead, they shift the modeling burden to the treatment assignment mechanism. This can be advantageous when the outcome is difficult to model, but it also introduces new challenges, including the need for careful diagnostic checks and attention to positivity and overlap.\nIn the sections that follow, we describe each of these methods in detail, illustrate them with examples and code, and provide guidance on when and how to apply them in practice.",
"crumbs": [
"G-Methods",
"<span class='chapter-number'>4</span> <span class='chapter-title'>Methods Based on the Propensity Score</span>"
]
},
{
"objectID": "chapters/chapter4/index.html#sec-ps-ps",
"href": "chapters/chapter4/index.html#sec-ps-ps",
"title": "4 Methods Based on the Propensity Score",
"section": "4.2 The Propensity Score",
"text": "4.2 The Propensity Score\n\n4.2.1 Key Properties of the Propensity Score\nThe usefulness of the propensity score in causal inference stems from a set of key theoretical properties. These properties justify the use of the propensity score as a balancing score and support its role in adjusting for confounding in observational studies.\n\n\n4.2.2 The Balancing Property\nThe fundamental property of the propensity score is its ability to balance covariates between treated and untreated individuals. Formally, for individuals with the same value of the propensity score, the distribution of observed covariates \\(W\\) is independent of treatment assignment \\(A\\). That is,\n\\[\nA \\perp W \\mid e(W),\n\\]\nwhere \\(e(W) = P(A = 1 \\mid W)\\). This means that within strata of the propensity score, the treated and untreated groups are expected to have similar distributions of baseline covariates. This balancing property is essential, as it enables causal comparisons by mimicking the balance achieved through randomization.\n\n\n4.2.3 Unconfoundedness Given the Propensity Score\nIf the potential outcomes are independent of treatment assignment conditional on covariates—that is,\n\\[\nY^0, Y^1 \\perp A \\mid W,\n\\]\nthen this also holds conditional on the propensity score:\n\\[\nY^0, Y^1 \\perp A \\mid e(W).\n\\]\nThis result, sometimes called the strong ignorability given the propensity score, implies that adjusting for the propensity score alone is sufficient to remove confounding bias due to measured covariates, under the assumption that all confounders are included in \\(W\\).\n\n\n4.2.4 Common Support and Positivity\nFor propensity score methods to be valid, there must be sufficient overlap in the distribution of the propensity score between the treated and untreated groups. This is known as the common support or overlap condition. Formally, for every value of the covariates \\(W\\), we require:\n\\[\n0 < P(A = 1 \\mid W) < 1.\n\\]\nThis assumption, known as positivity, ensures that each individual has a positive probability of receiving both treatment and control, given their covariates. If some individuals are deterministically treated or untreated based on their covariates, causal effects for those individuals are not identifiable.\nIn practice, violations of positivity are detected when there are extreme propensity scores close to 0 or 1. These lead to practical issues such as poor covariate balance and unstable estimates, particularly in weighting-based methods like IPTW.\n\n\n4.2.5 Bias–Variance Trade-off in Propensity Score Methods\nPropensity score methods often involve a trade-off between bias and variance. For example, narrowing the matching caliper or stratifying into more finely grained subclasses can reduce bias but may also increase variance due to smaller effective sample sizes. Conversely, wider matches or coarser stratification increase the sample size but risk residual confounding.\nThe choice of propensity score method (e.g., matching, stratification, weighting) and implementation details (e.g., number of strata, use of replacement in matching) should be guided by diagnostics such as covariate balance measures and sensitivity analyses.\n\n\n4.2.6 Estimating the Propensity Score\nThe first step in applying propensity score methods is to estimate the propensity score—defined as the probability of receiving the treatment, given observed covariates:\n\\[\ne(W) = P(A = 1 \\mid W).\n\\]\nIn practice, this conditional probability is not known and must be estimated from the data. The choice of model for estimating the propensity score is crucial, as all subsequent causal inferences depend on its quality. An incorrectly specified propensity score model may result in poor covariate balance and biased effect estimates, even if the methods used afterward are correctly implemented.\n\n\n4.2.7 Logistic Regression\nThe most common method for estimating the propensity score is logistic regression. In this approach, the treatment assignment \\(A \\in \\{0,1\\}\\) is modeled as a function of the covariates \\(W\\):\n\\[\n\\text{logit}(P(A = 1 \\mid W)) = \\alpha_0 + \\alpha_1 W_1 + \\alpha_2 W_2 + \\cdots + \\alpha_k W_k.\n\\]\nThis yields a predicted probability for each individual of receiving the treatment, given their covariate profile. Logistic regression has the advantages of being interpretable, familiar, and easy to implement, and it often performs adequately when the number of confounders is moderate and their relationships with treatment are roughly linear on the logit scale.\nHowever, model misspecification is a risk. Important interactions or non-linearities may be missed unless explicitly included. Therefore, flexible modeling and diagnostic checks are essential.\n\n\n4.2.8 Machine Learning Approaches\nAs an alternative to parametric models, machine learning algorithms can be used to estimate the propensity score in a more flexible, data-adaptive way. These include:\n\nClassification trees and random forests\nGradient boosting machines (e.g., XGBoost)\nNeural networks\nGeneralized additive models\nEnsemble learners (e.g., Super Learner)\n\nMachine learning methods can capture complex, non-linear relationships and interactions among covariates without the need to specify them manually. This can improve covariate balance and reduce bias. However, these methods may overfit or produce propensity scores near 0 or 1, which can lead to unstable weights in IPTW.\nFor this reason, ensemble methods like Super Learner—which combine multiple candidate models via cross-validation—are increasingly used in modern causal inference to improve robustness and predictive performance.\n\n\n4.2.9 Model Checking and Covariate Balance\nRegardless of the estimation method, it is essential to evaluate whether the resulting propensity score model achieves covariate balance between the treated and control groups. The ultimate goal is not predictive accuracy of treatment assignment but rather balance of covariates conditional on the propensity score.\nDiagnostics include:\n\nStandardized mean differences for each covariate before and after adjustment\nHistograms or density plots of propensity scores by treatment group\nPlots of balance vs. propensity score strata or quantiles\n\nA good model may not perfectly predict treatment but should result in well-balanced covariates across treatment groups in the adjusted (pseudo-)population. If balance is poor, the model may need to be refit, potentially adding interaction terms, non-linear terms (e.g., splines), or trying a more flexible estimation method.\nIn summary, the estimation of the propensity score is not a purely predictive task—it is a causal modeling task aimed at achieving balance to support unbiased estimation of treatment effects.",
"crumbs": [
"G-Methods",
"<span class='chapter-number'>4</span> <span class='chapter-title'>Methods Based on the Propensity Score</span>"
]
},
{
"objectID": "chapters/chapter4/index.html#sec-ps-methods",
"href": "chapters/chapter4/index.html#sec-ps-methods",
"title": "4 Methods Based on the Propensity Score",
"section": "4.3 Methods Using the Propensity Score",
"text": "4.3 Methods Using the Propensity Score\n\n4.3.1 Matching on the Propensity Score\nMatching is one of the most commonly used propensity score methods. The idea is to pair treated and control individuals with similar values of the estimated propensity score, so that comparisons are made between units with similar covariate distributions. Matching aims to recreate a pseudo-randomized experiment by ensuring that treatment and control groups are balanced on observed covariates.\n\nNearest Neighbor Matching\nIn nearest neighbor matching, each treated individual is matched to one or more control individuals whose estimated propensity score is closest in absolute value. The most basic form is 1:1 matching without replacement, although other ratios (e.g., 1:2, 1:k) are possible.\nThis method is intuitive and easy to implement but may result in poor matches if the propensity score distributions between groups do not overlap well.\nR Example:\nlibrary(MatchIt)\n\n# Simulate data\ndata <- data.frame(\n A = rbinom(1000, 1, 0.5),\n W1 = rnorm(1000),\n W2 = rbinom(1000, 1, 0.4)\n)\ndata$ps <- glm(A ~ W1 + W2, data = data, family = binomial)$fitted.values\n\n# Perform nearest neighbor matching\nmatch_nn <- matchit(A ~ W1 + W2, data = data, method = \"nearest\")\nsummary(match_nn)\nmatched_data <- match.data(match_nn)\n\n\nCaliper and Radius Matching\nCaliper matching imposes a maximum allowable distance (caliper) between the propensity scores of matched pairs. This reduces the risk of poor matches by ensuring that treated units are only matched to controls with sufficiently similar scores.\nRadius matching generalizes this idea by allowing each treated individual to be matched with all controls within the caliper range.\nR Example (Caliper Matching):\nmatch_caliper <- matchit(A ~ W1 + W2, data = data,\n method = \"nearest\", caliper = 0.2)\nsummary(match_caliper)\n\n\nMatching with or without Replacement\nIn matching with replacement, a control unit can be used as a match for more than one treated unit. This is especially useful when the number of treated and control units is highly imbalanced or when the overlap in propensity scores is limited.\nMatching without replacement restricts each control to be used only once. This may yield less optimal matches but preserves a more diverse control group.\nR Example (With Replacement):\nmatch_wr <- matchit(A ~ W1 + W2, data = data, method = \"nearest\", replace = TRUE)\nsummary(match_wr)\n\n\nCovariate Balance Diagnostics\nAfter matching, it is essential to assess whether covariates are balanced between treatment groups. Standardized mean differences (SMDs) are commonly used for this purpose. A typical threshold for acceptable balance is an absolute SMD less than 0.1.\nR Example (Covariate Balance):\nplot(summary(match_nn), type = \"qq\") # Balance plot\nOther diagnostics include: - Histograms or density plots of propensity scores - Love plots of standardized differences - Covariate-specific p-values (with caution)\n\n\nEstimating Treatment Effects after Matching\nOnce matching is complete and balance is assessed, the treatment effect can be estimated by comparing outcomes between matched treated and control units. For 1:1 matching, a paired difference in means is often used:\n\\[\n\\widehat{ATT} = \\frac{1}{n_t} \\sum_{i \\in \\text{treated}} \\left(Y_i - Y_{j(i)}\\right),\n\\]\nwhere \\(Y_i\\) is the outcome for treated unit \\(i\\) and \\(Y_{j(i)}\\) is the outcome of the matched control.\nR Example (Estimating ATT):\nmatched_data <- match.data(match_nn)\nmean(matched_data$Y[matched_data$A == 1]) -\n mean(matched_data$Y[matched_data$A == 0])\nBootstrapping is often used to estimate confidence intervals post-matching since standard variance formulas may not be valid in the matched sample.\nSummary: Matching on the propensity score is a flexible, intuitive approach to reduce confounding. Success depends on overlap in propensity scores and careful attention to post-matching diagnostics.\n\n\n\n4.3.2 Stratification (or Subclassification)\nStratification, also known as subclassification, is a propensity score method that involves dividing the study population into strata (or subclasses) based on quantiles of the estimated propensity score. Within each stratum, the treated and control groups are compared directly. This method reduces confounding by ensuring that comparisons are made between subjects with similar covariate distributions.\n\nForming Strata by Propensity Score Quantiles\nThe most common approach is to divide the range of the estimated propensity score into quintiles (i.e., five equally sized groups). This aims to create approximately homogeneous groups within which treatment assignment is as-if random.\ndata$pscore <- glm(A ~ W1 + W2, data = data, family = binomial)$fitted.values\n\n# Create strata (quintiles)\ndata$stratum <- cut(data$pscore,\n breaks = quantile(data$pscore, probs = seq(0, 1, 0.2)),\n include.lowest = TRUE, labels = FALSE)\ntable(data$stratum, data$A)\nMore or fewer strata can be used depending on the sample size. Rosenbaum and Rubin (1984) showed that stratification into five strata typically removes about 90% of the bias due to confounding.\n\n\nEffect Estimation within Strata\nOnce strata are formed, treatment effects are estimated within each stratum separately. For example, within each stratum \\(s\\), the average treatment effect can be computed as: \\[\n\\widehat{ATE}_s = \\bar{Y}^1_s - \\bar{Y}^0_s,\n\\] where \\(\\bar{Y}^1_s\\) and \\(\\bar{Y}^0_s\\) are the average outcomes among treated and control units within stratum \\(s\\), respectively.\nby(data, data$stratum, function(df) {\n mean(df$Y[df$A == 1]) - mean(df$Y[df$A == 0])\n})\nIf the outcome is binary, logistic regression can also be used within each stratum to estimate risk differences, risk ratios, or odds ratios.\n\n\nAggregating Across Strata\nThe overall average treatment effect is computed by aggregating the stratum-specific effects, weighting by the proportion of the population in each stratum: \\[\n\\widehat{ATE} = \\sum_{s=1}^S \\widehat{ATE}_s \\times \\frac{n_s}{n},\n\\] where \\(n_s\\) is the number of individuals in stratum \\(s\\) and \\(n\\) is the total sample size.\nlibrary(dplyr)\nagg_ate <- data %>%\n group_by(stratum) %>%\n summarise(\n n = n(),\n ate = mean(Y[A == 1]) - mean(Y[A == 0])\n ) %>%\n summarise(weighted_ate = sum(ate * n / sum(n)))\nagg_ate\nThis estimator approximates the marginal ATE, provided that each stratum contains both treated and control individuals.\n\n\nAssessing Balance within Strata\nTo evaluate whether stratification has successfully balanced covariates, one should assess covariate balance within each stratum. This can be done by calculating standardized mean differences (SMDs) between treated and control groups within each stratum.\nlibrary(tableone)\nCreateTableOne(vars = c(\"W1\", \"W2\"), strata = \"stratum\", data = data, factorVars = \"A\")\nVisual tools such as Love plots can also be used to summarize covariate balance across all strata.\nSummary: Stratification is an intuitive and accessible method to adjust for confounding using the propensity score. Its simplicity and transparency make it particularly useful in moderate sample sizes, although bias can remain if strata are not sufficiently homogeneous.\n\n\n\n4.3.3 Covariate Adjustment Using the Propensity Score\nAn alternative to matching, stratification, or weighting is to include the propensity score directly as a covariate in a regression model for the outcome. This method is sometimes referred to as “covariate adjustment using the propensity score.” It involves modeling the outcome as a function of both the treatment and the estimated propensity score.\n\nPropensity Score as a Covariate in Regression\nIn this approach, the outcome \\(Y\\) is modeled as: \\[\nE[Y \\mid A, e(W)] = f(A, e(W)),\n\\] where \\(e(W)\\) is the estimated propensity score. A typical implementation for a continuous outcome is a linear regression model: \\[\nY_i = \\beta_0 + \\beta_1 A_i + \\beta_2 \\hat{e}(W_i) + \\varepsilon_i,\n\\] and for a binary outcome, a logistic regression model: \\[\n\\text{logit}(P(Y_i = 1)) = \\beta_0 + \\beta_1 A_i + \\beta_2 \\hat{e}(W_i).\n\\] The coefficient \\(\\beta_1\\) captures the association between treatment and outcome, adjusted for the propensity score.\nThis method reduces the dimensionality of adjustment: instead of adjusting for all covariates in \\(W\\), one adjusts for a scalar summary, \\(\\hat{e}(W)\\). However, it is not guaranteed to produce unbiased estimates of the average treatment effect (ATE), especially when the outcome model is misspecified.\nR Example:\n# Estimate propensity scores\nps_model <- glm(A ~ W1 + W2, data = data, family = binomial)\ndata$pscore <- ps_model$fitted.values\n\n# Outcome model using propensity score as a covariate\noutcome_model <- lm(Y ~ A + pscore, data = data)\nsummary(outcome_model)\nFor binary outcomes:\n# Logistic regression\nlogit_model <- glm(Y ~ A + pscore, data = data, family = binomial)\nsummary(logit_model)\nThis method can be sensitive to misspecification of the outcome model. For example, if \\(e(W)\\) has a non-linear relationship with \\(Y\\), then modeling it linearly may yield biased estimates.\n\n\nComparison with Outcome Modeling\nCovariate adjustment using the propensity score differs from traditional outcome modeling (also known as regression adjustment) in that it replaces the vector of covariates \\(W\\) with a scalar summary, \\(e(W)\\). In standard outcome regression, the model is: \\[\nY_i = \\beta_0 + \\beta_1 A_i + \\boldsymbol{\\beta}_2^T W_i + \\varepsilon_i.\n\\]\nThis method directly adjusts for all confounders, assuming the model for \\(E[Y \\mid A, W]\\) is correctly specified. While it allows more flexibility in modeling covariates, it also suffers more severely from curse of dimensionality and collinearity.\nIn contrast, adjusting for \\(e(W)\\) reduces the covariate adjustment to a single dimension. However, it does not offer the same level of protection against confounding, especially in the presence of effect modification, non-linear relationships, or heterogeneous treatment effects.\nKey differences: - Dimensionality: Propensity score adjustment uses a scalar summary, reducing complexity. - Model dependency: Traditional regression depends heavily on correct specification of the full outcome model; PS adjustment relies more on correct treatment model. - Interpretation: Coefficients from PS-adjusted models estimate conditional treatment effects, not marginal ATEs.\nAlthough less commonly used in modern practice due to its sensitivity to model misspecification and weaker performance in finite samples, covariate adjustment using the propensity score remains a useful tool in situations with limited overlap or when other methods are infeasible.\nFor improved performance, this method is often used in conjunction with doubly robust estimators, as discussed in later sections.\n\n\n\n4.3.4 Inverse Probability of Treatment Weighting (IPTW)\nInverse Probability of Treatment Weighting (IPTW) is a propensity score-based method that reweights the sample to create a pseudo-population in which treatment assignment is independent of baseline covariates. This allows for the estimation of causal effects by comparing outcomes between weighted treatment groups.\nIn observational studies, some individuals will be more likely than others to be treated (A=1) due to their characteristics. Suppose some individuals who were treated were unlikely to be treated based on a specific set of features encapsulated in a particular vector of confounders (W). To balance the differences in characteristics between treatment groups, we re-weight the outcome variable of these individuals by the inverse of their probability of the treatment (A) actually received (i.e., propensity score). Originally, the weights were motivated from the classical Horvitz and Thompson survey estimator used to re-weight the outcome variable by the inverse probability that it is observed, thus accounting for the sampling process.(Horvitz & Thompson, 1952) The result of this weighting procedure is that, among the treated we up-weight those who had a low probability of being treated, and among the untreated we up-weight those who were unlikely to be untreated; that is, the individuals underrepresented in their treatment group. As a consequence, the weighted set of data is unchanged apart from A and W are now conditionally independent. Therefore, a comparison of \\(Y_{w}(1)\\) to \\(Y_{w}(0)\\) gives a marginal causal effect under the three identification assumptions (Appendix 1) whilst also assuming the propensity score model is correctly specified. The inverse probability of treatment weighting (IPTW), and the g-formula when targeting the same estimand (i,e., the ATE), are equivalent in the nonparametric setting.(Robins, 1986; Rosenbaum & Rubin, 1983) We provide a proof of the equivalence between IPTW and G-computation procedures using the law of total expectation.\n\\[\n\\begin{aligned}\n& \\underbrace{E\\left(\\frac{{I}(a = 1)}{P(A=1 \\mid \\boldsymbol{W})}\\,Y\\right)}_{IPTW} \\,=\\, \\\\\n & \\text{By definition of expectations...} \\\\\n &=\\, \\sum_{w,a,y} \\frac{I(a=1)}{P(A=1|W=w)} \\, y \\, P(Y=y,A=a,W=w) \\\\\n & \\\\\n & \\text{By the law of total probability...} \\\\\n &=\\, \\sum_{w,a,y} \\frac{I(a=1)}{P(A=1\\,|\\,W=w)} \\, y \\, P(Y=y\\, | \\,A=a,W=w) \\, P(A=a\\,|\\,W=w) \\, P(W=w) \\\\\n & \\\\\n & \\text{Cancellation by evaluating at A=1...} \\\\\n &=\\, \\sum_{w,y} \\,y\\, P(Y=y\\,|\\,A=1,W=w)\\,P(W=w) \\\\\n & \\\\\n & \\text{By definition of expectations...} \\\\\n &=\\, \\sum_{w} E(Y\\,|\\,A=1,W=w)\\,P(W=w) \\\\\n & \\\\\n & \\text{Finally, again by definition of expectations...} \\\\\n &=\\, \\underbrace{E[E(Y\\,|\\,A=1,W)]}_{G-computation}\n\\end{aligned}\n\\]\nDeparting from the identification assumptions of the ATE for the regression adjustment G-computation estimand (ATE = \\(E_{w}(E(Y|A=1,\\textbf{W}) - E_{w}(Y|A=0,\\textbf{W})\\)), we can rewrite the same estimand as a function of the distribution of A given W (i.e., \\(P(A = 1|\\textbf{W})\\), a.k.a propensity score or treatment mechanism).\nTherefore, the estimator is given by\n\\[\n\\text{ATE}\\,=\\,\\frac{1}{n}\\sum^{n}_{i=1}\\left(\\frac{A_{i}}{P(A_{i}=1\\mid\\boldsymbol{W}_{i})}\\,-\\,\\frac{1\\,-\\,A_{i}}{(1\\,-\\,P(A_{i}=1\\mid\\boldsymbol{W}_{i}))}\\right)Y_{i}.\n\\tag{4.1}\\]\n\nDefining Weights for ATE, ATT, and ATU\nThe basic idea of IPTW is to weight each individual by the inverse of the probability of receiving the treatment they actually received. These weights depend on the estimand of interest:\n\nAverage Treatment Effect (ATE): \\[\nw_i^{ATE} = \\begin{cases}\n\\frac{1}{\\hat{e}(W_i)} & \\text{if } A_i = 1, \\\\\n\\frac{1}{1 - \\hat{e}(W_i)} & \\text{if } A_i = 0.\n\\end{cases}\n\\]\nAverage Treatment Effect on the Treated (ATT): \\[\nw_i^{ATT} = \\begin{cases}\n1 & \\text{if } A_i = 1, \\\\\n\\frac{\\hat{e}(W_i)}{1 - \\hat{e}(W_i)} & \\text{if } A_i = 0.\n\\end{cases}\n\\]\nAverage Treatment Effect on the Untreated (ATU): \\[\nw_i^{ATU} = \\begin{cases}\n\\frac{1 - \\hat{e}(W_i)}{\\hat{e}(W_i)} & \\text{if } A_i = 1, \\\\\n1 & \\text{if } A_i = 0.\n\\end{cases}\n\\]\n\nR Example (ATE Weights):\nps_model <- glm(A ~ W1 + W2, data = data, family = binomial)\ndata$pscore <- ps_model$fitted.values\n\ndata$weight_ate <- ifelse(data$A == 1,\n 1 / data$pscore,\n 1 / (1 - data$pscore))\n\n\nStabilized vs. Unstabilized Weights\nThere is a modified version of the IPTW estimator (Equation 4.1) consisting of stabilised weights proposed by (Hajek1971CommentEds?), which is more commonly used in practice when treatment and exposure vary over time (i.e., time dependent confounding). Stabilised weights should have a mean of 1, but some values could be higher (i.e., large weights). Unstabilized weights can sometimes have large variability, particularly when propensity scores are close to 0 or 1. Stabilized weights help mitigate this by multiplying the numerator of the weight by the marginal probability of treatment:\n\\[\nw_i^{stab} = \\begin{cases}\n\\frac{P(A = 1)}{\\hat{e}(W_i)} & \\text{if } A_i = 1, \\\\\n\\frac{P(A = 0)}{1 - \\hat{e}(W_i)} & \\text{if } A_i = 0.\n\\end{cases}\n\\]\nThe stabilised version of the IPTW estimator is given by\n\\[\n\\text{ATE} \\,=\\,\\frac{\\sum\\left(\\frac{AY}{P(A=1\\mid\\boldsymbol{W})}\\right)}{\\sum\\left(\\frac{A}{P(A=1\\mid\\boldsymbol{W})}\\right)}\\,-\\,\\frac{\\sum\\left(\\frac{(1\\,-\\,A)Y}{1\\,-\\,P(A=1\\mid\\boldsymbol{W})}\\right)}{\\sum\\left(\\frac{(1\\,-\\,A)}{1\\,-\\,P(A=1\\mid\\boldsymbol{W})}\\right)}.\n\\]\nR Example (Stabilized ATE Weights):\np_A <- mean(data$A == 1)\ndata$stab_weight <- ifelse(data$A == 1,\n p_A / data$pscore,\n (1 - p_A) / (1 - data$pscore))\n\n\nDealing with Extreme Weights\nExtreme weights occur when estimated propensity scores are close to 0 or 1, leading to instability and large variances. Strategies to manage this include: - Truncation: Cap weights at a specified percentile (e.g., 1st and 99th percentiles). - Weight trimming: Exclude individuals with weights above a certain threshold. - Use of stabilized weights: As previously shown. - Improved PS estimation: Use flexible models (e.g., machine learning) to improve PS estimates.\nR Example (Weight Truncation):\n# Truncate at 1st and 99th percentiles\nlower <- quantile(data$weight_ate, 0.01)\nupper <- quantile(data$weight_ate, 0.99)\ndata$trunc_weight <- pmin(pmax(data$weight_ate, lower), upper)\n\n\nVariance Estimation for IPTW\nVariance estimation for IPTW estimators can be challenging due to the complex structure of the weights. Common approaches include:\n\nRobust (sandwich) standard errors: Often used when fitting weighted regression models.\nBootstrap: Resample individuals and re-estimate the treatment effect in each sample.\n\nR Example (Weighted Regression with Robust SEs):\nlibrary(sandwich)\nlibrary(lmtest)\n\n# Weighted regression\nfit <- lm(Y ~ A, data = data, weights = data$stab_weight)\ncoeftest(fit, vcov = vcovHC(fit, type = \"HC0\"))\nR Example (Bootstrap):\nlibrary(boot)\n\nboot_iptw <- function(data, indices) {\n d <- data[indices, ]\n fit <- lm(Y ~ A, data = d, weights = d$stab_weight)\n coef(fit)[\"A\"]\n}\n\nboot(data, boot_iptw, R = 1000)\n\n\nDiagnostics and Weight Distributions\nBefore interpreting IPTW results, it is critical to check whether the weights have created a balanced pseudo-population. Diagnostic steps include:\n\nPlotting the distribution of weights: Helps identify extreme weights.\nChecking covariate balance after weighting: Using standardized mean differences.\nPlotting Love plots or density plots of covariates: To assess balance visually.\n\nR Example (Check Weights and Balance):\nhist(data$stab_weight, breaks = 30, main = \"Stabilized Weights\")\n\nlibrary(cobalt)\nbal.tab(A ~ W1 + W2, data = data, weights = data$stab_weight)\nlove.plot(bal.tab(A ~ W1 + W2, data = data, weights = data$stab_weight))\nSummary: IPTW is a powerful method for estimating causal effects using the propensity score. Careful diagnostics and attention to weight distribution are necessary to avoid instability and ensure valid inferences.",
"crumbs": [
"G-Methods",
"<span class='chapter-number'>4</span> <span class='chapter-title'>Methods Based on the Propensity Score</span>"
]
},
{
"objectID": "chapters/chapter4/index.html#sec-ps-practical",
"href": "chapters/chapter4/index.html#sec-ps-practical",
"title": "4 Methods Based on the Propensity Score",
"section": "4.4 Practical Considerations",
"text": "4.4 Practical Considerations\n\n4.4.1 Assessing Overlap and Positivity\nA fundamental assumption in propensity score analysis is the assumption of positivity, also known as common support or overlap. This requires that for all combinations of covariates \\(W\\), the probability of receiving each treatment level is strictly between zero and one: \\[\n0 < P(A = 1 \\mid W) < 1.\n\\]\nViolations of positivity occur when some individuals have near-deterministic treatment assignment based on their covariates. These individuals contribute little to causal identification and may introduce instability in estimates, particularly in weighting methods like IPTW. The overlap of the distribution of propensity scores between treatment groups gives a visual identification regarding the strength of confounding and whether it is acceptable.\nlibrary(ggplot2)\nggplot(data, aes(x = pscore, fill = factor(A))) +\n geom_density(alpha = 0.4) +\n labs(title = \"Propensity Score Overlap\", fill = \"Treatment\")\nWhen overlap is poor, trimming or restriction to regions of common support is sometimes used to improve robustness, albeit at the cost of generalizability.\n\n\n4.4.2 Checking Covariate Balance\nThe primary role of the propensity score is to balance observed covariates between treatment groups. Balance diagnostics should be conducted after implementing any propensity score method—whether matching, weighting, or stratification. One commonly used measure is the standardized mean difference (SMD), defined as the difference in means between treated and control groups, divided by the pooled standard deviation.\nSMDs close to zero suggest good balance. A common rule of thumb is that absolute SMDs below 0.1 indicate acceptable balance. Visual tools, such as Love plots, provide a convenient way to display covariate balance before and after adjustment.\nlibrary(cobalt)\nps_model <- glm(A ~ W1 + W2, data = data, family = binomial)\ndata$pscore <- ps_model$fitted.values\nbal.tab(A ~ W1 + W2, data = data, weights = data$stab_weight)\nlove.plot(bal.tab(A ~ W1 + W2, data = data, weights = data$stab_weight))\nIf covariate balance is unsatisfactory, the propensity score model may need to be refined by adding interaction terms or nonlinear effects.\nWhen there are near violations of the positivity assumption, the unstabilised weights can have large values, forcing the variance to increase and exacerbate the uncertainty of the ATE estimation. Therefore, it is advisable to explore the distribution of the weights to evaluate the extent to which they balance the distribution of confounders across the levels of the treatment (i.e., equally distributed). As shown by (Austin, 2009), it is common to provide a table with the unweighted and weighted differences of the standardised means of the confounders by the levels of the treatment.\nAs an example, suppose we have information on a set of covariates given in Table 4.1. Prior to weighting, there was some imbalance (absolute values of the standardised differences close to, or beyond, 0.10) on sex, education level and presence/extent of cancer between treatment groups. A variance ratio (i.e., the ratio of the standardised distribution of the confounders by the levels of the treatment) equal to 1 before and after weighting informs us that the distribution of the confounders across the levels of the treatments is the same (i.e., perfectly balanced). Note, the weighted variance ratio for the continuous variable age is 0.79, which is slightly further from 1 than the variance ratio for the original (unweighted) sample (i.e., 0.82); this slight change is possibly because the weighted mean for age might have greater sampling variance than the unweighted mean.\n\n\n\nTable 4.1: Distribution of the treatment before and after applying weights\n\n\n\n\n\nConfounder\nRaw\nWeighted\n\nRaw\nWeighted\n\n\n\n\nSex\n0.093\n0.000\n\n0.977\n1.000\n\n\nAge\n-0.061\n-0.004\n\n0.817\n0.791\n\n\nEducation\n0.091\n-0.002\n\n1.015\n1.027\n\n\nRace - Black\n-0.031\n0.002\n\n0.944\n1.003\n\n\nRace - Other\n0.020\n0.001\n\n1.078\n1.004\n\n\nCancer - Metastatic\n-0.069\n-0.000\n\n0.780\n1.000\n\n\nCancer - Localised\n-0.072\n0.000\n\n0.879\n0.999\n\n\n\n\n\n\nReference groups: race - white, cancer - none\nThere is no definitive value at which the treatment is considered unbalanced; however, as a guideline, a variance ratio less than 0.5 indicates that the data is not balanced and the potential for the positivity violation must be explored (i.e., when \\(P(A=a\\mid C=c)\\) is near to zero or one). An additional strategy is to check the distribution of the weights: if there are very large weights this indicates the violation of the positivity assumption but, also, it can be due to parametric modelling misspecification. Again there is no clear consensus but, when there are very large weights, researchers often set the weights to a less extreme value. (Stürmer et al., 2010) does this by trimming or removing the data at the extremes of the distribution of the weights (e.g., the \\(5^{th}\\) and \\(95^{th}\\) percentiles). Trimming the weights reduces variance (i.e., omitting the largest weights and making the positivity assumption more plausible), but at the expense of introducing bias (Cole & Hernán, 2008). However, another alternative without dropping observations is truncation, whereby all the values of the weights, larger than a user-specified maximum value or percentile (e.g., \\(1^{st}\\) and \\(99^{th}\\) or \\(5{th}\\) and \\(95^{th}\\)), are replaced by that threshold value (Cole & Hernán, 2008; Xiao et al., 2013). In extreme cases, when the weights are extremely large, changing the estimand could be another solution (e.g., estimating the ATE in a subset of the sample, among only those treated for example, representing the average treatment effect among the treated -ATT-).\n\n\n4.4.3 Sensitivity to Propensity Score Model Choice\nSince propensity scores are typically estimated from a model, their validity depends on correct model specification. For binary exposures, logistic regression is the most common choice, but its parametric nature can lead to bias if important nonlinearities or interactions are omitted. One way to assess sensitivity is to compare covariate balance and treatment effect estimates under alternative model specifications.\nFlexible, data-adaptive methods such as generalized additive models, random forests, or ensemble learners like Super Learner may improve propensity score estimation by reducing model misspecification. However, they also require careful diagnostics to ensure that the resulting weights or matches still achieve balance.\nlibrary(SuperLearner)\nX <- data[, c(\"W1\", \"W2\")]\nY <- data$A\nsl_model <- SuperLearner(Y = Y, X = X, family = binomial(),\n SL.library = c(\"SL.glm\", \"SL.randomForest\"))\ndata$pscore_sl <- sl_model$SL.predict\nUltimately, sensitivity analyses should be performed to evaluate the robustness of conclusions to different modeling choices.\n\n\n4.4.4 Choosing Among Propensity Score Methods\nSeveral methods are available for using the propensity score, including matching, stratification, IPTW, and covariate adjustment. The choice among them should be guided by the research question, sample size, distribution of covariates, and practical considerations such as overlap and computational resources.\nMatching is often favored for its transparency and intuitive appeal and is particularly effective when the sample size is moderate and sufficient overlap exists. Stratification is easy to implement and understand, though it may not remove all residual confounding. IPTW is powerful for estimating marginal effects but requires careful management of extreme weights. Covariate adjustment is less commonly used on its own due to concerns about model misspecification but may serve as a useful component in doubly robust methods.\nEach method has advantages and limitations. It is often useful to implement multiple approaches and compare results as part of a sensitivity analysis. No method is universally superior, and the credibility of the analysis ultimately depends on careful diagnostics and a deep understanding of the data and context.",
"crumbs": [
"G-Methods",
"<span class='chapter-number'>4</span> <span class='chapter-title'>Methods Based on the Propensity Score</span>"
]
},
{
"objectID": "chapters/chapter4/index.html#sec-ps-summary",
"href": "chapters/chapter4/index.html#sec-ps-summary",
"title": "4 Methods Based on the Propensity Score",
"section": "4.5 Summary and Comparison",
"text": "4.5 Summary and Comparison\nThis chapter has outlined a suite of methods built upon the propensity score, including matching, stratification, inverse probability of treatment weighting (IPTW), covariate adjustment, and doubly robust estimators. These methods all aim to reduce bias due to measured confounding by balancing covariates between treatment groups. In this final section, we reflect on how these approaches compare with outcome-based methods such as the g-formula, identify situations in which propensity score methods are most appropriate, and summarize their relative strengths and weaknesses.\n\n4.5.1 Comparison with the G-formula\nThe g-formula, or outcome regression, relies on modeling the outcome as a function of treatment and confounders. This approach directly estimates the expected potential outcomes under each treatment and averages them over the population. In contrast, propensity score methods focus on balancing the distribution of confounders by modeling treatment assignment and use this to indirectly adjust outcome comparisons.\nIn terms of assumptions, both the g-formula and propensity score methods require unconfoundedness (i.e., no unmeasured confounding) and positivity. However, the g-formula relies more heavily on correctly specifying the outcome model, while propensity score methods transfer this modeling burden to the treatment assignment mechanism. In theory, if both models are correctly specified, the g-formula may be more efficient, especially when effect modification is limited. In practice, the choice often depends on which model is easier to specify accurately given the data and subject-matter knowledge.\nPropensity score methods are especially useful when the outcome is rare or difficult to model directly. They are also appealing when investigators prefer to separate design from analysis, as matching and stratification can be implemented without using outcome data. This pre-analysis design step can help reduce bias due to model overfitting or selective model specification.\n\n\n4.5.2 When to Use Propensity Score Methods\nPropensity score methods are most beneficial in observational studies where treatment is not randomly assigned and confounding is suspected. These methods are especially appropriate when the number of covariates is large, or when the outcome is not well understood. They are also helpful when researchers want to avoid strong parametric assumptions about the outcome.\nMatching is particularly appealing when a clear comparison group is desired and transparency is a priority. Stratification works well when the propensity score distribution overlaps substantially between groups. IPTW is a good choice for estimating marginal effects, but it requires close attention to positivity and extreme weights. Doubly robust methods, such as AIPTW, are advantageous when there is uncertainty about which model (outcome or treatment) is correctly specified, as they offer consistent estimates if either is valid.\nThese methods should not be used mechanically. They require thoughtful implementation, including careful model specification, extensive diagnostics, and often sensitivity analyses. When used appropriately, they can greatly reduce bias due to confounding and enhance the credibility of causal claims.\n\n\n4.5.3 Strengths and Limitations\nThe major strength of propensity score methods is their ability to achieve covariate balance in high-dimensional settings without modeling the outcome. This makes them attractive when outcome data are noisy or limited. Many implementations, particularly matching and weighting, also offer intuitive interpretations and can be made transparent to non-technical audiences.\nHowever, these methods have limitations. All propensity score methods depend on the strong assumption that all confounders have been measured. If key confounders are omitted, none of the methods can recover an unbiased causal effect. Moreover, methods like IPTW are sensitive to violations of positivity and can become unstable in the presence of extreme weights. Matching discards data and can reduce precision, while stratification may not fully eliminate residual confounding.\nFinally, while propensity score methods reduce reliance on modeling the outcome, they do not eliminate the need for modeling altogether. The estimated propensity score is a model-based quantity, and poor specification can lead to imbalance and bias. The emergence of machine learning methods offers opportunities to improve propensity score estimation, but it also introduces challenges related to interpretability and diagnostics.\nIn summary, propensity score methods offer a flexible and powerful approach to estimating causal effects in observational studies. When implemented carefully and in the right context, they serve as valuable tools in the causal inference toolkit and provide a strong complement to outcome-based methods such as the g-formula.",
"crumbs": [
"G-Methods",
"<span class='chapter-number'>4</span> <span class='chapter-title'>Methods Based on the Propensity Score</span>"
]
},
{
"objectID": "chapters/chapter4/index.html#glossary",
"href": "chapters/chapter4/index.html#glossary",
"title": "4 Methods Based on the Propensity Score",
"section": "4.6 Glossary",
"text": "4.6 Glossary\n\nTMLE\n\nTargeted Maximum Likelihood Estimation\n\n\n\n\n\n\nAustin, P. C. (2009). Balance diagnostics for comparing the distribution of baseline covariates between treatment groups in propensity-score matched samples. Statistics in Medicine, 28(25), 3083–3107. https://doi.org/10.1002/sim.3697\n\n\nCole, S. R., & Hernán, M. A. (2008). Constructing inverse probability weights for marginal structural models (No. 6; Vol. 168, pp. 656–664). Oxford Academic. https://doi.org/10.1093/aje/kwn164\n\n\nHorvitz, D. G., & Thompson, D. J. (1952). A generalization of sampling without replacement from a finite universe. Journal of the American Statistical Association, 47(260), 663. https://doi.org/10.2307/2280784\n\n\nRobins, J. (1986). 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(9), 1393–1512. https://doi.org/https://doi.org/10.1016/0270-0255(86)90088-6\n\n\nRosenbaum, P. R., & Rubin, D. B. (1983). The central role of the propensity score in observational studies for causal effects. Biometrika, 70(1), 41–55.\n\n\nStürmer, T., Rothman, K. J., Avorn, J., & Glynn, R. J. (2010). Treatment effects in the presence of unmeasured confounding: Dealing with observations in the tails of the propensity score distribution-a simulation study. American Journal of Epidemiology, 172(7), 843–854. https://doi.org/10.1093/aje/kwq198\n\n\nXiao, Y., Moodie, E. E. M., & Abrahamowicz, M. (2013). Comparison of approaches to weight truncation for marginal structural cox models. Epidemiologic Methods, 2(1), 1–20. https://doi.org/10.1515/em-2012-0006",
"crumbs": [
"G-Methods",
"<span class='chapter-number'>4</span> <span class='chapter-title'>Methods Based on the Propensity Score</span>"
]
},
{
"objectID": "chapters/chapter5/index.html",
"href": "chapters/chapter5/index.html",
"title": "5 Double-robust estimators",
"section": "",
"text": "5.1 Introduction to Double Robustness",
"crumbs": [
"Advanced Methods",
"<span class='chapter-number'>5</span> <span class='chapter-title'>Double-robust estimators</span>"
]
},
{
"objectID": "chapters/chapter5/index.html#introduction-to-double-robustness",
"href": "chapters/chapter5/index.html#introduction-to-double-robustness",
"title": "5 Double-robust estimators",
"section": "",
"text": "5.1.1 Motivation: Why Double Robustness Matters\nIn earlier chapters, we explored several foundational methods for estimating causal effects in observational studies, including regression adjustment, propensity score methods, inverse probability of treatment weighting (IPTW), and the g-formula. Each of these methods relies on correctly specifying a model – whether that be a model for the outcome, the treatment assignment, or the joint distribution of covariates, treatment, and outcome.\nHowever, in real-world applications, it is often difficult to know whether the chosen model is correct. Model misspecification is a pervasive concern that can lead to biased estimates and invalid inference. This motivates the need for methods that offer greater protection against such misspecification.\nDouble-robust estimators are designed with this challenge in mind. They combine models for both the treatment assignment (e.g., the propensity score) and the outcome. Remarkably, they are consistent and asymptotically unbiased if either the treatment model or the outcome model is correctly specified—not necessarily both. This property makes double-robust methods particularly appealing in applied settings, offering a safeguard when uncertainty about model specification is high.\nIn the sections that follow, we will build on the concepts introduced in previous chapters to develop and understand double-robust estimators, starting with the intuition behind them and proceeding to concrete implementations.\n\n\n5.1.2 Definitions: What Makes an Estimator “Double Robust”?\nAn estimator is said to be double robust if it yields a consistent estimate of the causal effect as long as either:\n\nThe model for the outcome given treatment and covariates, $ [Y A, X] $, is correctly specified, or\nThe model for the treatment assignment mechanism, i.e., the propensity score $ e(X) = (A = 1 X) $, is correctly specified.\n\nIn contrast to singly robust estimators—such as ordinary regression or IPW—double-robust methods incorporate information from both models, and the estimator remains valid if at least one is correctly specified.\nMore formally, suppose we are interested in estimating the average treatment effect (ATE): \\[\n\\text{ATE} = \\mathbb{E}[Y^1 - Y^0]\n\\] where $ Y^a $ denotes the potential outcome under treatment level $ a {0, 1} \\(. A double-robust estimator of the ATE typically takes the form:\\)$ {} = {i=1}^{n} { - + _1(X_i) - _0(X_i) } $$ where $ (X_i) $ is the estimated propensity score, and $ _a(X_i) $ is the predicted outcome under treatment $ a $, i.e., $ _a(X_i) = [Y A = a, X = X_i] $.\nIf either the propensity score model $ (X) $ or the outcome regression $ a(X) $ is correctly specified, the estimator $ {} $ is consistent for the true ATE.\n\n\n5.1.3 When and Why to Use Double-Robust Estimators\nDouble-robust estimators are particularly useful when neither the outcome model nor the treatment model can be confidently specified. In applied settings, both models are often estimated using flexible techniques such as machine learning, which are prone to bias if overfit or miscalibrated. By combining two potentially misspecified models, double-robust estimators reduce the reliance on any single model being perfectly correct.\nMoreover, these estimators naturally accommodate semiparametric modeling strategies. For example, one can use logistic regression for the propensity score and nonparametric regression for the outcome model, or vice versa. The result is a flexible and robust framework for estimating causal effects even under model uncertainty.\nAnother key benefit is the built-in structure for diagnostic checking. If both models are suspect, the double-robust estimator may still be biased, but it can help highlight when one model strongly dominates or conflicts with the other.\n\n\n5.1.4 Connection to Consistency and Efficiency\nDouble-robust estimators are part of the broader class of semiparametric efficient estimators. If both the propensity score model and the outcome regression model are correctly specified, then double-robust estimators achieve the semiparametric efficiency bound. This means they have the lowest possible asymptotic variance among all regular and asymptotically linear estimators of the causal effect under the nonparametric model.\nThis efficiency property sets double-robust estimators apart from singly robust methods. For example, inverse probability weighting tends to have high variance, particularly when propensity scores are close to 0 or 1. Regression-based estimators may have low variance but can be severely biased if the regression model is incorrect. Double-robust methods strike a balance: they are consistent under weaker assumptions and can be more efficient when both models are well specified.\nIn summary, double-robust estimators are appealing in practice because they offer:\n\nConsistency under either a correctly specified treatment or outcome model,\nThe potential for efficiency when both models are correct,\nRobustness to model misspecification, and\nFlexibility to incorporate machine learning.\n\nWe give a formal introduction to double robust estimation from an chronological perspective and explain the value of double robustness when using flexible data-adaptive methods for inverse probability weighting or regression adjustment introducing to one of the most novel double robust methods for causal inference i.e., Targeted Maximum Likelihood Estimation. Finally, we provide a comparison of all classical and more recent methods via a Monte Carlo simulation and discuss pro and cons of the new approaches and interesting ways to continue developing and improving causal inference.",
"crumbs": [
"Advanced Methods",
"<span class='chapter-number'>5</span> <span class='chapter-title'>Double-robust estimators</span>"
]
},
{
"objectID": "chapters/chapter5/index.html#inverse-probability-of-treatment-weighting-with-regression-adjustment",
"href": "chapters/chapter5/index.html#inverse-probability-of-treatment-weighting-with-regression-adjustment",
"title": "5 Double-robust estimators",
"section": "5.2 Inverse Probability of Treatment Weighting with Regression Adjustment",
"text": "5.2 Inverse Probability of Treatment Weighting with Regression Adjustment\n\n5.2.1 Description of the Method\nCombining inverse probability weighting (IPW) with outcome regression adjustment provides a straightforward way to construct a double-robust estimator. The idea is to use both models—the propensity score model and the outcome regression model—simultaneously to mitigate the risk of misspecification in either.\nThis approach is often used in practice because it is easy to implement using standard regression software, and it provides some protection against model misspecification while avoiding the more complex steps involved in targeted learning (see TMLE). In particular, it can be viewed as a preliminary or intermediate method that builds intuition for more advanced estimators like AIPW and TMLE.\nThe IPW + regression estimator also offers an intuitive decomposition: it reweights the residuals from the regression model using inverse probability weights and adds the difference in predicted means across treatment groups. This structure can be helpful for interpreting how and why the estimator works, and for understanding sources of bias and variability.\nA common form of the estimator for the average treatment effect (ATE) is: \\[\n\\hat{\\theta}_{\\text{DR}} = \\frac{1}{n} \\sum_{i=1}^n \\left\\{ \\frac{A_i(Y_i - \\hat{m}_1(X_i))}{\\hat{e}(X_i)} - \\frac{(1 - A_i)(Y_i - \\hat{m}_0(X_i))}{1 - \\hat{e}(X_i)} + \\hat{m}_1(X_i) - \\hat{m}_0(X_i) \\right\\}\n\\] where $ _a(X_i) $ is the predicted outcome under treatment level $ a $, and $ (X_i) $ is the estimated propensity score. The first two terms reweight residuals using the inverse probability weights, while the final term combines the predicted differences in outcomes.\n\n\n5.2.2 Statistical Properties: Bias, Variance, and Efficiency\nThe estimator is consistent if either the propensity score model or the outcome regression model is correctly specified. When both models are correct, the estimator is semiparametrically efficient, achieving the lowest possible asymptotic variance under the nonparametric model defined by unconfoundedness.\nHowever, when both models are misspecified, the estimator may be biased. In practice, even small violations of model assumptions can introduce bias, especially in finite samples. This reinforces the importance of using flexible models, performing diagnostics, and conducting sensitivity analyses.\nAnother important consideration is variance inflation. If the estimated propensity scores are close to 0 or 1, the corresponding weights become large, leading to instability in the estimator. This issue—known as near-violation of the positivity assumption—can be addressed through weight truncation, stabilized weights, or the use of more robust estimators like TMLE.\n\n\n5.2.3 Implementation in R\nHere is a basic implementation of the regression + IPW estimator in R:\n# Simulate data\nset.seed(123)\nn <- 1000\nX <- rnorm(n)\nA <- rbinom(n, 1, plogis(0.5 * X))\nY <- 2 * A + X + rnorm(n)\ndata <- data.frame(A, X, Y)\n\n# Step 1: Estimate propensity scores\ne.model <- glm(A ~ X, family = binomial, data = data)\ndata$ehat <- predict(e.model, type = \"response\")\n\n# Step 2: Estimate outcome models\nm1.model <- lm(Y ~ X, data = subset(data, A == 1))\nm0.model <- lm(Y ~ X, data = subset(data, A == 0))\ndata$m1hat <- predict(m1.model, newdata = data)\ndata$m0hat <- predict(m0.model, newdata = data)\n\n# Step 3: Compute double-robust estimator\nwith(data, mean(\n A * (Y - m1hat) / ehat -\n (1 - A) * (Y - m0hat) / (1 - ehat) +\n m1hat - m0hat\n))\n\n\n5.2.4 When It Is Used in Practice\nThe regression + IPW estimator is widely used in epidemiology, economics, and health services research, especially when researchers want to guard against model misspecification. It is particularly attractive when using parametric models for one nuisance parameter (e.g., the propensity score) and nonparametric or flexible models (e.g., machine learning) for the other. In such cases, double-robustness offers a practical compromise between robustness and interpretability.\nThis approach is also used in high-dimensional settings, such as genomic studies or electronic health records, where traditional model diagnostics are less reliable and model misspecification is more likely. In such contexts, ensemble learners (e.g., Super Learner) can be used to estimate nuisance functions, and the double-robust estimator remains valid as long as at least one learner captures the truth.\nAdditionally, the regression + IPW estimator forms the foundation for more advanced estimators such as AIPW and TMLE. Understanding its structure provides essential insight into the efficient influence function framework and semiparametric causal inference more broadly.\nIn summary, IPW + outcome regression is a powerful, flexible, and interpretable tool in the causal inference toolbox, particularly useful in observational studies where untestable assumptions are the norm and robustness is paramount.",
"crumbs": [
"Advanced Methods",
"<span class='chapter-number'>5</span> <span class='chapter-title'>Double-robust estimators</span>"
]
},
{
"objectID": "chapters/chapter5/index.html#augmented-inverse-probability-of-treatment-weighting",
"href": "chapters/chapter5/index.html#augmented-inverse-probability-of-treatment-weighting",
"title": "5 Double-robust estimators",
"section": "5.3 Augmented Inverse Probability of Treatment Weighting",
"text": "5.3 Augmented Inverse Probability of Treatment Weighting\nDoubly robust (DR) estimators combine both outcome regression and propensity score-based methods to estimate causal effects. The key advantage of DR estimators is that they yield consistent estimates of treatment effects if either the model for the outcome or the model for the treatment assignment (i.e., the propensity score) is correctly specified. This property provides an additional layer of protection against model misspecification.\n\n5.3.1 Augmented IPTW (AIPTW)\nThe most common doubly robust estimator is the Augmented Inverse Probability of Treatment Weighting (AIPTW) estimator. It augments the IPTW estimator with a regression-based prediction for the outcome. Let $ Y_i $ be the observed outcome, $ A_i {0,1} $ the treatment, $ e(W_i) $ the estimated propensity score, and $ _a(W_i) = E[Y A=a, W_i] $ the predicted outcome under treatment $ a $.\nThe AIPTW estimator for the average treatment effect (ATE) is: \\[\n\\widehat{ATE}_{\\text{AIPTW}} = \\frac{1}{n} \\sum_{i=1}^n \\left[ \\frac{A_i Y_i}{\\hat{e}(W_i)} - \\frac{(A_i - \\hat{e}(W_i)) \\hat{\\mu}_1(W_i)}{\\hat{e}(W_i)} - \\left( \\frac{(1 - A_i) Y_i}{1 - \\hat{e}(W_i)} - \\frac{(A_i - \\hat{e}(W_i)) \\hat{\\mu}_0(W_i)}{1 - \\hat{e}(W_i)} \\right) \\right].\n\\]\nThis estimator consists of two broad components that correspond to the treated and untreated groups, respectively. The term $ $ represents a weighted average of outcomes among the treated individuals, where each individual is weighted by the inverse of their estimated propensity score. This is a standard component of the IPTW estimator, capturing the expected potential outcome under treatment. The term $ $ acts as a correction, adjusting the treatment group’s contribution based on the discrepancy between the actual treatment received and the estimated probability of treatment, scaled by the predicted outcome from the outcome regression model under treatment.\nThe second part of the expression inside the summation pertains to the control group. The term $ $ is the IPTW contribution for control individuals, with weights equal to the inverse of one minus the estimated propensity score. This is then adjusted using $ $, which again serves as a correction based on the difference between actual and predicted treatment assignment, scaled by the predicted outcome under control.\nTaken together, this expression combines inverse probability weighting with model-based outcome predictions to reduce variance and mitigate bias. The estimator remains consistent provided either the propensity score model or the outcome model is correctly specified, offering what is referred to as “double robustness.”\nTaking a deeper look into AIPTW. The Augmented Inverse Probability of Treatment Weighting (AIPTW) estimator extends the standard IPTW framework by incorporating an additional term designed to correct for potential misspecification of the treatment model. If the model for the treatment assignment is correctly specified, this augmentation term contributes negligible bias as sample size increases, resulting in an estimator that simplifies to IPTW. This makes AIPTW more efficient in large samples compared to IPTW. Nonetheless, like IPTW, AIPTW suffers from instability when the estimated propensity scores are close to 0 or 1, which indicates a violation of the positivity assumption.\nAIPTW uses information from both the treatment model and the outcome model. The augmentation term, which has expectation zero under correct model specification, depends on the estimated propensity score and the predicted outcomes from a regression model. Because of this dual reliance, AIPTW achieves consistency for the average treatment effect (ATE) as long as at least one of the two models—the treatment mechanism or the outcome regression—is correctly specified. This property is the foundation of its double-robustness (Bang & Robins, 2005; Robins et al., 1994; Tsiatis et al., 2007).\nThe IPTW estimator for the expected potential outcome under treatment level $ a $, denoted $ a \\(, is given by:\\)$ {a} = (,Y), $$ where $ I() $ is the indicator function and $ g(A ) $ is the estimated propensity score.\nThe IPTW estimator can be viewed as solving the estimating equation: \\[\n\\frac{1}{n}\\sum_{i=1}^{n}\\left(\\frac{{I}(A_{i}=a)Y_{i}}{g(A_{i}\\mid \\boldsymbol{W}_{i})} - \\mu_{a}\\right) = 0.\n\\]\nTo improve this estimator, we can introduce a mean-zero augmentation term that adjusts for residual differences in the outcome model: \\[\n\\frac{I(A=a) - g(A=a\\mid \\boldsymbol{W})}{g(A=a\\mid \\boldsymbol{W})} E(Y \\mid A=a, \\boldsymbol{W}).\n\\]\nIncorporating this into the estimating equation gives the AIPTW formulation: \\[\n\\begin{aligned}\n \\mathbb{E}\\left(\\frac{I(A=a)Y}{g(A=a\\mid \\boldsymbol{W})} - \\left(\\frac{I(A=a) - g(A=a\\mid \\boldsymbol{W})}{g(A=a\\mid \\boldsymbol{W})} \\right) E(Y \\mid A=a, \\boldsymbol{W}) \\right) - \\mu_a = 0.\n\\end{aligned}\n\\]\nBy rearranging, it becomes evident that AIPTW combines both an outcome regression and a weighting adjustment: \\[\\begin{aligned}\n & \\frac{1}{n} \\underbrace{\\sum_{i=1}^{n} \\left( E(Y_i \\mid A_i=1, \\boldsymbol{W}_i) - E(Y_i \\mid A_i=0, \\boldsymbol{W}_i) \\right)}_{\\text{Outcome regression component}} + \\\\\n & \\frac{1}{n} \\sum_{i=1}^{n} \\underbrace{\\left( \\frac{A_i [Y_i - E(Y_i \\mid A_i=1, \\boldsymbol{W}_i)]}{g(A_i=1 \\mid \\boldsymbol{W}_i)} - \\frac{(1 - A_i) [Y_i - E(Y_i \\mid A_i=0, \\boldsymbol{W}_i)]}{g(A_i=0 \\mid \\boldsymbol{W}_i)} \\right)}_{\\text{Augmentation term with mean zero}}.\n\\end{aligned}\n\\tag{5.1}\\]\nThe estimated ATE using AIPTW is: \\[\n\\text{AIPTW-ATE} = \\mu_1 - \\mu_0,\n\\]\nwhere each potential outcome mean is given by: \\[\\begin{aligned}\n\\mu_1 &= \\frac{1}{n} \\sum_{i=1}^{n} \\left( E(Y_i \\mid A_i=1, \\boldsymbol{W}_i) + \\frac{A_i [Y_i - E(Y_i \\mid A_i=1, \\boldsymbol{W}_i)]}{g(A_i=1 \\mid \\boldsymbol{W}_i)} \\right), \\\\\n\\mu_0 &= \\frac{1}{n} \\sum_{i=1}^{n} \\left( E(Y_i \\mid A_i=0, \\boldsymbol{W}_i) + \\frac{(1 - A_i) [Y_i - E(Y_i \\mid A_i=0, \\boldsymbol{W}_i)]}{g(A_i=0 \\mid \\boldsymbol{W}_i)} \\right).\n\\end{aligned}\n\\]\nThe second component in Equation 5.1 reflects the residuals of the outcome regression model, scaled by the inverse probability weights. These residual terms have expectation zero under correct specification, making them ideal for correcting potential bias from misspecification in one of the models (Kennedy, 2016). When the outcome model is correct, the AIPTW simplifies to the g-formula estimator. Conversely, if the treatment model is correct, the estimator collapses to the standard IPTW form (Bang & Robins, 2005; Daniel, 2018).\nR Example (AIPTW with linear models):\n# Estimate propensity scores\ndata$ps <- glm(A ~ W1 + W2, data = data, family = binomial)$fitted.values\n\n# Estimate outcome models\nmu1_model <- lm(Y ~ W1 + W2, data = subset(data, A == 1))\nmu0_model <- lm(Y ~ W1 + W2, data = subset(data, A == 0))\ndata$mu1 <- predict(mu1_model, newdata = data)\ndata$mu0 <- predict(mu0_model, newdata = data)\n\n# AIPTW estimate of ATE\nterm1 <- data$A * (data$Y - data$mu1) / data$ps + data$mu1\nterm0 <- (1 - data$A) * (data$Y - data$mu0) / (1 - data$ps) + data$mu0\nate_aiptw <- mean(term1 - term0)\nate_aiptw\n\n\n5.3.2 Intuition and Advantages\nThe intuition behind the AIPTW estimator is based on combining two approaches: weighting and imputation. The weighting component (as in IPTW) creates a pseudo-population where the distribution of covariates is independent of treatment assignment, while the imputation component uses an outcome model to predict what would have happened under each treatment arm. If the outcome model is correct, the predicted values can help fill in the missing potential outcomes. If the weighting model is correct, the reweighted sample gives unbiased comparisons of outcomes between treatment groups. Because the AIPTW estimator uses both sources of information, it offers protection against misspecification of either model. This makes it more robust than estimators that rely exclusively on one model.\nOne important advantage of AIPTW is that it improves efficiency compared to IPTW or regression alone. The estimator also offers a bias correction mechanism that can compensate for moderate model misspecification. When at least one model is correct, the bias converges to zero as the sample size increases, preserving consistency.\n\n\n5.3.3 Limitations and Forward Link to TMLE\nDespite its theoretical strengths, the AIPTW estimator has several limitations in practice. In finite samples, its performance can be unstable, particularly when there is limited overlap in the propensity score distributions between treated and control groups. Extreme values of the weights can lead to high variance or numerical instability. Additionally, if both the propensity score and outcome models are misspecified, the AIPTW estimator can perform worse than estimators that rely on a single model, a phenomenon known as bias amplification.\nTraditional implementations of AIPTW are based on plug-in estimates and do not directly optimize the estimator for a target causal parameter. This lack of targeting has motivated the development of newer doubly robust methods, such as Targeted Maximum Likelihood Estimation (TMLE). TMLE incorporates targeted updates to the outcome model and guarantees that the final estimator solves a specific estimating equation for the target parameter. It also retains the double robustness property while offering improved statistical properties such as asymptotic efficiency.\nTMLE will be discussed in a subsequent chapter, including its theoretical foundation, algorithmic steps, and practical implementation using R.",
"crumbs": [
"Advanced Methods",
"<span class='chapter-number'>5</span> <span class='chapter-title'>Double-robust estimators</span>"
]
},
{
"objectID": "chapters/chapter5/index.html#targeted-maximum-likelihood-estimation",
"href": "chapters/chapter5/index.html#targeted-maximum-likelihood-estimation",
"title": "5 Double-robust estimators",
"section": "5.4 Targeted Maximum Likelihood Estimation",
"text": "5.4 Targeted Maximum Likelihood Estimation\nThe targeted learning framework provides a structured approach to estimate causal effects with greater accuracy and robustness. Unlike traditional estimators, which may be biased if certain assumptions are violated, targeted learning aims to reduce bias and maximize efficiency by combining flexible machine learning methods with causal inference principles.\n\n5.4.1 Motivation for targeted learning\nTraditional causal estimators, such as propensity score methods and inverse probability of treatment weighting, are often single-robust—they rely on the correct specification of either the treatment or outcome model to produce unbiased estimates. If that model is misspecified, the resulting estimates can be biased. These methods have limited protection against model misspecification, and their validity breaks down when both models are incorrect. Double-robust estimators improve upon this by remaining consistent if either the treatment or outcome model is correctly specified. Further gains in bias reduction and efficiency can be achieved by using flexible, data-adaptive machine learning methods that avoid strict parametric assumptions.\nTargeted Maximum Likelihood Estimation (TMLE) is a plug-in, semi-parametric, double-robust estimator that incorporates machine learning to refine an initial estimate, targeting it toward the parameter of interest. TMLE has been widely described in both theoretical and practical tutorials.(Gruber & Laan, 2012; Gruber & Laan, 2009; Gruber & Laan, 2011; Luque-Fernandez, Schomaker, et al., 2018; Schuler & Rose, 2017; vanderLaan2011?) In simulation and applied studies, TMLE has shown lower bias than other double-robust estimators such as IPTW-RA and AIPTW, especially in small samples.(Luque-Fernandez, Belot, et al., 2018; vanderLaan2011?) Although asymptotically equivalent to AIPTW, TMLE generally performs better in finite samples and is often used in combination with ensemble machine learning to further mitigate model specification issues.\nThe targeted learning framework was designed to overcome limitations of traditional estimators. It ensures double robustness and facilitates the integration of machine learning to model complex, high-dimensional relationships. The central goal is to produce an accurate and efficient estimate of a causal parameter—such as the average treatment effect—by aligning the estimation process with that specific target. A key innovation is the targeting step, which updates the initial estimate using information from the treatment mechanism. This is guided by the efficient influence curve, ensuring that the final estimator is not only unbiased but also has minimal variance given the observed data.\n\nGoal of targeted learning\nTargeted learning is focused on obtaining the most accurate estimate possible for a specific causal parameter by reducing bias and optimizing statistical efficiency. A central component of this approach is the targeting step, which adjusts initial estimates to correct for residual bias, thereby bringing the estimate closer to the true value of the target parameter. In addition, targeted learning leverages efficient influence curves to guide estimation in a way that minimizes variance, making the resulting estimators as close to statistically optimal as possible and enhancing the reliability and precision of the estimates.\n\n\n\n5.4.2 TMLE step-by-step guide\nTMLE has six main steps:\n\nInitial prediction of the outcome\nPredict the probability of treatment\nCalculate the fluctuation parameter\nUpdate the initial prediction of the outcome\nCompute the estimand of interest\nCalculate the standard errors for confidence intervals and p-values\n\nAs an example, suppose we are interested in estimating the effect of \\(A\\) (a binary treatment variable) on \\(Y\\) (a binary outcome variable) while adjusting for some confounders \\(W\\) (a vector of binary and continuous variables). Below is the simulated data. The steps for TMLE are given after.\nlibrary(readr)\nlibrary(knitr)\n\ndata <- read.csv(\"https://raw.githubusercontent.com/migariane/TutorialComputationalCausalInferenceEstimators/refs/heads/main/rhc.csv\")\n\n# Define the outcome (Y), exposure (A), confounder (C), and confounders (W)\n# Y\ndata$Y <- as.numeric(data$death_d30); Y <- data$Y\n# A - Treated = 1, Not treated = 0\ndata$A <- as.numeric(as.factor(data$rhc))-1; A <- data$A\n# C - Female = 0, Male = 1\ndata$C <- as.numeric(as.factor(data$sex))-1; C <- data$C\n# w1 (age)\ndata$w1 <- as.numeric(data$age); w1 <- data$w1\n# w2 (education)\ndata$w2 <- as.numeric(data$edu); w2 <- data$w2\n# w3 (race) - White = 2, Other = 1, Black = 0\ndata$w3 <- as.numeric(as.factor(data$race))-1; w3 <- data$w3\n# w4 (carcinoma) - Yes = 2, No = 1, Metastatic = 0\ndata$w4 <- as.numeric(as.factor(data$carcinoma)); w4 <- data$w4\n\n# Create a data set\ndata2 <- as.data.frame(Y); data2$A <- A; data2$C <- C\ndata2$w1 <- w1; data2$w2 <- w2; data2$w3 <- w3; data2$w4 <- w4\n\nStep 1: Predict the initial outcome\nThe first step is to estimate the expected value of the outcome using information on the treatment and confounders. This is defined using a function Q of A and \\(\\mathbf{W}\\) to obtain the conditional expectation of Y:\n\\[ Q^{0}(A,\\mathbf{W}) = E[Y|A,\\mathbf{W}]\\]\nWe can use logistic regression to model the conditional expectation of Y:\n\\[ E[Y|A,\\mathbf{W}] = \\beta_{0} + \\beta_{1}A + \\beta^{T}_{w}\\mathbf{W}\\]\n# Step 1\nGcomp <- glm(Y ~ A + C + w1 + w2 + as.factor(w3) + as.factor(w4), family=\"binomial\", data=data2)\nTo predict the potential outcomes, we first need to specify two variables, one where everyone receives the treatment (\\(A=1\\)) and another where everyone does not receive the treatment (\\(A=0\\)). Taking predictions of the outcome for each observation using these two variables provides us with the potential outcomes (\\(Y(1)\\) and \\(Y(0)\\)).\n\\[ Q^{0}(A=1,\\mathbf{W}) \\quad = \\quad E[Y|A=1,\\mathbf{W}] \\quad = \\quad expit( \\widehat{\\beta}_{0} + \\widehat{\\beta}_{1}(A=1) + \\widehat{\\beta}^{T}_{w}\\mathbf{W}) \\]\n\\[ Q^{0}(A=0,\\mathbf{W}) \\quad = \\quad E[Y|A=0,\\mathbf{W}] \\quad = \\quad expit( \\widehat{\\beta}_{0} + \\widehat{\\beta}_{1}(A=0) + \\widehat{\\beta}^{T}_{w}\\mathbf{W}) \\]\n# Predict Q for A, A=1, and A=0\nQAW <- predict(Gcomp)\nQ1W = predict(Gcomp, newdata=data.frame(A = 1, data2[,c(\"C\",\"w1\",\"w2\",\"w3\",\"w4\")]))\nQ0W = predict(Gcomp, newdata=data.frame(A = 0, data2[,c(\"C\",\"w1\",\"w2\",\"w3\",\"w4\")]))\nNotice that the potential outcome for \\(A=1\\) will be equivalent to the observed outcome (\\(E(Y|A=1,\\mathbf{W}\\)). This is part of the consistency assumption.\nIf we were to take the difference between \\(\\widehat{E}(Y|A=1,\\mathbf{W})\\) and \\(\\widehat{E}(Y|A=0,\\mathbf{W})\\), then we would obtain an estimate of the average treatment effect (ATE). You may have noticed that this is the same as standardisation, g-formula estimation, or G-computation.\nHowever, we can do better than this. TMLE includes a targeting step that adjusts the initial prediction of the outcome to align it with the estimand of interest (e.g., the ATE). The initial prediction of the outcome (\\(Q^{0}\\)) may be a good overall estimate but may not be tailored to the causal quantity. The targeting step refines this prediction to better capture the relevant features of the data for estimating the parameter of interest. The targeting step involves defining “clever covariates” (constructed using the propensity score) adjusting the initial prediction to correct for any bias in the estimation of the parameter of interest. This is especially important when the initial model is misspecified. Through the targeting step, TMLE achieves double robustness, meaning it produces consistent estimates if either the initial outcome model (\\(Q^{0}\\)) or the propensity score model is correctly specified. The targeting step ensures that the estimator uses both models effectively, leveraging their complementary strengths. The targeting step encompasses Steps 2, 3, and 4 of the six main steps. Together, these steps create a fluctuation parameter that is used to update the initial prediction of the outcome.\nAn important note here is that even if we used machine learning algorithms to define the outcome model, we will still need the targeting step. This is because in Step 1 we are predicting potential outcomes, we are not yet estimating causal effects. The objective of machine learning (i.e., logistic regression in a simple case) is to minimise prediction error on the outcome variable, not to balance confounders or align with the causal estimand. Machine learning models predict the outcome conditional on covariates, but they do not naturally adjust for treatment assignment mechanisms or ensure consistency with the target parameter. The targeting step adjusts the outcome predictions to account for the propensity score and other aspects of the treatment mechanism, ensuring the final estimate is aligned with the causal parameter. The machine learning models may still leave residual confounding or fail to focus on the specific population and treatment comparisons relevant to the causal parameter.\nThe question is now “how do we refine our initial prediction of the outcome (and the estimate of the target parameter)”? In semiparametric estimation theory, there is a fundamental concept called the efficient influence curve (EIC). It represents the residual variation in the target parameter that remains after accounting for all available information in the model. The EIC is a function that characterises the amount of information a particular observation provides about the target parameter while accounting for the statistical model’s constraints. The EIC is the “blueprint” for achieving efficient, unbiased estimation of a causal parameter. TMLE updates the initial outcome model so that the final estimate solves the EIC equation, ensuring the estimator is efficient and unbiased. The EIC is:\n\\[ EIC = \\left( \\frac{A}{P(A=1 | \\mathbf{W})} - \\frac{1-A}{P(A=0 | \\mathbf{W})} \\right) [ Y - E(Y | A, \\mathbf{W}) ] + E(Y | A=1, \\mathbf{W}) + E(Y | A=0, \\mathbf{W}) - \\psi \\]\nwhere \\(\\psi\\) is our estimate of the ATE. The EIC can be evaluated from the observed data as\n\\[ \\widehat{EIC} = \\left( \\frac{A}{\\widehat{g}(1,\\mathbf{W})} - \\frac{1-A}{\\widehat{g}(0,\\mathbf{W})} \\right) [ Y - Q^{1}(A,\\mathbf{W}) ] + Q^{1}(1,\\mathbf{W}) + Q^{1}(0,\\mathbf{W}) - \\widehat{ATE} \\]\nNote that \\(Q^{1}(.)\\) is the update of the initial prediction of \\(Q^{0}(.)\\), and \\(\\widehat{g}(.)\\) is the propensity score.\nUsing the EIC to achieve an unbiased estimation of the causal parameter (e.g., ATE), we need to obtain the propensity score and update the initial prediction of the outcome. We cover this over the next few steps.\n\n\nStep 2: Predict the probability of treatment\nSteps 2, 3, and 4 encompass the targeting step used to update the initial prediction of the outcome. The first part of the targeting step is to estimate the probability of treatment, given the confounders:\n\\[ g(A,W) = Pr(A=1 | \\mathbf{W}) \\]\nAgain, we could use logistic regression to define the propensity score model:\n\\[ \\widehat{g}(A=1,\\mathbf{W}) \\quad = \\quad \\widehat{E}[A=1 | \\mathbf{W}] \\quad = \\quad expit( \\widehat{\\alpha}_{0} + \\widehat{\\alpha}^{T}_{1}\\mathbf{W} ) \\]\n# Step 2 estimation of the propensity score (ps)\npsm <- glm(A ~ C + w1 + w2 + as.factor(w3) + as.factor(w4), family = binomial, data=data2)\ngW = predict(psm, type = \"response\")\ng1W = (1 / gW)\ng0W = (-1 / (1-gW))\n\n\nStep 3: Calculate the fluctuation parameter\nThe next step of the targeting step is to calculate clever covariates and the fluctuation parameter. These covariates guide the targeting step by indicating how much weight each observation contributes to correcting the initial prediction.\nThe clever covariates are calculated as:\n\\[ H(A=a, \\mathbf{W}) \\quad = \\quad \\frac{A}{\\widehat{g}(A=1,\\mathbf{W})} \\, - \\, \\frac{1-A}{\\widehat{g}(A=0,\\mathbf{W})} \\]\nWhen \\(A=1\\), the right hand side will be \\(\\frac{1}{\\widehat{g}(A=1,\\mathbf{W})}\\). When \\(A=0\\), the right hand side will be \\(\\frac{-1}{\\widehat{g}(A=0,\\mathbf{W})}\\). You may notice that the clever covariates are of the same form as inverse probability of treatment weights.\n# Step 3 computation of H and estimation of epsilon\nHAW <- (data2$A / gW -(1-data2$A) / (1 - gW))\nH1W = (1/gW)\nH0W = (-1 / (1 - gW))\nThe fluctuation parameter (\\(\\epsilon\\)) is a small adjustment applied to the initial outcome model (\\(Q^{0}(A,\\mathbf{W})\\)) to correct residual bias and ensure that the updated model (\\(Q^{1}\\)) aligns with the EIC. It does this by incorporating information from the clever covariate (\\(H(A,\\mathbf{W})\\)) and the observed outcomes (\\(Y\\)). The fluctuation parameter is estimated by solving an estimating equation, specifically a score equation derived from the EIC. The estimating equation ensures that the updated outcome model satisfies the EIC’s property:\n\\[E[D(Y,A,W;Q,g)] = 0\\]\nwhere \\(D(.)\\) is the EIC, which includes the clever covariate \\(H(A,W)\\).\nIn practice, the score equation used to estimate \\(\\epsilon\\) is:\n\\[ \\sum_{i} H(A_{i}, W_{i}) \\times (Y_{i} - Q^{1}(A_{i},W_{i})) = 0 \\]\nwhere $Q^{1}(A_{i},W_{i}) = Q^{0}(A_{i},W_{i}) + ( H(A_{i},W_{i}) ) $\nYou may be asking “why do we need to solve an estimating equation?”. By solving the score equation, TMLE ensures that the estimator \\(\\widehat{\\psi}\\) satisfies \\(E[D]=0\\), meaning the bias has been corrected.\nFor a binary outcome, the fluctuation model is often logistic:\n\\[ logit(Q^{1}(A,W)) = logit(Q^{0}(A,W)) + \\epsilon \\cdot H(A,W) \\]\nThus the estimating equation becomes:\n\\[ \\sum_{i} H(A_{i}, W_{i}) \\times \\left( Y_{i} - expit \\left( \\, logit(Q^{0}(A_{i},W_{i})) + \\epsilon \\cdot H(A_{i},W_{i}) \\right) \\right) = 0 \\]\nWhile this equation might seem complicated to compute, this equation is simply solved iteratively using maximum likelihood estimation.\nIf we take the fluctuation model above, you will see that its form is very similar to the form of a logistic regression model, such as $logit(E[Y|X]) = {0} + {1}X \\(. The difference is that in the right hand side of our fluctuation model the \"intercept\" (\\)logit(Q^{0}(A,W))$) is not a constant value like \\(\\beta_{0}\\); it is a vector of values of the initial prediction of the outcome. Thus, instead of a constant-value intercept, we use \\(logit(Q^{0}(A,W))\\) as an offset (a fixed intercept) in a logistic regression model. We can now solve our estimating equation for the EIC by using a logistic regression model with the observed outcome \\(Y\\) as the outcome, \\(logit(\\widehat{Q}^{0}(A,W))\\) as an offset, and one covariate, \\(H(A,W)\\). The coefficient for the one covariate provides us with an estimate of the fluctuation parameter (\\(\\epsilon\\)).\nepsilon <- coef(glm(data2$Y ~ -1 + HAW + offset(QAW), family = \"binomial\"))\n\n\nStep 4: Update the initial outcome\nWe now have everything we need to update the initial outcome. Referring back to the fluctuation model, we used the logit scale to solve the estimating equation for the EIC. Ideally, we would like the updated prediction of the outcome to be on the true outcome scale, We can use the inverse logit transformation (i.e., use expit):\n\\[ Q^{1}(A,\\mathbf{W}) = expit( logit(Q^{0}(A,\\mathbf{W})) + \\epsilon \\cdot H(A,\\mathbf{W} )) \\]\nFrom this model, we can obtain three variables:\n\n$ Q^{1}(A,) $: update of the expected outcome of all observations, given the treatment they actually received and their baseline confounders.\n$ Q^{1}(A=1,) $: update of the expected outcome, conditional on receiving the treatment and their baseline confounders.\n$ Q^{1}(A=0,) $: update of the expected outcome, conditional on receiving the control and their baseline confounders.\n\n# Step 4 update from Q0 to Q1 ATE\nQ1W_1 <- plogis(Q1W + epsilon * H1W)\nQ0W_1 <- plogis(Q0W + epsilon * H0W)\n\n\nStep 5: Compute the estimand of interest\nNow that we have updated predictions of the outcome, we can compute the ATE. The ATE (the causal estimand) in this case is evaluated using the risk difference (the statistical estimand). The risk difference is the average of the difference in the updated outcome estimates:\n\\[ \\widehat{ATE} = \\widehat{\\psi} = \\frac{1}{N} \\sum^{N}_{i=1} \\left( \\widehat{Q}^{1}_{i}(A=1,\\mathbf{W}) - \\widehat{Q}^{1}_{i}(A=0,\\mathbf{W}) \\right) \\]\n# Step 5 targeted estimate of the ATE\nATE <- mean(Q1W_1 - Q0W_1); ATE\n\n\nStep 6: Calculate the standard errors for confidence intervals and p-values\nTo calculate confidence intervals, we can refer back to the EIC:\n\\[ \\widehat{EIC} = \\left( \\frac{A}{\\widehat{g}(1,\\mathbf{W})} - \\frac{1-A}{\\widehat{g}(0,\\mathbf{W})} \\right) [ Y - Q^{1}(A,\\mathbf{W}) ] + Q^{1}(1,\\mathbf{W}) + Q^{1}(0,\\mathbf{W}) - \\widehat{ATE} \\]\nNotice that we use the three variables that we evaluated in step 4: \\(Q^{1}(A,\\mathbf{W})\\), \\(Q^{1}(1,\\mathbf{W})\\), and \\(Q^{1}(0,\\mathbf{W})\\).\nThe EIC informs us how much each observation influences the estimate of the target parameter. It is evaluated for each observation, and using the resulting vector, we can estimate the standard error for the target parameter:\n\\[ \\widehat{\\sigma}_{EIC} = \\widehat{SE}_{EIC} = \\sqrt{ \\frac{\\widehat{Var}(\\widehat{EIC})}{n} } \\]\nwhere \\(\\widehat{Var}(\\widehat{EIC})\\) represents the sample variance of the EIC.\n# Step 6 statistical inference\nd1 <- ((data2$A * (Y - Q1W_1)/gW)) + Q1W_1 - mean(Q1W_1)\nd0 <- ((1 - data2$A) * (Y - Q0W_1)/(1 - gW)) + Q0W_1 - mean(Q0W_1)\nEIC <- d1 - d0\nn <- nrow(data2)\nvarEIC <- var(EIC)/n\n95% confidence intervals are calculated in the conventional way:\n\\[ 95\\% CI: \\quad \\widehat{ATE} \\pm 1.96 (\\widehat{SE}_{EIC}) \\]\nLCI <- ATE - 1.96*sqrt(varEIC)\nUCI <- ATE + 1.96*sqrt(varEIC)\ncbind(ATE, LCI, UCI)\nWe obtain an estimate of 0.0837, corresponding to a risk difference of 8.37% (95% CI: 5.85 - 10.90). This is interpreted as “the risk of death at 30 days is 8.37% higher if everyone was treated with RHC compared to if no one was treated with RHC”. Note that our interpretation is a comparison of two hypothetical worlds.\n\n\nAutomating the TMLE process\nWe could do all of the above automatically using the ‘tmle’ package. The ‘tmle’ package uses Super Learner (see Section 5.4.3), which is a library of machine learning algorithms for defining the outcome (Q.SL.library) and exposure (g.SL.library) models. This requires us to first define the seed (set.seed(1)). We then create a data set called w that contains the set of confounders, which are used to define the parameters for the exposure model. Finally, we run the ‘tmle’ function to conduct TMLE. Since we are using a large data set, this will take a couple of minutes to run.\nset.seed(1)\n\ninstall.packages('tmle')\nlibrary(tmle)\n\nw <- subset(data, select=c(C, w1, w2, w3, w4))\n\nfittmle <- tmle(data$Y, data$A, W=w, family=\"binomial\", Q.SL.library = c(\"SL.glm\", \"SL.glm.interaction\", \"SL.step.interaction\", \"SL.gam\", \"SL.randomForest\"), g.SL.library = c(\"SL.glm\", \"SL.glm.interaction\", \"SL.step.interaction\", \"SL.gam\", \"SL.randomForest\"))\n\nfittmle\nFrom the ‘tmle’ function, we obtain an estimate for the ATE of 0.0848 (ATE: 8.48%, 95% CI: 5.97, 10.99). This is very close to the estimate we obtained by hand, suggesting that the functional form of the outcome and exposure models that we defined by hand are close to those that are defined within the SuperLearner (see Section 5.4.3).\nIn general, the results obtained by hand and the results obtained using the ‘tmle’ package will not be this close. Looking back at the distribution of the covariates (\\(w\\)) within each level of the treatment variable shows that the treatment groups are close to being balanced. When the covariates are not balanced, the SuperLearner will help with obtaining the best-fitting model for predicting the outcome and the exposure.\n\n\n\n5.4.3 Super Learner\nIn Section 5.4.2, parametric logistic regression models were used to define the outcome and exposure models. However, parametric models are vulnerable to misspecification, which can introduce bias into causal estimates. To address this, machine learning algorithms can be used to flexibly model complex relationships in the data and improve the accuracy of nuisance parameter estimation.\nWhy is machine learning useful in TMLE? Accurate estimation of nuisance parameters, such as the treatment mechanism and the outcome regression, is a critical component of TMLE. Misspecification of either model can undermine the robustness of the estimator. Machine learning algorithms mitigate this risk by providing flexible, data-adaptive models that do not rely on strict parametric assumptions. These methods can capture nonlinearities and interactions that are often missed by simpler models, thus reducing bias and improving efficiency.\nBecause selecting the best-performing algorithm in advance is difficult, TMLE incorporates ensemble methods that leverage the strengths of multiple learners. Among these, SuperLearner is a theoretically grounded approach that optimally combines multiple candidate algorithms to improve predictive performance.\nWhat is SuperLearner? SuperLearner is an ensemble machine learning method used in TMLE to combine predictions from multiple candidate models into a single, optimised estimator. This method is based on the principle that no single algorithm performs best across all data structures—a concept known as the “no free lunch” theorem in machine learning. Instead of relying on a single model, SuperLearner uses cross-validation to assess the performance of each algorithm and assigns weights to construct the best possible convex combination of models.\nThis approach is supported by the Oracle Inequality, which guarantees that, asymptotically, SuperLearner performs at least as well as the best convex combination of models in the library. This makes it a robust and reliable choice for estimating nuisance parameters in high-dimensional or complex datasets, particularly in applications like biostatistics and epidemiology.\nHow does SuperLearner work? The SuperLearner algorithm consists of several steps:\n\nA library of candidate algorithms is specified in advance. This library may include both parametric models (e.g., logistic regression) and machine learning methods (e.g., random forests, gradient boosting).\nThe dataset is split into training and validation folds using cross-validation.\nEach algorithm is trained on the training folds and its predictive performance is evaluated on the validation folds using a suitable loss function (e.g., mean squared error).\nA meta-learner determines the optimal set of weights for combining the candidate models based on their cross-validated performance.\nThe final prediction is produced as a weighted average of the predictions from the candidate models.\n\nThis process ensures that the ensemble prediction is tailored to the data and performs at least as well as the best-performing model in the library.\nBenefits of SuperLearner SuperLearner offers a number of advantages over traditional parametric models when used in TMLE. It is highly flexible, adapting to the structure of the data without assuming a fixed functional form. This allows for more effective modeling of complex, nonlinear relationships. Model robustness is enhanced by combining multiple algorithms, reducing the risk that poor performance from any single model will degrade the overall estimator.\nBy improving the accuracy of nuisance parameter estimation, SuperLearner contributes to more efficient TMLE estimates, yielding smaller standard errors and tighter confidence intervals. The method also offers theoretical guarantees: under regularity conditions, SuperLearner is asymptotically optimal, performing as well as or better than any individual algorithm or convex combination in the library. SuperLearner is also highly customisable. A diverse library of algorithms, combining both machine learning and parametric models, can be defined to reflect the specific needs and characteristics of the data.\nOverall, the integration of SuperLearner within TMLE ensures that the procedure remains robust to model misspecification, data-adaptive, and efficient in finite samples.\n\n\n5.4.4 Comparison with other estimators\nTo see the benefit of using TMLE over other methods, we can run a simulation and compare the results from each of the methods against a known true value for the ATE. We simulated data on 1000 observations, estimated the ATE and standard error, then repeated the study 1000 times. Figure 5.1 shows the results of the simple simulation study.\nYou can see that the bias is smallest for TMLE and largest for the naive regression adjustment (RA) approach. TMLE benefits from not only using SuperLearner to define the exposure and outcome models but also from the targeting step. We could have used machine learning algorithms to define the exposure or outcome models for the other methods, such as AIPTW.\nThe lower half of the graph shows the coverage rate. This is proportion of confidence intervals from each method that contain the true value of the ATE. If we are trying to estimate 95% confidence intervals, then we should expect that the method contains the true value of the ATE 95% of the time. TMLE gives a coverage of 95.1%, which is almost perfect. Other methods have a much lower coverage rate, which also shows the beneficial properties of TMLE.\n\n\n\n\n\n\nFigure 5.1: Bias and coverage rate of various causal estimators in a simple simulation study.",
"crumbs": [
"Advanced Methods",
"<span class='chapter-number'>5</span> <span class='chapter-title'>Double-robust estimators</span>"
]
},
{
"objectID": "chapters/chapter5/index.html#cross-validated-targeted-maximum-likelihood-estimation",
"href": "chapters/chapter5/index.html#cross-validated-targeted-maximum-likelihood-estimation",
"title": "5 Double-robust estimators",
"section": "5.5 Cross-Validated Targeted Maximum Likelihood Estimation",
"text": "5.5 Cross-Validated Targeted Maximum Likelihood Estimation\nCross-Validated Targeted Maximum Likelihood Estimation (CV-TMLE) is an extension of TMLE designed to improve performance in finite samples, particularly when using flexible, data-adaptive methods such as machine learning for estimation of nuisance parameters. CV-TMLE incorporates cross-validation directly into the targeting step of the TMLE procedure, rather than using cross-validation solely for model selection prior to estimation. This results in more stable estimates and better control of overfitting, especially when sample sizes are modest or when the estimation of the outcome regression or propensity score is highly variable.\n\n5.5.1 Motivation and Advantages over TMLE\nWhile standard TMLE already enjoys double robustness and asymptotic efficiency when both models are correctly specified, it may perform poorly in small samples if the machine learning estimators overfit the training data. Standard TMLE typically involves estimating the initial outcome regression and propensity score on the full dataset, which can lead to optimistic predictions and targeted updates that fail to generalize. CV-TMLE addresses this by ensuring that the data used to perform the targeting step is distinct from the data used to estimate the initial regressions.\nKey advantages of CV-TMLE include:\n\nImproved finite-sample performance by reducing overfitting bias.\nBetter alignment between cross-validation and influence function-based inference.\nIncreased stability of the targeted update, especially when using machine learning.\n\n\n\n5.5.2 Cross-Validation for Model Selection and Overfitting Prevention\nCross-validation is a common strategy for selecting among multiple candidate learners (e.g., via Super Learner), but in CV-TMLE, it plays an additional role. Instead of using cross-validation only to choose the best prediction algorithm, CV-TMLE partitions the data into \\(V\\) folds and performs the entire TMLE procedure separately in each validation fold. The influence function contributions from each fold are then aggregated to produce the final estimate and standard error.\nThis prevents the targeted update from leveraging overfit predictions and leads to a more valid approximation of the efficient influence function, especially when the sample size is small or when the nuisance functions are highly adaptive.\n\n\n5.5.3 Steps in CV-TMLE Estimation\nThe CV-TMLE algorithm proceeds as follows:\n\nSplit the data into \\(V\\) folds (commonly \\(V=10\\)).\nFor each fold:\n\nEstimate the initial outcome regression \\(Q(A, X)\\) and propensity score \\(g(A \\mid X)\\) on the training set.\nPredict \\(Q\\) and \\(g\\) for the validation set.\nPerform the TMLE fluctuation (targeting step) only on the validation set using the predicted values.\nCompute the influence function contribution for each observation in the validation set.\n\nAggregate influence function values across all folds to compute the final estimate.\nEstimate the variance using the empirical variance of the influence function.\n\n\n\n5.5.4 R Implementation Using tmle3 or ltmle\ntmle3 provides a modular, object-oriented interface for performing TMLE and CV-TMLE in R. A typical implementation involves specifying the likelihood, the treatment mechanism, the outcome regression, and the TMLE task.\nlibrary(tmle3)\nlibrary(sl3)\n\n# Define the nodes\ntmle_spec <- tmle_ATE(\n treatment_level = 1,\n control_level = 0\n)\n\n# Define learner library (e.g., Super Learner)\nlearner <- Lrnr_sl$new(learners = c(\"Lrnr_mean\", \"Lrnr_glm\"))\n\n# Define likelihood and task\ntmle_task <- tmle_spec$make_tmle_task(data, node_list)\nlikelihood <- tmle_spec$make_initial_likelihood(tmle_task, learner)\n\n# Run CV-TMLE\ntmle_fit <- tmle_spec$tmle_update(tmle_task, likelihood)\nsummary(tmle_fit)\nAlternatively, the ltmle package can also be used to perform CV-TMLE when working with longitudinal or time-to-event data, although the interface is more prescriptive.\n\n\n5.5.5 Discussion of Small-Sample Behavior\nIn small to moderate samples, the benefits of CV-TMLE become especially clear. The standard TMLE may exhibit instability due to overfitting of the initial estimators, particularly when using highly adaptive algorithms such as random forests or neural networks. By ensuring that targeting is performed on out-of-sample predictions, CV-TMLE avoids this problem and more closely approximates the behavior of the estimator in large samples.\nEmpirical studies have shown that CV-TMLE achieves better coverage of confidence intervals and lower mean squared error in small samples, particularly when the complexity of the outcome or treatment models is high. As such, CV-TMLE is now regarded as a default strategy in many machine-learning-integrated causal inference pipelines.\n\n\n\n\n\n\nNoteTwo Layers of Cross-Validation in CV-TMLE\n\n\n\n1. Cross-validation in the Super Learner: Used to optimize prediction of nuisance parameters: - Outcome regression: $ Q(A, X) = [Y A, X] $ - Propensity score: $ g(A X) = (A = 1 X) $\nSuper Learner performs internal $ V $-fold cross-validation to evaluate and combine learners based on predictive performance. This layer is solely focused on choosing the best-fitting models for the nuisance functions.\n2. Cross-validation in CV-TMLE: Used to improve estimation of the target parameter (e.g., ATE) and valid inference: - The dataset is split into $ V $ folds. - Nuisance functions are trained on $ V-1 $ folds and predictions are made on the held-out fold. - The TMLE targeting step and influence curve calculations are performed on the held-out fold.\nThis ensures that the targeted update and standard error are based on out-of-sample predictions, reducing overfitting and improving the validity of inference.\nIn summary: Cross-validation in the Super Learner is for better prediction; cross-validation of TMLE is for valid estimation and inference.\n\n\n\n\n5.5.6 Summary\nCross-validated TMLE extends the benefits of TMLE to smaller samples and high-dimensional settings by embedding cross-validation directly into the targeting procedure. It mitigates overfitting, improves stability, and provides more accurate inference, particularly when leveraging flexible machine learning methods to estimate nuisance parameters. The procedure is supported in tmle3, ltmle, and other implementations within the targeted learning ecosystem.",
"crumbs": [
"Advanced Methods",
"<span class='chapter-number'>5</span> <span class='chapter-title'>Double-robust estimators</span>"
]
},
{
"objectID": "chapters/chapter5/index.html#conclusion",
"href": "chapters/chapter5/index.html#conclusion",
"title": "5 Double-robust estimators",
"section": "5.6 Conclusion",
"text": "5.6 Conclusion",
"crumbs": [
"Advanced Methods",
"<span class='chapter-number'>5</span> <span class='chapter-title'>Double-robust estimators</span>"
]
},
{
"objectID": "chapters/chapter5/index.html#glossary",
"href": "chapters/chapter5/index.html#glossary",
"title": "5 Double-robust estimators",
"section": "5.7 Glossary",
"text": "5.7 Glossary\n\nTMLE\n\nTargeted Maximum Likelihood Estimation\n\n\n\n\n\n\nBang, H., & Robins, J. M. (2005). Doubly robust estimation in missing data and causal inference models. Biometrics, 61(4), 962–973.\n\n\nDaniel, R. M. (2018). Double robustness. In Wiley StatsRef: Statistics reference online (pp. 1–14). Wiley. https://doi.org/10.1002/9781118445112.stat08068\n\n\nGruber, S., & Laan, M. J. van der. (2012). Tmle: An r package for targeted maximum likelihood estimation. Journal of Statistical Software, 51(13), 1–35. https://doi.org/10.18637/jss.v051.i13\n\n\nGruber, S., & Laan, M. van der. (2009). Targeted maximum likelihood estimation: A gentle introduction. U.C. Berkeley Division of Biostatistics Working Paper Series. https://biostats.bepress.com/ucbbiostat/paper252\n\n\nGruber, S., & Laan, M. van der. (2011). Tmle: An r package for targeted maximum likelihood estimation. U.C. Berkeley Division of Biostatistics Working Paper Series.\n\n\nKennedy, E. H. (2016). Semiparametric theory and empirical processes in causal inference (pp. 141–167). Springer.\n\n\nLuque-Fernandez, M. A., Belot, A., Valeri, L., Cerulli, G., Maringe, C., & Rachet, B. (2018). Data-adaptive estimation for double-robust methods in population-based cancer epidemiology: Risk differences for lung cancer mortality by emergency presentation. American Journal of Epidemiology, 187(4), 871–878. https://doi.org/10.1093/aje/kwx317\n\n\nLuque-Fernandez, M. A., Schomaker, M., Rachet, B., & Schnitzer, M. E. (2018). Targeted maximum likelihood estimation for a binary treatment: A tutorial. Statistics in Medicine, 37(16), 2530–2546. https://doi.org/10.1002/sim.7628\n\n\nRobins, J. M., Rotnitzky, A., & Zhao, L. P. (1994). Estimation of regression coefficients when some regressors are not always observed. Journal of the American Statistical Association, 89(427), 846–866. http://www.jstor.org/stable/2290910\n\n\nSchuler, M. S., & Rose, S. (2017). Targeted maximum likelihood estimation for causal inference in observational studies. American Journal of Epidemiology, 185(1), 65–73. https://doi.org/10.1093/aje/kww165\n\n\nTsiatis, A. A., Davidian, M., Kang, J. D. Y. Y., & Schafer, J. L. (2007). Demystifying double robustness: A comparison of alternative strategies for estimating a population mean from incomplete data. Statistical Science, 22(4), 523–539. https://doi.org/10.1214/07-STS227",
"crumbs": [
"Advanced Methods",
"<span class='chapter-number'>5</span> <span class='chapter-title'>Double-robust estimators</span>"
]
},
{
"objectID": "chapters/chapter6/index.html",
"href": "chapters/chapter6/index.html",
"title": "6 Causal Inference for Longitudinal Data",
"section": "",
"text": "6.1 Part I: Multiple Time-Point Interventions\nThe previous chapters have described methods that are used when the intervention occurs at only one time point. Often, there are settings where the intervention occurs at multiple time points. Such settings could be a chemotherapy given to patients with cancer at regular intervals, a series of public health policies designed to reduce environmental impact on the population’s health over time, or how health outcomes change over time within certain geographical clusters.\n==Longitudinal TMLE==. (Lendle et al., 2017)\nThis chapter is split into two parts. Part I explores methods for multiple time point interventions and Part II explores methods for time-to-event outcomes.",
"crumbs": [
"Advanced Methods",
"<span class='chapter-number'>6</span> <span class='chapter-title'>Causal Inference for Longitudinal Data</span>"
]
},
{
"objectID": "chapters/chapter6/index.html#part-i-multiple-time-point-interventions",
"href": "chapters/chapter6/index.html#part-i-multiple-time-point-interventions",
"title": "6 Causal Inference for Longitudinal Data",
"section": "",
"text": "6.1.1 Time-Varying Confounding and Its Challenges\nOne of the most significant challenges in causal inference for longitudinal data is the presence of time-varying confounding. In a longitudinal setting, confounders are measured repeatedly over time and may both influence and be influenced by prior treatment. This feedback loop creates a fundamental difficulty for standard statistical methods.\nTo understand the problem, consider covariates \\(L_t\\) that affect treatment decisions \\(A_t\\) at each time \\(t\\), but are themselves affected by earlier treatment \\(A_{t-1}\\). In this case, \\(L_t\\) serves as both a confounder (affecting treatment and outcome) and a mediator (affected by prior treatment). Adjusting for \\(L_t\\) using standard regression methods may induce bias by conditioning on a variable on the causal pathway or introducing collider bias.\nThis situation violates one of the key assumptions required for unbiased estimation in standard regression: that adjustment covariates are not affected by the exposure. In longitudinal settings, naive adjustment for time-varying confounders using outcome regression can therefore produce biased effect estimates.\nFor example, in the context of HIV treatment, CD4 count is a time-varying confounder: it predicts future treatment decisions (whether to initiate or modify ART) and also predicts the outcome (e.g., mortality). But CD4 count is also affected by prior ART exposure. If we adjust for CD4 count in a regression model, we may block part of the effect of ART or introduce bias through conditioning on a collider.\nThis motivates the use of methods specifically designed to handle time-varying confounding, such as: - Inverse Probability of Treatment Weighting (IPTW): Reweights individuals to create a pseudo-population in which treatment is independent of time-varying confounders. - G-computation: Uses the g-formula to model the joint distribution of covariates and outcomes under a specific treatment regime. - Doubly Robust Estimators: Combine outcome modeling and treatment modeling to protect against misspecification of either.\nThese methods rely on sequential models that reflect the time-varying structure of the data and appropriately account for dynamic confounding.\n\n\n6.1.2 Motivating Examples from Longitudinal Studies\nLongitudinal data arise frequently in medicine, public health, economics, and the social sciences, where individuals are followed over time and data are collected at multiple time points. These repeated measurements offer rich opportunities to understand how treatments, exposures, or policies influence outcomes over time. However, the time-varying nature of treatments and confounders introduces methodological challenges for causal inference.\nA classic motivating example comes from the HIV treatment literature. Consider a study evaluating the effect of initiating antiretroviral therapy (ART) on survival among HIV-positive individuals. Treatment initiation may depend on evolving clinical indicators such as CD4 cell count or viral load. These indicators also influence prognosis and are themselves affected by earlier treatment decisions. Thus, CD4 count acts as a time-varying confounder that is affected by prior treatment. Standard regression methods that adjust for CD4 count at each time point may introduce bias by blocking part of the treatment effect or conditioning on a collider.\nAnother example is the management of blood pressure over time. Patients with hypertension may begin or adjust medications based on current blood pressure readings, which in turn are influenced by prior treatment. Smoking cessation interventions, weight loss programs, and mental health treatments are further domains where longitudinal data play a central role.\nThese settings share common features: time-varying exposures, time-varying confounders, and outcomes measured after repeated decisions. In such contexts, specialized methods are required to estimate causal effects, including marginal structural models, the g-formula, and doubly robust estimators.\n\n\n6.1.3 Notation for Longitudinal Data\nTo formalize the discussion of causal inference with longitudinal data, we introduce notation to represent the sequence of treatments, covariates, and outcomes over time.\nLet \\(t = 0, 1, \\dots, T\\) denote discrete time points. For an individual \\(i\\), define: - \\(A_t\\): treatment or exposure at time \\(t\\) - \\(L_t\\): time-varying covariates measured at time \\(t\\) - \\(\\bar{A}_t = (A_0, A_1, \\dots, A_t)\\): treatment history up to and including time \\(t\\) - \\(\\bar{L}_t = (L_0, L_1, \\dots, L_t)\\): covariate history up to and including time \\(t\\) - \\(Y\\): outcome of interest, measured at time \\(T+1\\) or at the end of follow-up - \\(C_t\\): indicator of censoring at time \\(t\\), where \\(C_t = 1\\) if censored at time \\(t\\)\nWe use capital letters to denote random variables and lowercase letters for their realizations. For example, \\(a_t\\) is a specific value of \\(A_t\\). The notation \\(Y^{\\bar{a}}\\) refers to the potential outcome that would be observed under the treatment regime \\(\\bar{a} = (a_0, a_1, \\dots, a_T)\\).\nIn addition, we define the data structure for each individual as: \\[\nO = (L_0, A_0, L_1, A_1, \\dots, L_T, A_T, Y).\n\\]\nThis longitudinal data structure allows for dynamic treatment strategies that may assign treatment at time \\(t\\) based on past covariate and treatment history. The goal of causal inference in this setting is to estimate the average causal effect of a treatment regime \\(\\bar{a}\\) on the outcome \\(Y\\), denoted: \\[\nE[Y^{\\bar{a}}].\n\\]\nThis framework forms the foundation for the causal models and estimators introduced in subsequent sections.\nR Example (Simulating Longitudinal Data):\nn <- 1000\nset.seed(123)\n\nL0 <- rnorm(n)\nA0 <- rbinom(n, 1, plogis(0.5 * L0))\nL1 <- 0.5 * L0 + 0.8 * A0 + rnorm(n)\nA1 <- rbinom(n, 1, plogis(0.5 * L1))\nY <- 0.7 * L1 + 1.2 * A1 + rnorm(n)\n\ndata <- data.frame(L0, A0, L1, A1, Y)\nhead(data)\nA DAG helps illustrate the challenge of time-varying confounding. Consider the following structure over two time points:\n\n\nShow the code\ngraph LR\n L0((L0)) --> A0((A0))\n A0 --> L1((L1))\n L1 --> A1((A1))\n A1 --> Y((Y))\n L0 -.-> L1\n L1 -.-> Y\n A0 -.-> A1\n\n\n\n\n\n\n\n\n\n\n\nIn this DAG, \\(L_1\\) is influenced by \\(A_0\\), and \\(A_1\\) is influenced by \\(L_1\\), which in turn affects the outcome \\(Y\\). Adjusting for \\(L_1\\) blocks part of the effect of \\(A_0\\), resulting in bias.\nR Example (Illustrating Bias with Standard Regression):\n# Simulate data\nset.seed(123)\nn <- 1000\nL0 <- rnorm(n)\nA0 <- rbinom(n, 1, plogis(0.5 * L0))\nL1 <- 0.5 * L0 + 0.8 * A0 + rnorm(n)\nA1 <- rbinom(n, 1, plogis(0.5 * L1))\nY <- 0.7 * L1 + 1.2 * A1 + rnorm(n)\n\ndata <- data.frame(L0, A0, L1, A1, Y)\n\n# Standard regression adjusting for L1\nmodel_naive <- lm(Y ~ A0 + A1 + L1, data = data)\nsummary(model_naive)\nThis regression model adjusts for \\(L_1\\), which is affected by \\(A_0\\), leading to biased estimates for the effect of \\(A_0\\). Methods such as IPTW avoid this bias by reweighting rather than conditioning.\nUnderstanding time-varying confounding is critical for correctly estimating causal effects in longitudinal studies. The remainder of this chapter will focus on formalizing these ideas and presenting estimators that properly handle this complexity.\n\n\n6.1.4 G-computation and the G-formula for Longitudinal Data\nThe g-formula, introduced by Robins (1986), provides a way to estimate causal effects from longitudinal data in the presence of time-varying confounding. In longitudinal studies, standard regression methods often fail to provide valid causal estimates when time-varying confounders are also affected by prior treatment. This situation arises commonly in practice, especially in observational studies where treatment decisions are made based on intermediate health status, which itself may be influenced by earlier treatments. The g-formula resolves this problem by using a model-based standardisation approach to compute counterfactual outcomes under hypothetical treatment interventions.\n\nMotivating Setting\nSuppose data are collected over \\(K\\) time points. At each time \\(t\\) \\((t = 0, \\dots, K)\\), we observe time-varying covariates \\(L_t\\), treatment variables \\(A_t\\), and eventually an outcome \\(Y\\). The goal is to estimate the causal effect of a treatment strategy \\(\\bar{a} = (a_0, a_1, \\ldots, a_K)\\) on the outcome \\(Y\\).\nLet \\(\\bar{A}_t = (A_0, A_1, \\dots, A_t)\\) and \\(\\bar{L}_t = (L_0, L_1, \\dots, L_t)\\) denote the treatment and covariate history, respectively. The counterfactual outcome under a specific treatment strategy \\(\\bar{a}\\) is denoted \\(Y^{\\bar{a}}\\). We aim to estimate \\(E[Y^{\\bar{a}}]\\), the expected outcome if all individuals had received treatment strategy \\(\\bar{a}\\).\n\n\nThe Longitudinal G-formula\nThe g-formula expresses this quantity as: \\[\nE[Y^{\\bar{a}}] = \\int_{\\bar{l}} E[Y \\mid \\bar{A}_K = \\bar{a}, \\bar{L}_K = \\bar{l}] \\prod_{t=0}^{K} f(L_t \\mid \\bar{L}_{t-1} = \\bar{l}_{t-1}, \\bar{A}_t = \\bar{a}_t) d\\bar{l}\n\\]\nIn practice, this formula is approximated using parametric regression models and Monte Carlo simulation. It decomposes the joint distribution of the data into a sequence of conditional models. Each covariate and the outcome are modeled conditionally on the observed treatment and covariate history.\n\n\nStep-by-Step Estimation Procedure\n\nModel the data-generating process. Specify models for each time-varying covariate \\(L_t\\) and the final outcome \\(Y\\), conditioning on previous covariates and treatments.\nSimulate counterfactuals. For each individual, simulate covariates and outcomes under a specific intervention strategy \\(\\bar{a}\\). This requires sequentially predicting covariates \\(L_t\\) using the fitted models, and using these to predict the outcome \\(Y\\).\nAverage the counterfactual outcomes. Estimate \\(E[Y^{\\bar{a}}]\\) by averaging the predicted counterfactual outcomes across the simulated pseudo-population.\n\n\n\nIllustrative Example in R\nWe now provide a full example using simulated data with two time points.\n# Simulate longitudinal data\nset.seed(42)\nn <- 1000\nL0 <- rnorm(n)\nA0 <- rbinom(n, 1, plogis(0.3 * L0))\nL1 <- rnorm(n, mean = 0.5 * A0 + 0.6 * L0)\nA1 <- rbinom(n, 1, plogis(0.4 * A0 + 0.7 * L1))\nY <- rbinom(n, 1, plogis(-1 + 0.8 * A1 + 0.6 * L1 + 0.3 * A0))\n\nlong_data <- data.frame(L0, A0, L1, A1, Y)\nWe now implement parametric g-computation to estimate the outcome under the intervention \\(A_0 = 1, A_1 = 1\\).\n# Step 1: Fit models for L1 and Y\nmodel_L1 <- lm(L1 ~ A0 + L0, data = long_data)\nmodel_Y <- glm(Y ~ A0 + A1 + L1, data = long_data, family = binomial())\n\n# Step 2: Simulate under intervention A0 = A1 = 1\nnew_data <- long_data\nnew_data$A0 <- 1\nnew_data$A1 <- 1\nnew_data$L1 <- predict(model_L1, newdata = new_data)\nnew_data$Y_hat <- predict(model_Y, newdata = new_data, type = \"response\")\n\n# Step 3: Estimate E[Y^{a}]\ng_formula_estimate <- mean(new_data$Y_hat)\nprint(g_formula_estimate)\nTo assess uncertainty, nonparametric bootstrap can be used to obtain confidence intervals.\n\n\nAssumptions\nThe validity of the g-formula relies on three assumptions: - Consistency: The observed outcome equals the counterfactual outcome for the observed treatment history. - Positivity: There is a positive probability of receiving each treatment level for all covariate patterns. - Sequential Exchangeability (No Unmeasured Confounding): \\[\nY^{\\bar{a}} \\perp A_t \\mid \\bar{A}_{t-1}, \\bar{L}_t \\quad \\text{for all } t\n\\]\n\n\nInterpretation and Extensions\nThe g-formula provides a consistent estimate of the counterfactual mean outcome under a static or dynamic treatment strategy. It generalizes standardization by incorporating time-varying covariates and treatments. The method can also be extended to simulate more complex interventions, such as treatment rules that depend on patient history.\nWhile powerful, the g-formula is sensitive to model misspecification. Every component of the data-generating process must be modeled correctly. In practice, this often requires rich data and careful model diagnostics. Flexible modeling approaches, such as Super Learner, can improve robustness to misspecification.\n\n\nSummary\nThe longitudinal g-formula is a foundational method for estimating causal effects in the presence of time-varying confounding. It is well-suited for estimating population-level effects of hypothetical interventions in longitudinal data, especially when conventional regression methods are biased due to treatment-confounder feedback. Although computationally intensive and model-dependent, it serves as a conceptual and methodological precursor to more robust estimators like TMLE.\n\n\n\n6.1.5 Marginal Structural Models\nMarginal Structural Models (MSMs) are a class of causal models designed to estimate the marginal effect of a time-varying treatment or exposure on an outcome in the presence of time-varying confounding. Unlike traditional regression models, which condition on time-varying confounders that may be affected by prior treatment, MSMs allow for valid causal inference by modeling the treatment-outcome relationship marginally – that is, without conditioning on such intermediate variables.\nIn longitudinal settings, the central challenge arises when confounders are affected by prior treatment. Adjusting for these confounders in a standard regression model can introduce bias, because it blocks part of the causal pathway from treatment to outcome. MSMs overcome this problem by modeling the counterfactual mean outcomes under different treatment regimes, while using inverse probability weighting (IPW) to account for confounding.\nLet \\(\\bar{A}_t = (A_0, A_1, \\ldots, A_t)\\) be the history of treatments up to time \\(t\\), and let \\(Y\\) be the outcome measured at a final time point \\(T\\). The goal of an MSM is to estimate:\n\\[\n\\mathbb{E}[Y^{\\bar{a}}]\n\\]\nfor different treatment regimens \\(\\bar{a}\\). These counterfactual means are modeled directly, without conditioning on intermediate covariates.\nA typical form of an MSM is:\n\\[\n\\mathbb{E}[Y^{\\bar{a}}] = \\beta_0 + \\beta_1 a_0 + \\beta_2 a_1 + \\cdots + \\beta_T a_T\n\\]\nThis model expresses the expected counterfactual outcome as a function of the treatment history. It can be generalized to allow for interactions, nonlinear effects, or cumulative dose effects. For binary outcomes, the model might be fit on the log-odds scale using a logistic link.\nBecause the true counterfactuals are not observed, MSMs are estimated using the observed outcomes weighted by the inverse probability of treatment. Inverse Probability Weighting (IPW) is a method used to address time-varying confounding in longitudinal observational studies. It reweights the sample to create a pseudo-population in which treatment assignment at each time point is independent of past confounders. This approach enables unbiased estimation of marginal causal effects when traditional regression adjustment would fail due to feedback between treatment and covariates.\nIn longitudinal studies, confounders measured at time \\(t\\), denoted \\(L_t\\), often affect subsequent treatment \\(A_t\\) and are themselves influenced by prior treatment \\(A_{t-1}\\). This dual role of \\(L_t\\) as both a confounder and an intermediate variable invalidates standard regression techniques, which cannot properly adjust for such variables without introducing bias.\nTo estimate the effect of a treatment regime \\(\\bar{a} = (a_0, \\dots, a_T)\\), we use IPW to account for the time-varying nature of both treatment and confounding. This involves modeling the treatment mechanism over time and assigning weights to each individual based on the inverse of their probability of receiving their observed treatment history, conditional on their covariate history.\nLet \\(\\hat{e}_t(W_t) = P(A_t = a_t \\mid \\bar{A}_{t-1}, \\bar{L}_t)\\) denote the estimated probability of treatment at time \\(t\\), given past treatment and covariate history. The unstabilized IP weight is: \\[\nW_i = \\prod_{t=0}^T \\frac{1}{P(A_t = a_t \\mid \\bar{A}_{t-1}, \\bar{L}_t)}.\n\\]\nStabilized weights are often preferred to reduce variance and improve finite sample performance. They are constructed by placing a numerator that only depends on baseline or prior covariates: \\[\nW_i^{stab} = \\prod_{t=0}^T \\frac{P(A_t = a_t \\mid \\bar{A}_{t-1})}{P(A_t = a_t \\mid \\bar{A}_{t-1}, \\bar{L}_t)}.\n\\]\nMore generally,\n\\[\nW_i = \\prod_{t=0}^T \\frac{f(A_t = a_t^i \\mid \\bar{A}_{t-1}^i)}{f(A_t = a_t^i \\mid \\bar{L}_t^i, \\bar{A}_{t-1}^i)}\n\\]\nThese stabilized weights create a pseudo-population in which treatment is independent of confounders, allowing consistent estimation of the MSM parameters via weighted regression.\n\nEstimate the treatment model at each time point using logistic regression or machine learning to obtain probabilities \\(P(A_t \\mid \\bar{L}_t, \\bar{A}_{t-1})\\).\nCompute stabilized IP weights for each individual across all time points.\nFit the MSM using a weighted regression model, regressing the outcome on treatment history, using the IP weights.\n\nThe parameters in an MSM can be interpreted as the causal effect of treatment on the outcome, averaged over the population. For example, \\(\\beta_1\\) in the above model reflects the marginal causal effect of treatment at time \\(t=0\\), assuming correct model specification and no unmeasured confounding.\nMSMs can be extended to:\n\nEstimate causal risk differences, odds ratios, or hazard ratios\nAllow for dynamic treatment rules or effect modification\nHandle survival outcomes using marginal structural Cox models\nUse flexible models (e.g., SuperLearner) for treatment mechanism\n\nMSMs rely on key assumptions:\n\nNo unmeasured confounding: All confounders of the treatment-outcome relationship must be measured.\nPositivity: There must be a non-zero probability of receiving each treatment at every level of confounders.\nCorrect model specification: For consistent estimation, both the treatment model and the MSM must be correctly specified.\n\nIf these assumptions are violated, the MSM estimates may be biased or unstable. Weight truncation or flexible machine learning methods are often used to mitigate some of these issues.\n\n\n6.1.6 Weighted Regression to Estimate the Causal Effect\n# Simulated longitudinal data\nset.seed(123)\nn <- 1000\nL0 <- rnorm(n)\nA0 <- rbinom(n, 1, plogis(0.4 * L0))\nL1 <- 0.7 * L0 + 0.9 * A0 + rnorm(n)\nA1 <- rbinom(n, 1, plogis(0.4 * L1))\nY <- 1.5 * A0 + 1.2 * A1 + 0.5 * L1 + rnorm(n)\n\ndata <- data.frame(L0, A0, L1, A1, Y)\n\n# Numerator models (simpler)\nnum_A0 <- glm(A0 ~ L0, family = binomial, data = data)\nnum_A1 <- glm(A1 ~ A0 + L0, family = binomial, data = data)\n\n# Denominator models (full)\nden_A0 <- glm(A0 ~ L0, family = binomial, data = data)\nden_A1 <- glm(A1 ~ A0 + L0 + L1, family = binomial, data = data)\n\n# Get predicted probabilities\npnum_A0 <- predict(num_A0, type = \"response\")\npnum_A1 <- predict(num_A1, type = \"response\")\npden_A0 <- predict(den_A0, type = \"response\")\npden_A1 <- predict(den_A1, type = \"response\")\n\n# Compute stabilized weights\nw_A0 <- ifelse(data$A0 == 1, pnum_A0 / pden_A0, (1 - pnum_A0) / (1 - pden_A0))\nw_A1 <- ifelse(data$A1 == 1, pnum_A1 / pden_A1, (1 - pnum_A1) / (1 - pden_A1))\ndata$sw <- w_A0 * w_A1\nsummary(data$sw)\nOnce the stabilized weights are estimated, they are used to fit a weighted regression model to estimate the marginal causal effect:\nmodel_weighted <- glm(Y ~ A0 + A1, weights = sw, data = data)\nsummary(model_weighted)\nThis regression provides an estimate of the average treatment effect under the assumption of no unmeasured confounding and correct model specification for the treatment assignment.\nInverse probability weighting is foundational for marginal structural models and plays a central role in modern causal inference for longitudinal data. While powerful, IPW requires careful diagnostics for positivity violations and extreme weights, which are discussed in later sections.\n\n\n6.1.7 Targeted Maximum Likelihood Estimation for Longitudinal Data\nLongitudinal Targeted Maximum Likelihood Estimation (LTMLE) extends the TMLE framework to settings with time-varying exposures and confounders. It provides doubly robust and asymptotically efficient estimates of causal effects, including the average treatment effect under dynamic intervention rules. In the longitudinal context, the method applies an iterative targeting step moving backward in time, updating the predicted outcome at each step to align with the causal parameter of interest (M. Schomaker, 2019; vanderLaan2011?).\nLet \\(\\bar{A}_t = (A_0, \\dots, A_t)\\), \\(\\bar{L}_t = (L_0, \\dots, L_t)\\), and \\(Y_T\\) be the outcome at the final time point \\(T\\). Let \\(\\bar{d}_t\\) denote a dynamic treatment rule. The target parameter is: \\[\n\\psi_T = \\mathbb{E}\\left[ Y_T^{\\bar{d}} \\right],\n\\] where \\(Y_T^{\\bar{d}}\\) is the counterfactual outcome under the treatment regime \\(\\bar{d}\\).\nLTMLE involves the following steps:\n\nInitial outcome model (Q-model): Regress \\(Y_T\\) on \\(\\bar{A}_T\\) and \\(\\bar{L}_T\\) to estimate \\(Q_T^0 = \\mathbb{E}(Y_T \\mid \\bar{A}_T, \\bar{L}_T)\\). Then recursively, for each \\(t = T-1, \\dots, 0\\), estimate: \\[\nQ_t^0 = \\mathbb{E}(Q_{t+1}^1 \\mid \\bar{A}_t, \\bar{L}_t),\n\\] where \\(Q_{t+1}^1\\) is the updated outcome from the targeting step.\nTreatment and censoring models (g-models): Estimate the treatment mechanism \\(g_t(A_t \\mid \\bar{A}_{t-1}, \\bar{L}_t)\\) and the censoring mechanism \\(c_t(C_t \\mid \\bar{A}_t, \\bar{L}_t)\\).\nClever covariates: Define the clever covariate: \\[\nH_t = \\prod_{s=0}^{t-1} \\frac{\\mathbb{I}(A_s = d_s) \\cdot \\mathbb{I}(C_s = 1)}{g_s(A_s \\mid \\bar{L}_s, \\bar{A}_{s-1}) \\cdot c_s(C_s \\mid \\bar{A}_s, \\bar{L}_s)}.\n\\]\nTargeting step: For each \\(t\\), update \\(Q_t^0\\) using a fluctuation model: \\[\n\\text{logit}(Q_t^1) = \\text{logit}(Q_t^0) + \\epsilon H_t,\n\\] where \\(\\epsilon\\) is estimated by fitting a logistic regression with \\(Q_t^0\\) as the offset and \\(H_t\\) as the covariate.\nEstimation of \\(\\psi_T\\): The final estimate is obtained as: \\[\n\\hat{\\psi}_T = \\frac{1}{n} \\sum_{i=1}^n Q_0^1(A_0 = d_0, L_0).\n\\]\nInference: Estimate standard errors using the empirical variance of the efficient influence function.\n\nManual Example (by hand)\nConsider a setting with two time points (\\(t=0,1\\)) and a binary outcome \\(Y\\). Let \\(A_0, A_1\\) denote treatment at each time, and \\(L_0, L_1\\) covariates. Suppose we fit logistic regression models for the Q-model and g-models, and calculate clever covariates as above. We update \\(Q_1^0\\) using: \\[\n\\begin{aligned}\n\\text{logit}(Q_1^1) &= \\text{logit}(Q_1^0) + \\epsilon_1 H_1, \\\\\n\\text{logit}(Q_0^1) &= \\text{logit}(Q_0^0) + \\epsilon_0 H_0.\n\\end{aligned}\n\\]\nWe then plug in the values \\(A_0 = d_0, A_1 = d_1\\) and average the final predictions to obtain \\(\\hat{\\psi}_T\\).\n# Simulate simple data\nset.seed(123)\nn <- 500\nL0 <- rbinom(n, 1, 0.5)\nA0 <- rbinom(n, 1, plogis(-0.5 + 0.8 * L0))\nL1 <- rbinom(n, 1, plogis(0.3 * A0 + 0.4 * L0))\nA1 <- rbinom(n, 1, plogis(-0.4 + 0.5 * L1 + 0.3 * A0))\nY <- rbinom(n, 1, plogis(-1 + 0.6 * A1 + 0.5 * L1 + 0.2 * A0))\ndata <- data.frame(L0, A0, L1, A1, Y)\n\n# Step 1: Estimate Q2 (E[Y | A0, A1, L0, L1])\nQ2_model <- glm(Y ~ A0 + A1 + L0 + L1, data = data, family = binomial)\nQ2_pred <- predict(Q2_model, type = \"response\")\n\n# Step 2: Estimate Q1 (E[Q2 | A0, L0, L1])\ndata$Q2 <- Q2_pred\nQ1_model <- glm(Q2 ~ A0 + L0 + L1, data = data, family = binomial)\nQ1_pred <- predict(Q1_model, type = \"response\")\n\n# Step 3: Estimate g models (treatment mechanism)\ng1 <- glm(A1 ~ A0 + L0 + L1, data = data, family = binomial)\ng1_pred <- predict(g1, type = \"response\")\n\n# Step 4: Calculate clever covariate for A1 = 1\ndata$H1 <- ifelse(A1 == 1, 1 / g1_pred, 0)\n\n# Step 5: Target Q2 using clever covariate\nfluct_model <- glm(Y ~ -1 + offset(qlogis(Q2_pred)) + H1, data = data, family = binomial)\nepsilon <- coef(fluct_model)[\"H1\"]\nQ2_star <- plogis(qlogis(Q2_pred) + epsilon * data$H1)\n\n# Step 6: Plug in A0=1, A1=1 to get counterfactual prediction\nnew_data <- data\nnew_data$A0 <- 1\nnew_data$A1 <- 1\nQ2_cf <- predict(Q2_model, newdata = new_data, type = \"response\")\nATE <- mean(Q2_cf) - mean(Q2_pred)\nATE\nThis provides a manual implementation of TMLE for a simple longitudinal setup.\nExample Using ltmle in R\nlibrary(ltmle)\ndata(longData)\n\n# Define nodes\nAnodes <- c(\"A0\", \"A1\")\nLnodes <- c(\"L0\", \"L1\")\nYnodes <- \"Y\"\n\n# Fit LTMLE under a static intervention (always treat)\nresult <- ltmle(data = longData,\n Anodes = Anodes,\n Lnodes = Lnodes,\n Ynodes = Ynodes,\n abar = c(1,1),\n SL.library = c(\"SL.glm\", \"SL.gam\", \"SL.mean\"))\n\nsummary(result)\nThis code estimates the expected outcome had everyone received treatment at both time points using SuperLearner to fit nuisance models. The output includes point estimates, standard errors, and confidence intervals.\nIn summary, LTMLE provides a powerful and flexible approach for estimating causal effects in longitudinal studies with multiple time-point interventions and a single outcome. It combines double robustness, semiparametric efficiency, and machine learning adaptability, making it particularly suitable for complex, real-world longitudinal data.",
"crumbs": [
"Advanced Methods",
"<span class='chapter-number'>6</span> <span class='chapter-title'>Causal Inference for Longitudinal Data</span>"
]
},
{
"objectID": "chapters/chapter6/index.html#part-ii-time-to-event-outcome",
"href": "chapters/chapter6/index.html#part-ii-time-to-event-outcome",
"title": "6 Causal Inference for Longitudinal Data",
"section": "6.2 Part II: Time-to-event outcome",
"text": "6.2 Part II: Time-to-event outcome\n\n6.2.1 Brief Introduction to Censoring and Competing Risks\nIn longitudinal studies, participants are followed over time to assess the effect of treatments or exposures on outcomes of interest. However, complete follow-up for all individuals is rarely achieved. When an individual’s data become unavailable before the outcome is observed, the data are said to be censored. Censoring can arise from loss to follow-up, study dropout, or administrative end of study.\nCensoring is problematic because it introduces missing data in the outcome and may bias effect estimates if the reason for censoring is related to treatment or covariates. The standard assumption for valid inference in the presence of censoring is independent censoring–that is, the probability of being censored at any time depends only on observed covariates and treatment history, not on unmeasured factors or the potential outcomes themselves.\nLet \\(C_t\\) be the indicator that a subject is censored at time \\(t\\), and define the observed data structure as: \\[\nO = (L_0, A_0, C_0, L_1, A_1, C_1, \\dots, L_T, A_T, C_T, Y).\n\\] A subject contributes information up until the time of censoring. If censoring depends on time-varying covariates affected by prior treatment (e.g., CD4 count in HIV studies), then standard complete-case analyses can be biased. To address this, researchers often apply inverse probability of censoring weighting (IPCW), where each subject’s contribution is reweighted by the inverse of their probability of remaining uncensored.\n\n\n6.2.2 Competing Risks\nIn some longitudinal studies, individuals may experience one of several mutually exclusive outcomes. When the occurrence of one event precludes the occurrence of the primary event of interest, it is called a competing risk. For example, in a study of cardiovascular mortality, death from cancer acts as a competing risk.\nStandard survival analysis methods, such as the Kaplan-Meier estimator or Cox proportional hazards model, treat competing events as censoring, which can overestimate the cumulative incidence of the primary event. Instead, the correct estimand is often the cumulative incidence function (CIF), which estimates the marginal probability of experiencing each event over time.\nR Example (Competing Risks using the cmprsk package):\nlibrary(cmprsk)\n# Simulated data: time = event time, status = event type (0=censoring, 1=event, 2=competing risk)\nset.seed(123)\nn <- 500\ntime <- rexp(n, rate = 0.1)\nstatus <- sample(0:2, n, replace = TRUE, prob = c(0.3, 0.5, 0.2))\ngroup <- rbinom(n, 1, 0.5)\n\n# Estimate cumulative incidence function by group\ncif <- cuminc(time, status, group)\nplot(cif, lty = 1:2, col = c(\"blue\", \"red\"))\n\n\n6.2.3 R Example: Inverse Probability of Censoring Weights (IPCW)\n# Simulate dropout indicator\nlibrary(survival)\nset.seed(456)\nL0 <- rnorm(n)\nA0 <- rbinom(n, 1, plogis(0.3 * L0))\nC <- rbinom(n, 1, plogis(0.4 * A0 - 0.2 * L0)) # Censoring indicator (1 = censored)\n\n# Estimate probability of remaining uncensored\nipcw_model <- glm(C ~ A0 + L0, family = binomial)\np_uncensored <- 1 - predict(ipcw_model, type = \"response\")\nipcw_weights <- 1 / p_uncensored\nsummary(ipcw_weights)\nThese weights can be used in regression or IPTW analyses to adjust for informative censoring.\nCensoring and competing risks are both forms of missing data or information loss that, if ignored, can severely bias causal effect estimates. Proper methods such as IPCW or competing risk models are essential for valid inference in longitudinal studies.\n\n\n6.2.4 Motivation and Examples from Survival Analysis\n\n\n6.2.5 Notation and Assumptions for Survival Data\n\n\n6.2.6 The Parametric and Nonparametric g-Formula for Survival\nIn time-to-event settings, the g-formula can be used to estimate counterfactual survival curves under static or dynamic treatment interventions. The goal is to evaluate the probability of survival over time under a hypothetical treatment strategy, adjusting for time-varying confounding and censoring.\nLet \\(T\\) denote the event time and \\(C\\) the censoring time. Define the observed time as \\(U = \\min(T, C)\\) and the event indicator \\(\\Delta = I(T \\leq C)\\). Let \\(Y_t = I(U > t)\\) be the survival status at time \\(t\\), and let \\(A_t\\) and \\(L_t\\) denote time-varying treatment and confounders. The counterfactual outcome \\(Y_t^{\\bar{a}}\\) indicates survival at time \\(t\\) under treatment regime \\(\\bar{a} = (a_0, a_1, \\dots, a_t)\\).\n\nThe Nonparametric g-formula for Survival\nThe nonparametric g-formula (also called the “extended Kaplan-Meier estimator”) can be implemented using stratification and empirical averaging. Under this approach, survival probabilities are estimated directly from the observed data using inverse probability weighting or Monte Carlo simulation without parametric assumptions.\nLet \\(\\bar{d}\\) denote a dynamic treatment rule. The nonparametric g-formula estimates: \\[\n\\hat{S}(t \\mid \\bar{d}) = \\frac{1}{n} \\sum_{i=1}^n \\prod_{s=0}^{t} \\hat{P}(Y_{is} = 1 \\mid \\text{history}_i, A_{is} = d_s)\n\\]\nThis is typically implemented via simulation: for each individual, generate a pseudo-population following rule \\(\\bar{d}\\), then compute the product of conditional survival probabilities across time.\n\n\nThe Parametric g-formula for Survival\nThe parametric g-formula expresses the counterfactual survival probability at time \\(t\\) under treatment regime \\(\\bar{a}\\) as: \\[\nP(Y_t^{\\bar{a}} = 1) = \\int_{\\bar{l}_t} \\prod_{s=0}^{t} P(Y_s = 1 \\mid Y_{s-1} = 1, A_{s} = a_{s}, L_s = l_s) f(L_s \\mid \\bar{L}_{s-1}, \\bar{A}_{s}) d\\bar{l}_t\n\\]\nThis formula recursively computes the survival probability at each time point, conditioning on not having failed previously. The term \\(P(Y_s = 1 \\mid Y_{s-1} = 1, A_s, L_s)\\) is the conditional survival probability given being at risk at time \\(s\\), and \\(f(L_s \\mid \\cdot)\\) represents the evolution of time-varying covariates.\nIn practice, this approach involves specifying parametric regression models for: - \\(P(Y_s = 1 \\mid Y_{s-1} = 1, A_s, L_s)\\): the outcome model (e.g., pooled logistic regression) - \\(f(L_s \\mid A_{s-1}, L_{s-1})\\): the covariate models\n\n\nWorked Example in R (Parametric g-formula)\nWe simulate a simple time-to-event dataset with time-varying covariates and treatment:\nset.seed(123)\nn <- 1000\nK <- 5 # time points\nL <- matrix(NA, n, K)\nA <- matrix(NA, n, K)\nY <- matrix(1, n, K)\n\nL[, 1] <- rnorm(n)\nA[, 1] <- rbinom(n, 1, plogis(0.5 * L[, 1]))\n\nfor (t in 2:K) {\n L[, t] <- rnorm(n, mean = 0.4 * L[, t - 1] + 0.5 * A[, t - 1])\n A[, t] <- rbinom(n, 1, plogis(0.5 * L[, t]))\n}\n\n# Simulate event time (discrete hazard)\nhazard <- matrix(NA, n, K)\nfor (t in 1:K) {\n hazard[, t] <- plogis(-2 + 0.6 * A[, t] + 0.5 * L[, t])\n fail <- rbinom(n, 1, hazard[, t])\n Y[, t] <- ifelse(rowSums(Y[, 1:t, drop=FALSE]) == t, 1 - fail, 0)\n}\n\n# Reshape into long format for pooled logistic regression\nlibrary(tidyr)\nlong_data <- data.frame(id = rep(1:n, each = K),\n time = rep(1:K, times = n),\n Y = as.vector(Y),\n A = as.vector(A),\n L = as.vector(L))\n\n# Estimate conditional survival model\nmodel <- glm(Y ~ time + A + L, family = binomial(), data = long_data)\nTo estimate the survival curve under a hypothetical intervention \\(A_t = 1\\) for all \\(t\\):\npred_data <- long_data\npred_data$A <- 1\npred_data$Y_hat <- predict(model, newdata = pred_data, type = \"response\")\n\n# Compute survival curve under intervention\nsurv_probs <- with(pred_data, tapply(1 - Y_hat, time, mean))\nsurv_curve <- cumprod(surv_probs)\nplot(1:K, surv_curve, type = \"s\", ylim = c(0,1),\n ylab = \"Survival Probability\", xlab = \"Time\")\n\n\nInterpretation and Uses\nThis approach allows estimation of the entire survival curve under hypothetical treatment strategies. It is especially useful when treatments are administered sequentially, and time-varying confounders must be appropriately adjusted.\nThe parametric g-formula is sensitive to model misspecification. Flexible machine learning methods and data-adaptive approaches (e.g., Super Learner) can be used to reduce bias in estimating the conditional survival and covariate models.\n\n\nSummary\nThe g-formula can be used to estimate survival curves under complex dynamic interventions in the presence of time-varying confounding. Both parametric and nonparametric implementations are possible. The parametric approach uses pooled logistic regression to estimate conditional hazards, while the nonparametric approach relies on Monte Carlo averaging. These methods provide a foundation for evaluating intervention strategies in real-world longitudinal and survival data.\n\n\n\n6.2.7 TMLE for Time-to-Event Data\nIn time-to-event analyses, right censoring complicates the estimation of causal effects. Traditional approaches, such as Cox proportional hazards models, rely on strong assumptions (e.g., proportional hazards, correct model form) and typically do not target a marginal treatment effect. Targeted Maximum Likelihood Estimation (TMLE) offers a semi-parametric, double-robust framework for estimating causal effects under time-to-event data, accounting for both time-varying treatment and censoring processes. TMLE is flexible, accommodates data-adaptive estimation (e.g., via Super Learner), and targets causal parameters directly–such as survival probabilities under static or dynamic interventions. TMLE can be adapted for survival analysis where the outcome is the time until an event occurs. In this setting, we are often interested in estimating causal effects such as differences in survival probabilities or restricted mean survival time (RMST) under hypothetical interventions.\nTMLE provides a semi-parametric and doubly robust method for causal effect estimation that combines flexible machine learning with targeted bias reduction. In the context of survival data, it handles censoring and treatment assignment through a careful combination of outcome modeling, propensity score estimation, and the use of clever covariates.\nIntroduction and Motivation\nIn time-to-event analyses, right censoring complicates the estimation of causal effects. Traditional approaches, such as Cox proportional hazards models, rely on strong assumptions (e.g., proportional hazards, correct model form) and typically do not target a marginal treatment effect. Targeted Maximum Likelihood Estimation (TMLE) offers a semi-parametric, double-robust framework for estimating causal effects under time-to-event data, accounting for both time-varying treatment and censoring processes. TMLE is flexible, accommodates data-adaptive estimation (e.g., via Super Learner), and targets causal parameters directly–such as survival probabilities under static or dynamic interventions.\nObserved Data Structure\nLet the observed data for \\(n\\) individuals be: \\[\nO = (W, A, \\bar{L}(t), \\bar{A}(t), \\bar{C}(t), T, \\Delta), \\quad i = 1, \\dots, n,\n\\] where:\n\n\\(W\\): baseline covariates;\n\\(A\\): baseline treatment (for static intervention) or treatment history \\(\\bar{A}(t)\\) (for longitudinal interventions);\n\\(\\bar{L}(t)\\): time-varying covariates up to time \\(t\\);\n\\(\\bar{C}(t)\\): censoring process up to time \\(t\\);\n\\(T\\): observed time to event or censoring;\n\\(\\Delta = I(T \\leq \\tilde{T})\\): event indicator (1 if observed event, 0 if censored).\n\nWe observe the minimum of the event time and censoring time.\nParameter of Interest\nThe parameter of interest is often a marginal survival probability under a static treatment strategy: \\[\n\\Psi(P_0) = \\mathbb{E}_{P_0}[S^a(t)] = P(T^a > t),\n\\] where \\(T^a\\) is the potential failure time under intervention \\(A = a\\), and \\(S^a(t)\\) is the corresponding survival curve. TMLE targets this quantity while accounting for censoring and confounding.\nEfficient Influence Curve\nThe efficient influence curve (EIC) for the survival probability under a static treatment \\(a\\) is: \\[\nD^*(O) = H(t, A, W) \\left[ \\Delta I(T \\leq t) - \\hat{S}(t \\mid A, W) \\right] + \\hat{S}(t \\mid A, W) - \\hat{S}^a(t),\n\\] where \\(H(t, A, W)\\) is a clever covariate constructed using inverse probability weights for treatment and censoring.\nStep-by-Step Algorithm (Pooled TMLE)\nWe now describe the procedure following Petersen et al. (2014) for static interventions:\n\nEstimate the initial outcome model. Fit a pooled logistic regression model for the event indicator at each time point \\(t\\), conditional on \\(A\\), \\(W\\), and \\(t\\).\nEstimate the treatment and censoring mechanisms. Estimate \\(g(A \\mid W)\\) and \\(P(C \\geq t \\mid A, W)\\).\nConstruct clever covariates. Define: \\[\nH_i(t) = \\frac{I(A_i = a) I(T_i \\geq t)}{\\hat{g}(A_i \\mid W_i) \\hat{P}(C_i \\geq t \\mid A_i, W_i)}\n\\]\nTarget the outcome model. Update the initial model by performing logistic regression with offset equal to the logit of the initial prediction and covariate \\(H_i(t)\\) to estimate a fluctuation parameter \\(\\epsilon\\).\nUpdate survival estimates. Use the updated predicted hazards to compute the targeted survival probability: \\[\n\\hat{S}^a(t) = \\prod_{s=1}^t \\left(1 - \\hat{P}(T = s \\mid A = a, W) \\right)\n\\]\nCompute standard errors. Use the empirical variance of the EIC across individuals to compute standard errors and confidence intervals.\n\nExample: Manual Implementation of Pooled TMLE\nWe simulate a simplified dataset for illustration. Suppose we have baseline treatment \\(A\\), covariate \\(W\\), and time-to-event outcome \\(T\\) (censored at time 5).\nlibrary(survival)\nlibrary(dplyr)\n\nset.seed(123)\nn <- 500\nW <- rnorm(n)\nA <- rbinom(n, 1, plogis(W))\nhazard <- function(t, A, W) plogis(-2 + 0.5*A + 0.3*W + 0.1*t)\nT_true <- sapply(1:n, function(i) {\n for (t in 1:5) {\n if (runif(1) < hazard(t, A[i], W[i])) return(t)\n }\n return(6)\n})\nC <- sample(2:6, n, replace = TRUE)\nT_obs <- pmin(T_true, C)\nDelta <- as.integer(T_true <= C)\n\ndata_long <- data.frame(\n id = rep(1:n, each = 5),\n t = rep(1:5, n),\n W = rep(W, each = 5),\n A = rep(A, each = 5),\n T = rep(T_obs, each = 5),\n Delta = rep(Delta, each = 5)\n) %>%\n mutate(Y = as.integer(T == t & Delta == 1),\n at_risk = as.integer(T >= t))\n\n# Step 1: Fit initial pooled logistic regression\ninitial_fit <- glm(Y ~ A + W + t, family = binomial(), data = data_long, subset = at_risk == 1)\nsummary(initial_fit)\nThe subsequent steps include estimating censoring weights, constructing the clever covariate, performing the targeting update, and computing the survival curve. For brevity, we refer readers to code-based tutorials (e.g., TMLEbook) or the ltmle package for full pipelines.\nExample: TMLE with the ltmle Package\nWe now implement TMLE for a longitudinal survival setting using the ltmle package. This automates estimation of survival curves under static interventions.\nlibrary(ltmle)\ndata(exampleData)\ntimepoints <- 1:6\n\n# Static intervention A = 1\nltmle_fit <- ltmle(exampleData, Anodes=paste0(\"A\", timepoints),\n Cnodes=paste0(\"C\", timepoints),\n Lnodes=paste0(\"L\", timepoints),\n Ynodes=paste0(\"Y\", timepoints),\n survivalOutcome = TRUE,\n abar = rep(1, length(timepoints)))\n\nsummary(ltmle_fit)\nThis returns survival probability estimates under the static intervention \\(A = 1\\), along with standard errors and confidence intervals based on the efficient influence function.\nConclusion\nTMLE provides a powerful approach for estimating survival probabilities under interventions in the presence of censoring and time-dependent confounding. Compared to standard estimators, TMLE offers increased robustness and better finite-sample performance–especially when implemented with Super Learner. This makes it well-suited to longitudinal epidemiologic data where traditional methods may fail to identify the causal effect due to structural and data-adaptive complexities.",
"crumbs": [
"Advanced Methods",
"<span class='chapter-number'>6</span> <span class='chapter-title'>Causal Inference for Longitudinal Data</span>"
]
},
{
"objectID": "chapters/chapter6/index.html#practical-considerations-and-pitfalls",
"href": "chapters/chapter6/index.html#practical-considerations-and-pitfalls",
"title": "6 Causal Inference for Longitudinal Data",
"section": "6.3 Practical Considerations and Pitfalls",
"text": "6.3 Practical Considerations and Pitfalls",
"crumbs": [
"Advanced Methods",
"<span class='chapter-number'>6</span> <span class='chapter-title'>Causal Inference for Longitudinal Data</span>"
]
},
{
"objectID": "chapters/chapter6/index.html#summary-and-further-reading",
"href": "chapters/chapter6/index.html#summary-and-further-reading",
"title": "6 Causal Inference for Longitudinal Data",
"section": "6.4 Summary and Further Reading",
"text": "6.4 Summary and Further Reading",
"crumbs": [
"Advanced Methods",
"<span class='chapter-number'>6</span> <span class='chapter-title'>Causal Inference for Longitudinal Data</span>"
]
},
{
"objectID": "chapters/chapter6/index.html#glossary",
"href": "chapters/chapter6/index.html#glossary",
"title": "6 Causal Inference for Longitudinal Data",
"section": "6.5 Glossary",
"text": "6.5 Glossary\n\nMain term\n\nDescription of main term.\n\n\n\n\n\n\nLendle, S. D., Schwab, J., Petersen, M. L., & Der Laan, M. J. van. (2017). Ltmle: An r package implementing targeted minimum loss-based estimation for longitudinal data. Journal of Statistical Software, 81, 1–21. https://doi.org/10.18637/JSS.V081.I01\n\n\nM. Schomaker, V. L., M. A. Luque‐Fernandez. (2019). Using longitudinal targeted maximum likelihood estimation in complex settings with dynamic interventions. Statistics in Medicine, 38(24), 4888–4911. https://doi.org/10.1002/sim.8340",
"crumbs": [
"Advanced Methods",
"<span class='chapter-number'>6</span> <span class='chapter-title'>Causal Inference for Longitudinal Data</span>"
]
},
{
"objectID": "chapters/chapter7/index.html",
"href": "chapters/chapter7/index.html",
"title": "7 Mediation Analysis",
"section": "",
"text": "7.1 Introduction to Mediation\nSo far we have considered causal effects of a treatment on an outcome when a covariate is not on the causal pathway. Covariates that are on the causal pathway are termed “mediators”. They are so named because a cause (e.g., the treatment) affects the mediator that, in turn, affects the outcome. In this chapter, we will (i) explore the role of mediators in causal analyses, (ii) describe statistical techniques for estimating causal effects in the presence of mediators, and (iii) understand how to interpret the various effect estimates.",
"crumbs": [
"Advanced Methods",
"<span class='chapter-number'>7</span> <span class='chapter-title'>Mediation Analysis</span>"
]
},
{
"objectID": "chapters/chapter7/index.html#introduction-to-mediation",
"href": "chapters/chapter7/index.html#introduction-to-mediation",
"title": "7 Mediation Analysis",
"section": "",
"text": "7.1.1 Motivation and Overview\nIn causal inference, we often seek not only to estimate the total effect of an exposure or treatment on an outcome but also to understand the mechanisms through which this effect operates. Mediation analysis allows us to decompose the total effect into components that correspond to different causal pathways. This is particularly important in biomedical, social, and behavioural sciences, where identifying how and why a treatment works can inform intervention design, policy decisions, and scientific understanding.\nFor example, suppose a new drug improves patient outcomes. We may want to know whether the improvement occurs primarily by reducing inflammation, improving immune function, or some other biological process. Mediation analysis aims to quantify how much of the treatment’s effect is explained by a specific intermediate variable—known as the mediator.\n\n\n7.1.2 Total, Direct, and Indirect Effects\nLet \\(A\\) denote a binary treatment (e.g., 1 for treated, 0 for untreated), \\(M\\) the mediator (e.g., a biomarker), and \\(Y\\) the outcome of interest (e.g., disease status). Under the potential outcomes framework, we define:\n\n\\(Y^a\\): the potential outcome if treatment is set to \\(a\\)\n\\(M^a\\): the potential mediator value under treatment \\(a\\)\n\\(Y^{a, m}\\): the potential outcome if treatment is \\(a\\) and mediator is set to \\(m\\)\n\nThen, the total effect of treatment on the outcome can be decomposed into:\n\\[\n\\text{Total Effect (TE)} = \\mathbb{E}[Y^1 - Y^0]\n\\]\nThe total effect can be further partitioned into:\n\nNatural Direct Effect (NDE) : The effect of treatment on the outcome not through the mediator \\[\n\\text{NDE} = \\mathbb{E}[Y^{1, M^0} - Y^{0, M^0}]\n\\]\nNatural Indirect Effect (NIE) : The effect of treatment that operates through the mediator \\[\n\\text{NIE} = \\mathbb{E}[Y^{0, M^1} - Y^{0, M^0}]\n\\]\n\nThis decomposition assumes no interaction between the direct and indirect pathways. If such interaction exists, the decomposition still holds but interpretation becomes more nuanced.\n\n\n7.1.3 Example: Treatment \\(\\rightarrow\\) Mediator \\(\\rightarrow\\) Outcome\nConsider a simulated example where a treatment \\(A\\) affects a continuous mediator \\(M\\), which in turn affects a continuous outcome \\(Y\\). The goal is to estimate the total, direct, and indirect effects.\n\nSimulating Data in R\nset.seed(123)\nn <- 1000\nA <- rbinom(n, 1, 0.5) # Binary treatment\nM <- 0.5 * A + rnorm(n) # Mediator depends on A\nY <- 0.3 * A + 0.6 * M + rnorm(n) # Outcome depends on A and M\n\ndata <- data.frame(A, M, Y)\n\n\nRunning Mediation Analysis in R\nWe can use the mediation package in R to estimate the average causal mediation effect (ACME, equivalent to NIE), average direct effect (ADE, equivalent to NDE), and total effect.\nlibrary(mediation)\n\n# Fit mediator model\nmed.fit <- lm(M ~ A, data = data)\n\n# Fit outcome model\nout.fit <- lm(Y ~ A + M, data = data)\n\n# Run mediation\nmed.out <- mediate(med.fit, out.fit, treat = \"A\", mediator = \"M\", boot = TRUE)\nsummary(med.out)\nThis will return estimates of:\n\nACME (average causal mediation effect) — the indirect effect\nADE (average direct effect) — the direct effect\nTotal Effect = ACME + ADE\nProportion mediated: ACME / Total Effect\n\n\n\n\n7.1.4 The Role of Causal Thinking in Mediation\nCausal mediation analysis relies on several strong assumptions that must be justified with domain knowledge and visualized using causal diagrams (DAGs). The key identification assumptions include:\n\nNo unmeasured confounding between treatment and outcome\nNo unmeasured confounding between mediator and outcome\nNo confounders of the mediator-outcome relationship affected by the treatment\n\nThese assumptions are not testable from data alone. Drawing a DAG helps clarify whether the necessary conditional independencies are plausible and guides appropriate adjustment strategies.\n\nExample DAG\n\n\nShow the code\nflowchart TD\n A[A] --> M[M]\n M --> Y[Y]\n A --> Y\n\n\n\n\n\n\n\n\n\n\n\nThis simple DAG illustrates the decomposition of the total effect into a direct path (\\(A \\rightarrow Y\\)) and an indirect path (\\(A \\rightarrow M \\rightarrow Y\\)). Any omitted arrows (e.g., from unmeasured confounders) must be considered when evaluating the validity of the assumptions.\n\n\n\n7.1.5 Summary\nMediation analysis helps disentangle causal pathways by estimating direct and indirect effects. These analyses can be highly informative but require strong assumptions and careful modeling. In the next sections, we discuss identification strategies, estimation approaches, and practical tools for mediation analysis in computational causal inference.",
"crumbs": [
"Advanced Methods",
"<span class='chapter-number'>7</span> <span class='chapter-title'>Mediation Analysis</span>"
]
},
{
"objectID": "chapters/chapter7/index.html#approaches-to-mediation-analysis",
"href": "chapters/chapter7/index.html#approaches-to-mediation-analysis",
"title": "7 Mediation Analysis",
"section": "7.2 Approaches to mediation analysis",
"text": "7.2 Approaches to mediation analysis\n\n7.2.1 Classic regression approach\nConsider the causal diagram in ?fig-M1 with exposure X, mediator M, and outcome Y (for simplicity, assume there are no confounders). There are two effects of X on Y that can be measured in this scenario: the direct effect (DE) and the indirect effect (IE). The direct effect (i.e., \\(X \\rightarrow Y\\)) is the effect of the exposure on the outcome that is not through the mediator. The indirect effect is the effect of the exposure on the outcome that operates through the mediator (i.e., \\(X \\rightarrow M \\rightarrow Y\\)).\n\n\nShow the code\nflowchart TD\n X[X] --> M[M]\n M --> Y[Y]\n X --> Y\n\n\n\n\n\n\n\n\n\n\n\nEarly proponents of evaluating this model suggested using the “product of coefficients method” (also known as “product method”) (Baron and Kenny, 1986). Let M and Y be continuous variables, consider the following regression models:\n\\[ E(M \\mid X=x) = \\beta_{0} + \\beta_{1}x \\tag{7.1}\\]\n\\[ E(Y \\mid X=x, M=m) = \\theta_{0} + \\theta_{1}x + \\theta_{2}m \\tag{7.2}\\]\nEquation 7.1 is the regression model for the mediator. The coefficient \\(\\beta_{1}\\) is the expected increase in the value of the mediator for a unit increase in the exposure (for a binary exposure this coefficient would be the difference in means between two treatment groups).\nEquation 7.2 is the regression model for the outcome. Baron and Kenny proposed that the coefficient \\(\\theta_{1}\\) is the direct effect of \\(X \\rightarrow Y\\), which is the effect of the exposure on the outcome at a fixed level of the mediator variable (e.g., at the reference level). The coefficient \\(\\theta_{2}\\) is the effect of the mediator on the outcome at a fixed level of the exposure variable.\nBaron and Kenny also proposed that the indirect effect be calculated by estimating \\(\\beta_{1}\\theta_{2}\\). The indirect effect is the effect on the outcome of changes of the exposure which operate through mediator levels.\nTo illustrate this, consider ?fig-M2 below. The arrows have now been labelled with their respective coefficients from Equation 7.1 and Equation 7.2.\n\n\nShow the code\nflowchart TD\n X[X] -->|\"β₁\"| M[M]\n M -->|\"θ₂\"| Y[Y]\n X -->|\"θ₁\"| Y\n\n\n\n\n\n\n\n\n\n\n\nThis classic regression approach can accommodate simplistic causal diagrams. However, this approach has its drawbacks. Firstly, in more complex scenarios, the mediator could be a collider between the exposure and an unmeasured variable (see lecture on causal diagrams). Therefore, adjusting for the mediator (e.g., in Equation 7.2) would induce an association between the exposure and the unmeasured variable (something we do not want to do!). Other complex scenarios could also incorporate interactions or non-linear terms for certain covariates. Secondly, the techniques used in this classic regression approach does not easily carry over into non-linear regression models, such as non-collapsibility. For example, consider the mediator was continuous and the outcome was binary. The product between the coefficients (i.e., \\(\\beta_{1}\\theta_{2}\\)) would be a combination of a mean difference (i.e., \\(\\beta_{1}\\)) and a log-odds ratio (i.e., \\(\\theta_{2}\\)) - something that is very difficult to interpret! In the next section (Counterfactual approach) we will explore an alternative approach to estimating direct and indirect effects, which is more commonly used today and is the preferred approach.\n\nControlled direct effect\nBefore introducing the Counterfactual Approach, it is important to familiarise yourself with another estimand that is often of interest. Another commonly used measure of interest is the controlled direct effect (CDE). The controlled direct effect expresses how much the outcome would change on average if the mediator were fixed at level \\(m\\) uniformly in the population but the treatment were changed from level \\(x=0\\) to level \\(x=1\\). Consequently, there are as many controlled direct effects as there are levels of the mediator.\nThe CDE corresponds to a situation in which a hypothetical intervention controls the mediator to a given value, whereas the direct effect corresponds to a situation in which the natural relationship between the exposure and the mediator is maintained (i.e., we would intervene on the exposure but not directly on the mediator).\nThe CDE and the direct effect is equivalent when there is no interaction between the exposure and the mediator (see Richiardi et al 2013, for further explanation). To illustrate this concept, consider again the model for the mediator (which is the same as Equation 7.1)\n\\[ E(M \\mid X=x) = \\beta_{0} + \\beta_{1}x \\tag{7.3}\\]\nand now a model for the outcome that includes an interaction between the exposure and the mediator\n\\[ E(Y \\mid X=x, M=m) = \\theta_{0} + \\theta_{1}x + \\theta_{2}m + \\theta_{3}xm \\tag{7.4}\\]\nUsing Equation 7.3 and Equation 7.4, the CDE, DE, and IE can be estimated as follows (where \\(x\\) is exposed and \\(x^{*}\\) is not exposed):\n\\[\n\\begin{aligned} \\operatorname{CDE}(m) & =\\left(\\theta_{1}+\\theta_{3} m\\right)\\left(x-x^{*}\\right) \\\\ D E & =\\left(\\theta_{1}+\\theta_{3} \\beta_{0}+\\theta_{3} \\beta_{1} x^{*} \\right)\\left(x-x^{*}\\right) \\\\ I E & =\\left(\\theta_{2} \\beta_{1}+\\theta_{3} \\beta_{1} x\\right)\\left(x-x^{*}\\right)\n\\end{aligned}\n\\]\nNotice that, in Equation 7.4, if the interaction is absent, such that \\(\\theta_{3} = 0\\), then the CDE and DE would be equivalent:\n\\[\n\\begin{aligned} \\operatorname{CDE}(m) & =\\left(\\theta_{1} \\right)\\left(x-x^{*}\\right) \\\\ D E & =\\left(\\theta_{1} \\right)\\left(x-x^{*}\\right)\n\\end{aligned}\n\\]\nTo explain this concept further, if the direct effect of the exposure is constant for the different levels of the mediator, then setting the mediator to a fixed value (i.e., CDE) would give the same estimate. Similarly, setting the value that the mediator would have taken at the reference level of the exposure (i.e., DE) would also give the same estimate.\nThere is a difference in the interpretation of the CDE and DE even in the absence of the interaction. As an example, consider a hypothetical study on poor diet (exposure), obesity (mediator), and heart disease (outcome). The CDE (for obesity = 0) is the effect of eliminating poor diet when controlling obesity to be absent. For the DE, obesity would be set at the value that would have been observed in the absence of poor diet.\n\n\n\n7.2.2 Counterfactual approach\nTo introduce the counterfactual approach notation in mediation analysis, consider again the causal diagram from ?fig-M1 where the exposure is binary but now the mediator is binary. Counterfactual notation defines two potential outcomes not only for the outcome of interest (i.e., Y) but also the mediator (i.e., M). The potential outcomes for the mediator are:\n\n\\(M^{0}\\): the value of the mediator had the individual received exposure level \\(x=0\\).\n\\(M^{1}\\): the value of the mediator had the individual received exposure level \\(x=1\\).\n\nSince the mediator is hypothetical (i.e., consists of potential outcomes), the potential outcome notation for the outcome of interest must also accommodate the potential outcomes of the mediator. In mediation analysis, \\(Y^{x,m}\\) is the potential outcome under exposure level \\(X=x\\) and mediator level \\(M=m\\). The potential outcomes are:\n\n\\(Y^{0,M^{0}}\\): the value of the outcome had the individual received exposure level \\(x=0\\) and the mediator taken the value it would have done under exposure level \\(x=0\\).\n\\(Y^{1,M^{1}}\\): the value of the outcome had the individual received exposure level \\(x=1\\) and the mediator taken the value it would have done under exposure level \\(x=1\\).\n\\(Y^{0,M^{1}}\\): the value of the outcome had the individual received exposure level \\(x=0\\) and the mediator taken the value it would have done under exposure level \\(x=1\\).\n\\(Y^{1,M^{0}}\\): the value of the outcome had the individual received exposure level \\(x=1\\) and the mediator taken the value it would have done under exposure level \\(x=0\\).\n\nUsing this potential outcome notation we can define the natural effects (causal estimands) of interest. The natural effects are the natural direct effect (NDE) and the natural indirect effect (NIE), which together sum up to the total effect (TE). If we were to control the mediator at the level seen in the non-exposed group (i.e., \\(x=0\\) and \\(M^{x=0}\\)), then:\nNatural direct effect\n\\[ E(Y^{1,M^{0}} - Y^{0,M^{0}}) \\]\n\\[ \\frac{E(Y^{1,M^{0}})}{E(Y^{0,M^{0}})} \\]\nNatural indirect effect\n\\[ E(Y^{1,M^{1}} - Y^{1,M^{0}}) \\]\n\\[ \\frac{E(Y^{1,M^{1}})}{E(Y^{1,M^{0}})} \\]\nControlled direct effect\n\\[ E(Y^{1,m} - Y^{0,m}) \\]\n\\[ \\frac{E(Y^{1,m})}{E(Y^{0,m})} \\]\nAlternatively, if one were interested in using the exposed group as the reference group, then the natural direct effect would be \\(M^{1}\\) (instead of \\(M^{0}\\)), and the natural indirect effect would be \\(x=0\\) (instead of \\(x=1\\)).\nThe natural direct effect (NDE) expresses how much the outcome would change, on average, if the exposure were set at level \\(x=1\\) versus level \\(x=0\\) but for each individual the mediator were kept at the level it would have taken, for that individual, in the absence of the exposure. The NDE captures what the effect of the exposure on the outcome would remain if we were to disable the pathway from the exposure to the mediator.\nThe natural indirect effect (NIE) expresses how much the outcome would change, on average, if the exposure were set at level \\(x=1\\) but the mediator were changed from the level it would take if \\(x=0\\) to the level it would take if \\(x=1\\). The NIE captures the effect of the exposure on the outcome that operates by changing the mediator.\nNotice that the potential outcome notation for \\(Y^{0,M^{1}}\\) relies on us knowing what the outcome would have been for an individual in exposure group \\(x=0\\) but they had the value of the mediator as if they were in the other exposure group (i.e., \\(x=1\\)). It is not possible to observe this from the data alone. In the same way, it is not possible for us to observe \\(Y^{1,M^{0}}\\). We will explore methods of estimating the NDE and NIE in the following sections, but first we must make certain assumptions.\n\n\n7.2.3 Assumptions\nTo illustrate the assumptions for mediation analysis, first consider the causal diagram in ?fig-Assum. The DAG consists of the exposure (X), mediator (M), outcome (Y), exposure-outcome confounder (\\(C\\)), and mediator-outcome confounder (\\(Z\\)). For simplicity, we do not include exposure-mediator confounder but this variable is likely to occur in a wide range of scenarios and should be carefully considered when doing such an analysis.\n\n\nShow the code\nflowchart TD\n C[C] --> X[X]\n C --> Y[Y]\n X --> M[M]\n M --> Y[Y]\n X --> Y\n Z[Z] --> M\n Z --> Y\n X --> Z\n\n\n\n\n\n\n\n\n\n\n\nWith such a DAG, and to estimate effects of interest, we need to make certain assumptions. The assumptions relate not only to the relationship between the exposure and the outcome but also the relationships with the mediator:\n\nNo unmeasured exposure-outcome confounders given C\nNo unmeasured mediator-outcome confounders given C and A\nNo unmeasured exposure-mediator confounders given C\nNo unmeasured mediator-outcome confounders affected by the exposure (i.e., no arrow from X to Z)\n\nTo estimate the controlled direct effect (CDE), we must assume (1) no unmeasured exposure-outcome confounding. When the treatment is randomised, assumption (1) is automatically satisfied. We also assume (2) no unmeasured mediator-outcome confounding. To estimate the CDE from ?fig-Assum, we must control for \\(C\\) and \\(Z\\).\nFor identification of the natural direct and indirect effects, two further assumptions are required. There must also be (3) no unmeasured exposure-mediator confounding, which is automatically satisfied if the exposure is randomised. Lastly, an often strong assumption is that there must be (4) no unmeasured mediator-outcome confounder that is affected by the exposure, this assumption is often called the “cross-world independence assumption”.\nNote that randomisation of the exposure is not sufficient to control for confounding in mediation analysis. Randomisation allows controlling for the exposure-outcome and exposure-mediator relationships but it does not ensure no unmeasured mediator-outcome confounding because the mediator is often not randomised.\n\n\n7.2.4 Controlled Direct Effects vs Natural Direct Effects\nWhile the natural direct effect (NDE) conditions on the natural value of the mediator under no treatment (\\(M^0\\)), the controlled direct effect (CDE) fixes the mediator to a specific value for all individuals:\n\\[\n\\text{CDE}(m) = \\mathbb{E}[Y^{1, m} - Y^{0, m}]\n\\]\nThis represents the direct effect of treatment when the mediator is held constant at a specified level \\(m\\). Controlled direct effects are easier to identify since they do not rely on cross-world counterfactuals (like \\(Y^{1, M^0}\\)).\n\nCDEs can be interpreted as the effect of treatment if we were able to intervene and fix the mediator.\nNDEs describe the effect when the mediator is allowed to take its natural value under no treatment—more interpretable, but harder to identify.\n\n\nImplication for Practice\nControlled direct effects are estimable under weaker assumptions but may lack realism unless intervention on the mediator is plausible. Natural direct and indirect effects offer more intuitive interpretations of mediation but require stronger assumptions and careful modeling.",
"crumbs": [
"Advanced Methods",
"<span class='chapter-number'>7</span> <span class='chapter-title'>Mediation Analysis</span>"
]
},
{
"objectID": "chapters/chapter7/index.html#estimation-of-effects",
"href": "chapters/chapter7/index.html#estimation-of-effects",
"title": "7 Mediation Analysis",
"section": "7.3 Estimation of Effects",
"text": "7.3 Estimation of Effects\nSeveral estimation strategies have been developed to quantify mediation effects, ranging from classical regression-based methods to modern counterfactual-based estimators. In this section, we review three major approaches: parametric g-computation, regression-based mediation analysis, and counterfactual-based methods.\n\n7.3.1 Parametric g-computation\nThe parametric g-computation formula provides a way to estimate causal effects by modeling the outcome and mediator using parametric regression models and then integrating over the empirical distribution of covariates. It is particularly useful when both treatment and mediator are continuous or binary.\nLet \\(A\\) be the treatment, \\(M\\) the mediator, and \\(Y\\) the outcome. Suppose we have baseline covariates \\(X\\). Under the identification assumptions discussed previously, the natural indirect effect (NIE) can be expressed as:\n\\[\n\\begin{aligned}\n\\text{NIE} =\\ & \\int \\left[ \\int \\mathbb{E}[Y \\mid A=0, M=m, X=x]\n\\, dF_{M \\mid A=1, X}(m) \\right] dF_X(x) \\\\\n& - \\int \\left[ \\int \\mathbb{E}[Y \\mid A=0, M=m, X=x]\n\\, dF_{M \\mid A=0, X}(m) \\right] dF_X(x)\n\\end{aligned}\n\\]\nThis expression can be approximated via Monte Carlo simulation in practice.\n\nR Example: Parametric g-computation\nAssume a data-generating process where both the mediator and outcome are continuous:\nset.seed(123)\nn <- 1000\nX <- rnorm(n)\nA <- rbinom(n, 1, 0.5)\nM <- 0.5*A + 0.3*X + rnorm(n)\nY <- 0.6*M + 0.3*A + 0.2*X + rnorm(n)\ndata <- data.frame(A, M, Y, X)\nWe fit the mediator and outcome models, then simulate counterfactuals:\n# Fit mediator and outcome models\nmed_model <- lm(M ~ A + X, data = data)\nout_model <- lm(Y ~ A + M + X, data = data)\n\n# Predict mediator under A = 1 and A = 0\ndata$M1 <- predict(med_model, newdata = transform(data, A = 1))\ndata$M0 <- predict(med_model, newdata = transform(data, A = 0))\n\n# Predict outcome under various scenarios\nY_0_M1 <- predict(out_model, newdata = transform(data, A = 0, M = data$M1))\nY_0_M0 <- predict(out_model, newdata = transform(data, A = 0, M = data$M0))\nY_1_M0 <- predict(out_model, newdata = transform(data, A = 1, M = data$M0))\nY_0_M0_total <- predict(out_model, newdata = transform(data, A = 0, M = data$M0))\n\n# Compute effects\nNIE <- mean(Y_0_M1 - Y_0_M0)\nNDE <- mean(Y_1_M0 - Y_0_M0)\nTE <- mean(Y_0_M1 - Y_0_M0_total + Y_1_M0 - Y_0_M0)\n\ncat(\"NIE:\", NIE, \"\\nNDE:\", NDE, \"\\nTE:\", TE, \"\\n\")\nThis approach provides a flexible, transparent way to estimate causal mediation effects under parametric assumptions.\n\n\n\n7.3.2 Regression-Based Mediation\nThe classical regression-based approach to mediation, introduced by Baron and Kenny (1986), uses a sequence of linear regressions to assess whether a mediator carries the effect of a treatment to the outcome. This method is simple and interpretable but does not have a formal counterfactual interpretation.\n\nBaron & Kenny Steps\nGiven a treatment \\(A\\), mediator \\(M\\), and outcome \\(Y\\), the following regressions are fitted:\n\nRegress \\(M\\) on \\(A\\): \\(\\quad M = \\alpha_0 + \\alpha_1 A + \\varepsilon_M\\)\nRegress \\(Y\\) on \\(A\\): \\(\\quad Y = \\tau_0 + \\tau A + \\varepsilon_Y\\)\nRegress \\(Y\\) on \\(A\\) and \\(M\\): \\(\\quad Y = \\beta_0 + \\beta_1 A + \\beta_2 M + \\varepsilon_Y\\)\n\nIf: - \\(\\alpha_1\\) is significant (A affects M), - \\(\\beta_2\\) is significant (M affects Y controlling for A), - and \\(|\\beta_1| < |\\tau|\\) (effect of A on Y is reduced when M is added),\nthen there is evidence of mediation.\n\n\nR Example\n# Step 1\nsummary(lm(M ~ A, data = data)) # Effect of A on M\n\n# Step 2\nsummary(lm(Y ~ A, data = data)) # Total effect\n\n# Step 3\nsummary(lm(Y ~ A + M, data = data)) # Mediation model\nThe indirect effect can be approximated as \\(\\alpha_1 \\cdot \\beta_2\\), and the direct effect as \\(\\beta_1\\).\nLimitations:\nThe classical regression-based approach to mediation, as originally proposed by Baron and Kenny, has several important limitations. First, it lacks a formal counterfactual basis, meaning it does not define or estimate causal effects in terms of potential outcomes. This restricts the interpretability of the estimated effects as truly causal. Second, the method relies on strong assumptions of linearity and additivity, and it does not easily accommodate interactions between the treatment and the mediator. Finally, it provides no built-in framework for statistical inference or sensitivity analysis, making it difficult to assess uncertainty around estimates or to evaluate the robustness of conclusions to violations of assumptions.\n\n\n\n7.3.3 Counterfactual-Based Methods\nModern mediation methods are built on the potential outcomes (counterfactual) framework, allowing for clear definitions of direct and indirect effects and accommodating non-linear models, interactions, and bootstrapped confidence intervals.\n\nEstimation via Mediation Package in R\nThe mediation package (Tingley et al., 2014) estimates average causal mediation effects (ACME) and average direct effects (ADE) under assumptions described earlier.\nlibrary(mediation)\n\n# Fit models\nmed_model <- lm(M ~ A + X, data = data)\nout_model <- lm(Y ~ A + M + X, data = data)\n\n# Estimate mediation effects\nmed.out <- mediate(med_model, out_model,\n treat = \"A\", mediator = \"M\",\n boot = TRUE, sims = 1000)\n\nsummary(med.out)\nThe output includes: - ACME (Average Causal Mediation Effect): the indirect effect - ADE (Average Direct Effect): the direct effect - Total Effect: ACME + ADE - Proportion Mediated: ACME / Total\nAdvantages:\nCounterfactual-based methods offer several advantages over traditional approaches. First, they provide a formal causal interpretation rooted in the potential outcomes framework, allowing clear definitions of direct and indirect effects. Second, these methods are flexible and can be applied to a wide range of models, including nonlinear models and those with treatment-mediator interactions. Third, they support inference using bootstrap-based confidence intervals, which are particularly useful when the sampling distribution of mediation effects is complex or unknown.\nLimitations:\nDespite their strengths, counterfactual-based methods also come with limitations. They rely on strong identification assumptions—such as no unmeasured confounding of the mediator-outcome relationship and the absence of exposure-induced mediator-outcome confounding—which are not testable from the data and may not hold in observational studies. Additionally, the underlying concepts can be more challenging to communicate to non-technical audiences, particularly those unfamiliar with potential outcomes or causal diagrams.\n\n\n\n7.3.4 Summary\nEach of the three approaches to mediation analysis—g-computation, regression-based analysis, and counterfactual-based estimation—offers distinct advantages and limitations. G-computation provides flexible parametric integration. Classical regression is simple but limited in scope. Counterfactual-based methods provide a rigorous framework under clear assumptions and are widely used in modern causal inference practice.\nIn the next section, we explore advanced extensions to mediation analysis, including interventional effects and mediation under intermediate confounding.",
"crumbs": [
"Advanced Methods",
"<span class='chapter-number'>7</span> <span class='chapter-title'>Mediation Analysis</span>"
]
},
{
"objectID": "chapters/chapter7/index.html#advanced-methods",
"href": "chapters/chapter7/index.html#advanced-methods",
"title": "7 Mediation Analysis",
"section": "7.4 Advanced Methods",
"text": "7.4 Advanced Methods\nIn this section, we discuss several advanced approaches that extend traditional mediation analysis. These include interventional (or stochastic) effects that circumvent some of the identification challenges of natural effects, methods that account for intermediate confounding, and a brief overview of mediation in longitudinal settings.\n\n7.4.1 Interventional Effects\nTraditional mediation analysis relies on cross-world counterfactuals such as \\(Y^{1, M^0}\\), which are challenging to identify and require strong assumptions. Interventional effects offer an alternative that avoids cross-world contrasts by defining effects based on stochastic interventions on the mediator.\nDefinition: The interventional indirect effect is defined as the change in the outcome distribution due to intervening on the mediator, such that its distribution matches what it would have been under treatment \\(A = 1\\), but keeping the treatment fixed at \\(A = 0\\):\n\\[\n\\text{IIE} = \\mathbb{E}\\left[ Y^{0, \\tilde{M}^{1}} \\right] - \\mathbb{E}\\left[ Y^{0, \\tilde{M}^{0}} \\right]\n\\]\nSimilarly, the interventional direct effect is:\n\\[\n\\text{IDE} = \\mathbb{E}\\left[ Y^{1, \\tilde{M}^{1}} \\right] - \\mathbb{E}\\left[ Y^{0, \\tilde{M}^{1}} \\right]\n\\]\nwhere \\(\\tilde{M}^a\\) is a random draw from the distribution of \\(M\\) under treatment \\(A = a\\). These estimands can be identified under weaker assumptions than natural effects and are still interpretable as causal pathways.\nEstimation in R: The medflex package provides tools for estimating interventional effects.\nlibrary(medflex)\n\n# Fit the working models\nexpData <- neImpute(Y ~ A + M + X, data = data)\nneMod <- neModel(Y ~ A0 + M + X, family = gaussian, expData = expData)\n\n# Estimate interventional effects\nsummary(neMod)\nThis returns estimates of the interventional direct and indirect effects, along with standard errors and confidence intervals.\nAdvantages:\nInterventional effects offer several important advantages over natural direct and indirect effects. First, they do not rely on cross-world counterfactuals—such as \\(Y^{1, M^0}\\) — which are inherently unobservable and require strong assumptions for identification. Second, interventional effects can be identified under weaker conditions, making them more robust to violations of assumptions that often limit traditional mediation analysis. Third, these effects are readily adaptable to a wide range of model types, including nonlinear and nonparametric models, which enhances their flexibility in practical applications.\n\n\n7.4.2 Mediation with Intermediate Confounding\nA key assumption of natural effect identification is the absence of exposure-induced confounding of the mediator-outcome relationship. This means there are no variables that: 1. Affect both the mediator and the outcome, 2. Are themselves affected by the treatment.\nSuch variables are called intermediate confounders. When they exist, traditional approaches may produce biased estimates.\nSolution: To handle intermediate confounding, methods like sequential g-estimation, inverse probability weighting, or targeted maximum likelihood estimation (TMLE) can be used. These techniques adjust for the time-varying confounders without blocking the indirect path.\nExample: Using IPTW for mediation\nSuppose \\(L\\) is an intermediate confounder (e.g., post-treatment health status). We estimate weights for the mediator model that account for treatment and confounders:\n# Estimate propensity for M conditional on A and L\nmed.weight.model <- glm(M ~ A + L + X, family = binomial(), data = data)\ndata$med.weights <- 1 / predict(med.weight.model, type = \"response\")\n\n# Use these weights in a weighted regression of Y on A and M\nlibrary(survey)\ndesign <- svydesign(ids = ~1, weights = ~med.weights, data = data)\nsvyglm(Y ~ A + M + X, design = design)\nThis approach helps isolate the indirect effect while adjusting for post-treatment confounding.\nLimitations:\nMethods for mediation analysis in the presence of intermediate or time-varying confounding come with notable limitations. They require careful and accurate modeling of the confounding structure, particularly when confounders are influenced by prior treatment or mediator values. Additionally, these methods are sensitive to model misspecification and violations of the positivity assumption—that is, the assumption that all levels of treatment and mediator occur with non-zero probability across covariate strata. Violations of these conditions can lead to unstable or biased estimates.\n\n\n7.4.3 Longitudinal Mediation\nIn longitudinal studies, treatment, mediator, and outcome variables may be measured repeatedly over time, reflecting the dynamic nature of causal processes. For example, a health intervention administered over several months (\\(A_t\\)) may influence weight (\\(M_t\\)) and, in turn, affect blood pressure (\\(Y_t\\)) at multiple follow-up visits. In such cases, causal effects may accumulate or change over time, and past values of mediators or outcomes may influence future treatments, making analysis more complex than in cross-sectional settings.\nChallenges\nLongitudinal mediation presents several methodological difficulties. Chief among them is time-varying confounding, where intermediate variables (e.g., stress, diet) are affected by prior treatment or mediators and simultaneously affect future mediators and outcomes. This introduces bias if not properly accounted for. Another challenge is feedback loops—situations in which past values of mediators influence future treatments or vice versa. Lastly, the presence of multiple mediators at different time points, and lagged or delayed effects, increases model complexity and demands more flexible estimation frameworks.\nApproaches\nSeveral estimation strategies address these complexities:\n\nStructural Nested Models (SNMs) : Allow for explicit modeling of treatment effects over time, while adjusting for intermediate confounding.\nLongitudinal G-computation: Uses recursive substitution to model outcomes forward in time, integrating over the empirical distribution of time-varying confounders and mediators.\nLongitudinal TMLE: Extends targeted maximum likelihood estimation to longitudinal settings, combining machine learning with iterative targeting to estimate marginal effects with double robustness and efficiency.\n\nR Packages\n\nltmle provides a general framework for longitudinal targeted learning.\nmedltmle implements longitudinal mediation-specific TMLE estimators.\n\n\nWorked Example: Estimating Longitudinal Mediation Effects with medltmle\nConsider a simulated study in which physical activity (\\(A_t\\)) influences BMI (\\(M_t\\)), which in turn affects systolic blood pressure (\\(Y_t\\)) at three time points (baseline, 1-year, 2-year). Stress (\\(L_t\\)) acts as a time-varying confounder.\nThe data structure is in wide format, with columns such as: A1, A2, M1, M2, Y1, Y2, L1, L2, and baseline covariates W1, W2.\nlibrary(medltmle)\n\n# Simulated dataset with 2 follow-up time points\ndata(simLongMediation)\n\n# Define variables\nAnodes <- c(\"A1\", \"A2\")\nCnodes <- NULL # No censoring in this example\nLnodes <- c(\"L1\", \"L2\") # Time-varying confounders\nMnodes <- c(\"M1\", \"M2\") # Mediators\nYnodes <- c(\"Y2\") # Final outcome only\nWnodes <- c(\"W1\", \"W2\") # Baseline covariates\n\n# Estimate natural direct and indirect effects using TMLE\nresult <- medltmle(data = simLongMediation,\n Anodes = Anodes,\n Cnodes = Cnodes,\n Lnodes = Lnodes,\n Mnodes = Mnodes,\n Ynodes = Ynodes,\n Wnodes = Wnodes,\n abar0 = c(0, 0), # Control treatment regime\n abar1 = c(1, 1), # Treated regime\n gform = NULL, # Use Super Learner (default)\n Yrange = c(80, 180),\n deterministic.g.function = NULL)\n\nsummary(result)\nThe summary() output provides estimates of the longitudinal total effect (TE), natural direct effect (NDE), and natural indirect effect (NIE), each accounting for the cumulative dynamics of treatment, mediators, and confounders over time.\nUsing medltmle, we can assess whether the long-term impact of the intervention on blood pressure is driven primarily by changes in BMI (indirect effect) or through other direct mechanisms. This approach allows for appropriate adjustment for time-varying confounding and flexible functional forms using machine learning.\nLongitudinal mediation analysis captures complex causal mechanisms unfolding over time. Tools such as medltmle make it feasible to estimate these effects under realistic assumptions, even when confounding and mediation evolve dynamically. Researchers are encouraged to use DAGs, model checking, and sensitivity analysis to validate findings in these more complex scenarios.\n\n\n\n7.4.4 Summary\nAdvanced mediation methods allow for more flexible and realistic modeling of causal mechanisms. Interventional effects provide an interpretable alternative to natural effects under weaker assumptions. Approaches that address intermediate confounding are crucial when post-treatment confounders exist. Longitudinal mediation methods account for repeated, time-dependent relationships, though at the cost of increased complexity. These tools are essential for applied researchers aiming to uncover nuanced pathways of causal influence.",
"crumbs": [
"Advanced Methods",
"<span class='chapter-number'>7</span> <span class='chapter-title'>Mediation Analysis</span>"
]
},
{
"objectID": "chapters/chapter7/index.html#sensitivity-analysis-in-mediation",
"href": "chapters/chapter7/index.html#sensitivity-analysis-in-mediation",
"title": "7 Mediation Analysis",
"section": "7.5 Sensitivity Analysis in Mediation",
"text": "7.5 Sensitivity Analysis in Mediation\nCausal mediation analysis relies on several strong identification assumptions, one of the most critical being the absence of unmeasured confounding between the mediator and the outcome. This assumption is often difficult to justify in observational studies, where the same covariates that confound the exposure-outcome relationship may not fully account for confounding of the mediator-outcome relationship. In this section, we review methods for assessing the robustness of mediation findings to potential violations of this assumption, focusing on bias formulas developed by VanderWeele and colleagues.\n\n7.5.1 Mediator-Outcome Confounding\nRecall that to identify the natural indirect effect (NIE), we require:\n\\[\nY^{a, m} \\perp\\!\\!\\!\\perp M \\mid A = a, X\n\\]\nThis means that, conditional on treatment and baseline covariates \\(X\\), the mediator must be as good as randomized with respect to the potential outcomes. In practice, this is often implausible due to omitted variables (e.g., psychological factors, unmeasured behaviors, or genetic traits) that may influence both the mediator and the outcome.\nWhen this assumption fails, estimated mediation effects—particularly the NIE—can be biased. Sensitivity analysis provides a way to quantify how strong such unmeasured confounding would need to be to substantially alter the conclusions of the analysis.\n\n\n7.5.2 VanderWeele-Style Bias Analysis\nVanderWeele (2010, 2015) developed analytic bias formulas that quantify how unmeasured mediator-outcome confounding might distort estimates of mediation effects. These formulas can be used to:\n\nPerform a sensitivity analysis by varying hypothetical values of confounding parameters\nIdentify the conditions under which the NIE or NDE would be reduced to zero\n\n\nBias Formula for Continuous Outcomes\nSuppose we estimate the NIE using linear models. Then the bias in the estimated NIE due to an unmeasured confounder \\(U\\) is approximately:\n\\[\n\\text{Bias}_{\\text{NIE}} \\approx \\rho_{MY \\cdot A,X} \\cdot \\rho_{MU \\cdot A,X} \\cdot \\sigma_Y \\cdot \\sigma_M\n\\]\nwhere: - \\(\\rho_{MY \\cdot A,X}\\): Partial correlation between \\(M\\) and \\(Y\\), given \\(A\\) and \\(X\\) - \\(\\rho_{MU \\cdot A,X}\\): Partial correlation between an unmeasured confounder \\(U\\) and both \\(M\\) and \\(Y\\) - \\(\\sigma_Y\\), \\(\\sigma_M\\): Standard deviations of \\(Y\\) and \\(M\\)\nBy varying \\(\\rho_{MU \\cdot A,X}\\) over a plausible range (e.g., -0.3 to 0.3), we can assess the impact of unmeasured confounding on the NIE.\n\n\nR Implementation Using medsens\nThe mediation package includes a function medsens() to perform this kind of sensitivity analysis following a call to mediate().\nlibrary(mediation)\n\n# Step 1: Fit the mediator and outcome models\nmed.model <- lm(M ~ A + X, data = data)\nout.model <- lm(Y ~ A + M + X, data = data)\n\n# Step 2: Estimate the mediation effects\nmed.out <- mediate(med.model, out.model, treat = \"A\", mediator = \"M\", boot = TRUE)\n\n# Step 3: Run sensitivity analysis\nsens.out <- medsens(med.out, rho.by = 0.01)\n\n# Step 4: Plot sensitivity analysis\nplot(sens.out, sens.par = \"rho\")\nThis generates a sensitivity plot showing how the estimated ACME (NIE) changes as a function of the sensitivity parameter \\(\\rho\\), which captures the strength of correlation between the error terms in the mediator and outcome models (i.e., residual confounding).\n\n\nInterpretation\nIf the ACME estimate remains far from zero even when \\(\\rho\\) is large (e.g., \\(\\rho = 0.3\\)), the mediation effect is considered robust to moderate levels of unmeasured confounding. Conversely, if a small \\(\\rho\\) is enough to explain away the effect, the result is considered sensitive.\n\n\nBinary Outcomes\nWhen \\(Y\\) is binary, similar bias formulas exist, though they are more complex and typically require modeling on the log-odds scale. The mediation package also supports sensitivity analysis for binary outcomes, assuming appropriate logistic models are used for both mediator and outcome regressions.\n\n\n\n7.5.3 Simulated Example: When Unmeasured Confounding Overturns the ACME\nTo illustrate the potential impact of unmeasured mediator-outcome confounding, we simulate a simple data-generating process in which an unobserved variable confounds the relationship between the mediator and the outcome. We then compare the naive (biased) estimate of the average causal mediation effect (ACME) to the true value obtained when the confounder is included in the model.\n\nData Generating Process\nWe simulate a binary treatment \\(A\\), a continuous mediator \\(M\\), and a continuous outcome \\(Y\\), along with a baseline covariate \\(X\\) and an unmeasured confounder \\(U\\). The mediator and outcome are generated as follows:\n\\[\nM = 0.5 A + 0.5 U + 0.3 X + \\varepsilon_M, \\quad \\varepsilon_M \\sim \\mathcal{N}(0,1)\n\\]\n\\[\nY = 0.3 A + 0.6 M + 0.6 U + 0.2 X + \\varepsilon_Y, \\quad \\varepsilon_Y \\sim \\mathcal{N}(0,1)\n\\]\nHere, \\(U\\) is unobserved and influences both \\(M\\) and \\(Y\\), violating the assumption of no unmeasured mediator-outcome confounding.\n\n\nSimulation Code\nset.seed(42)\nn <- 1000\nX <- rnorm(n)\nA <- rbinom(n, 1, 0.5)\nU <- rnorm(n)\nM <- 0.5*A + 0.5*U + 0.3*X + rnorm(n)\nY <- 0.3*A + 0.6*M + 0.6*U + 0.2*X + rnorm(n)\ndata <- data.frame(A, M, Y, X, U)\n\n\nNaive Estimation (Ignoring Unmeasured Confounding)\nWe fit the standard mediation models, omitting \\(U\\):\n# Mediator model\nmed.model <- lm(M ~ A + X, data = data)\n\n# Outcome model\nout.model <- lm(Y ~ A + M + X, data = data)\n\n# Naive ACME estimate\nalpha1 <- coef(med.model)[\"A\"]\nbeta2 <- coef(out.model)[\"M\"]\nnaive_acme <- alpha1 * beta2\n\n\nTrue Estimation (Adjusting for U)\nWe repeat the analysis including \\(U\\) to recover the true ACME:\n# True mediator model\nmed.model.true <- lm(M ~ A + X + U, data = data)\n\n# True outcome model\nout.model.true <- lm(Y ~ A + M + X + U, data = data)\n\n# True ACME estimate\nalpha1.true <- coef(med.model.true)[\"A\"]\nbeta2.true <- coef(out.model.true)[\"M\"]\ntrue_acme <- alpha1.true * beta2.true\n\n\nResults\nThe estimates from the simulation were:\n\nNaive ACME (ignoring \\(U\\)): 0.473\nTrue ACME (adjusting for \\(U\\)): 0.299\n\n\n\nInterpretation\nThis example demonstrates how failing to adjust for unmeasured mediator-outcome confounding can lead to substantial bias in estimated mediation effects. The naive ACME overstates the indirect effect by more than 50%, incorrectly suggesting a stronger mediating role for \\(M\\). If the unmeasured confounder \\(U\\) were more strongly associated with both \\(M\\) and \\(Y\\), the indirect effect could be entirely explained by confounding, effectively reducing the true ACME to zero.\nThis underscores the importance of conducting sensitivity analysis in mediation studies, especially when unmeasured mediator-outcome confounding is plausible. Even modest violations of this assumption can have a large impact on the validity of causal interpretations.\n\n\n\n7.5.4 Summary\nSensitivity analysis plays a critical role in mediation analysis, especially when the assumption of no unmeasured mediator-outcome confounding is in doubt. VanderWeele-style bias formulas provide a transparent and interpretable way to assess how robust estimated mediation effects are to violations of this assumption. Tools such as the medsens() function in R make it easy to implement these diagnostics and communicate them effectively through graphical summaries.",
"crumbs": [
"Advanced Methods",
"<span class='chapter-number'>7</span> <span class='chapter-title'>Mediation Analysis</span>"
]
},
{
"objectID": "chapters/chapter7/index.html#applications-and-case-studies",
"href": "chapters/chapter7/index.html#applications-and-case-studies",
"title": "7 Mediation Analysis",
"section": "7.6 Applications and Case Studies",
"text": "7.6 Applications and Case Studies\nIn this section, we present a complete applied example of mediation analysis using simulated data. We walk through the process of estimating direct and indirect effects, visualizing the underlying causal structure with a directed acyclic graph (DAG), and plotting the estimated effects for interpretation. This example illustrates how the methods introduced in earlier sections can be combined in practice.\n\n7.6.1 Applied Example 1: The Effect of a Lifestyle Program on Blood Pressure via Weight Loss\nSuppose we are studying whether a lifestyle intervention program (treatment \\(A\\)) reduces systolic blood pressure (\\(Y\\)) by promoting weight loss (\\(M\\)). Participants are randomized to either receive the program (\\(A = 1\\)) or standard care (\\(A = 0\\)). We also collect baseline data on age and physical activity level, denoted \\(X\\).\nWe hypothesize the following causal pathways:\n\nThe intervention directly reduces blood pressure.\nThe intervention also indirectly reduces blood pressure by helping participants lose weight.\n\n\nSimulating the Data\nset.seed(101)\nn <- 1000\nage <- rnorm(n, mean = 50, sd = 10)\nactivity <- rnorm(n, mean = 0, sd = 1)\nX <- data.frame(age, activity)\n\nA <- rbinom(n, 1, 0.5) # Random assignment to intervention\nM <- 30 - 2*A - 0.1*age - 0.5*activity + rnorm(n) # Weight (mediator)\nY <- 140 - 0.5*A + 0.6*M - 0.2*age - 1*activity + rnorm(n) # Blood pressure\ndata <- data.frame(A, M, Y, age, activity)\n\n\nFitting Mediation Models\nWe now fit linear models for the mediator and the outcome, adjusting for covariates.\nlibrary(mediation)\n\n# Mediator model\nmed.model <- lm(M ~ A + age + activity, data = data)\n\n# Outcome model\nout.model <- lm(Y ~ A + M + age + activity, data = data)\n\n# Estimate ACME, ADE, and TE\nmed.out <- mediate(med.model, out.model, treat = \"A\", mediator = \"M\",\n boot = TRUE, sims = 1000)\n\nsummary(med.out)\nThe summary() output provides estimates of the average causal mediation effect (ACME), the average direct effect (ADE), and the total effect (TE), along with 95% confidence intervals based on bootstrapping.\n\n\nInterpreting Results\nAssume the results show:\n\nACME (indirect effect): -1.18 mmHg\nADE (direct effect): -0.47 mmHg\nTotal effect: -1.65 mmHg\nProportion mediated: 71.5%\n\nThis indicates that most of the effect of the intervention on blood pressure is mediated through weight loss. Only a small portion of the effect is direct.\n\n\nDAG-Based Illustration of the Causal Structure\nWe can represent the assumed causal model using a DAG, which helps clarify identification assumptions and model structure.\n\n\nShow the code\nflowchart TD\n A[A] --> M[M]\n M --> Y[Y]\n A --> Y\n X[X = {age, activity}] --> M\n X --> Y\n\n\n\n\n\n\n\n\n\n\n\nThis DAG shows the treatment affecting both the mediator and the outcome, and baseline covariates \\(X\\) confounding both mediator and outcome relationships. There are no arrows from unmeasured variables, indicating we assume no unmeasured confounding.\n\n\nVisualizing Direct and Indirect Effects\nTo communicate mediation effects more clearly, we can visualize them using a simple bar plot.\nlibrary(ggplot2)\n\neffects <- data.frame(\n Effect = c(\"Indirect (ACME)\", \"Direct (ADE)\", \"Total\"),\n Estimate = c(-1.18, -0.47, -1.65)\n)\n\nggplot(effects, aes(x = Effect, y = Estimate, fill = Effect)) +\n geom_bar(stat = \"identity\", color = \"black\") +\n theme_minimal() +\n labs(title = \"Decomposition of the Intervention Effect on Blood Pressure\",\n y = \"Effect Size (mmHg)\", x = \"\") +\n scale_fill_brewer(palette = \"Set2\") +\n geom_hline(yintercept = 0, linetype = \"dashed\")\nThis plot visually separates the indirect and direct effects, helping non-technical audiences understand how much of the total effect operates through the mediator.\n\n\nSummary\nThis applied example illustrates a full mediation analysis workflow, from hypothesizing a causal structure to fitting models, estimating effects, visualizing pathways, and interpreting results. By grounding the analysis in a DAG and using appropriate statistical models, we gain insight into both the magnitude and mechanism of the intervention’s impact. Mediation analysis thus plays a central role in making causal inferences not only about whether an effect exists, but also about how it operates.\n\n\n\n7.6.2 Applied Example 2: Professional Occupation, Education, and Income\nIn this case study, we use real data to explore whether individuals in professional occupations earn more income in part because they have higher levels of education. This is a classic mediation question in the social sciences. The analysis is based on the Prestige dataset from the carData R package, which contains information on Canadian occupations, including income, education, and occupational type.\n\nResearch Question\nWe hypothesize that: - Working in a professional occupation (\\(A\\)) leads to higher income (\\(Y\\)). - This effect is partially mediated by higher educational attainment (\\(M\\)).\nWe also control for the percentage of women in the occupation (\\(X\\)), as it may influence both education levels and income.\n\n\nCausal DAG\nWe can represent this scenario with the following directed acyclic graph (DAG):\n\n\nShow the code\nflowchart TD\n A[A (Professional)] --> M[M (Education)]\n M --> Y[Y (Income)]\n A --> Y\n X[X (% Women)] --> M\n X --> Y\n\n\n\n\n\n\n\n\n\n\n\n\n\nData Preparation and Mediation Models in R\nWe recode the variable type into a binary treatment, where 1 indicates a professional occupation. The mediator is years of education, and the outcome is average income. We control for women, the percentage of women in each occupation.\nlibrary(carData)\nlibrary(mediation)\ndata(Prestige)\n\n# Clean and prepare data\ndf <- na.omit(Prestige)\ndf$professional <- ifelse(df$type == \"prof\", 1, 0)\n\n# Fit mediator model\nmed.model <- lm(education ~ professional + women, data = df)\n\n# Fit outcome model\nout.model <- lm(income ~ professional + education + women, data = df)\n\n# Estimate mediation effects\nmed.out <- mediate(med.model, out.model,\n treat = \"professional\", mediator = \"education\",\n boot = TRUE, sims = 1000)\nsummary(med.out)\n\n\nResults\nAssume the results from summary(med.out) return:\n\nAverage Causal Mediation Effect (ACME): 2200 (95% CI: 1300–3100)\nAverage Direct Effect (ADE): 4800 (95% CI: 3500–6100)\nTotal Effect: 7000 (95% CI: 5800–8200)\nProportion mediated: 31%\n\nThese results suggest that approximately one-third of the income advantage associated with professional occupations can be explained by higher levels of education, while the remaining two-thirds represents a direct effect of the occupation type.\n\n\nVisualizing the Effects\nWe can visualize the decomposition of the total effect into direct and indirect components:\nlibrary(ggplot2)\n\neffects <- data.frame(\n Effect = c(\"Indirect (ACME)\", \"Direct (ADE)\", \"Total Effect\"),\n Estimate = c(2200, 4800, 7000)\n)\n\nggplot(effects, aes(x = Effect, y = Estimate, fill = Effect)) +\n geom_bar(stat = \"identity\", color = \"black\") +\n theme_minimal() +\n labs(title = \"Decomposition of Effect of Profession on Income\",\n y = \"Effect Size (Dollars)\", x = \"\") +\n scale_fill_brewer(palette = \"Set2\") +\n geom_hline(yintercept = 0, linetype = \"dashed\")\n\n\nConclusion\nThis case study shows how mediation analysis can be used to unpack the mechanisms behind occupational income disparities. By applying mediation models to real-world data, we can quantify how much of a treatment effect operates through a hypothesized mediator. In this example, education explains a substantial portion—but not all—of the income differences associated with professional work. The analysis also highlights the importance of DAGs for clarifying assumptions and visual tools for communicating complex causal pathways.",
"crumbs": [
"Advanced Methods",
"<span class='chapter-number'>7</span> <span class='chapter-title'>Mediation Analysis</span>"
]
},
{
"objectID": "chapters/chapter7/index.html#glossary",
"href": "chapters/chapter7/index.html#glossary",
"title": "7 Mediation Analysis",
"section": "7.7 Glossary",
"text": "7.7 Glossary\n\nMain term\n\nDescription of main term.",
"crumbs": [
"Advanced Methods",
"<span class='chapter-number'>7</span> <span class='chapter-title'>Mediation Analysis</span>"
]
},
{
"objectID": "chapters/chapter8/index.html",
"href": "chapters/chapter8/index.html",
"title": "8 Sensitivity analysis",
"section": "",
"text": "8.1 Overview of methods for sensitivity analysis in causal inference\nIn the process of causal inference, we frequently try to estimate the population effect of a binary treatment on an outcome variable by comparing the means of potential outcomes \\(Y(1)\\) and \\(Y(0)\\), where \\(Y(t)\\) is the (bounded) outcome of a random individual under treatment \\(A\\), (Neyman, 1923; Rubin, 1974).” This contrast, known as the Average Treatment Effect (ATE), must be identified from observational data (i.e., non-experimental investigations) based on untestable hypotheses, i.e., consistency, conditional ignorability, exchangeability or independence, and positivity. Under these assumptions, the ATE is identified from the observed data distribution via the g formula:\n\\[\\begin{aligned}\n\\textit{ATE} &= \\int_w \\Big\\{E[Y \\mid A=1, \\textbf{W=w}] - E[Y \\mid A=0, \\textbf{W=w}] \\Big\\} dF(w),\n\\end{aligned} \\tag{8.1}\\]\nwhere \\(F(\\cdot)\\) denotes the cumulative distribution function of \\(w\\).\nUsing \\(n\\) independent and identically distributed copies of \\(O=(W, A, Y)\\), many methods have been developed to draw inference about the ATE functional, e.g., propensity score matching (Rosenbaum & Rubin, 1983), g-computation (Robins, 1986), (stabilized) inverse probability weighting (Hernán & Robins, 2006), augmented inverse probability weighting (Robins et al., 1994), and targeted maximum likelihood (Der Laan & Rubin, 2006) as seen in the previous chapters.\nThe conditional conditional independence assumption states that there exists a set of measured pre-treatment covariates (W) such that treatment is conditionally independent of the potential outcomes given W, i.e.,\n\\[Y(a) \\perp A \\mid \\textbf{W} \\quad \\text{ for } a=0,1; \\tag{8.2}\\]\nimplies that there are no unmeasured confounders (U) between treatment and outcome.\nIn sensitivity analysis from observational studies targeting the study of causal relationships, the robustness of inference to potential unmeasured confounding is always needed and considered crucial. In this chapter, we aim to briefly review the literature on sensitivity analysis in causal inference and provide a computational overview of the current methods for evaluating the sensitivity of the analysis to the unmeasured confounding assumption about the ATE (Equation 8.2).\nTo investigate the effect of residual unmeasured confounding on the causal effect estimate, sensitivity analysis to the “no unmeasured confounders” assumption is commonly used. (Ding & VanderWeele, 2016) Assessing how robust an estimated causal effect is to potential unmeasured confounding is the principal aim of the following methods.\nThe E-value was first introduced (Ding & VanderWeele, 2016). The authors proposed a sensitivity analysis technique without any assumptions about the unmeasured confounders. They derived a bound on the relative risk (RR) scale based on two parameters. However, the method does not accommodate complex measured confounders.\nL. Z. Matthew A. Masten Alexandre Poirier (2024) introduced a nonparametric methodology to evaluate the sensitivity of results related to causal inference under the assumption of conditional independence. He introduced the concept of conditional partial independence, which is a less stringent condition than full conditional independence. Specifically, he examined a group of assumptions labeled conditional c-dependence, which quantify the relaxation of conditional independence through a single parameter, c. For every positive c, conditional independence is only partially fulfilled, preventing the exact determination of treatment effect parameters, such as the ATE; instead, only bounds can be derived. Masten describes these bounds in relation to c: smaller c values result in tighter bounds, whereas larger c values produce broader bounds. The extent of these bounds, and thus the sensitivity of the results, is contingent upon the data.\nRosenbaum’s (Rosenbaum, 1987) method identified the smallest \\(\\Gamma\\) ensuring the ATE cannot be deemed “statistically significant” within matched studies (Tan, 2006), and Zhao et al. (Zhao et al., 2019) established ATE bounds by comparing the odds of receiving treatment with both measured and unmeasured confounders versus only measured confounders. Recent advancements by Dorn et al. (Dorn et al., 2021; Dorn & Guo, 2022) have further refined these bounds. The final bounds are expressed in a closed form, incorporating the observed propensity score, a specific transformed-outcome regression, and conditional quantiles of the outcome given treatment and covariates.\nMoreover, (Dorn et al., 2021) demonstrated that estimators for these bounds can be developed that remain valid—though somewhat conservative—even when the conditional quantiles are improperly specified, provided that at least one of the other two nuisance functions is estimated consistently. Other methods, such as those described by (Dı́az & Laan, 2013) and (Dı́az et al., 2018), involve deriving bounds on the Average Treatment Effect (ATE) by limiting the difference in mean potential outcomes between patients who received treatment and those who received control, considering covariates. (Bonvini & Kennedy, 2022) utilized a contamination model to provide bounds on the ATE by limiting the fraction of units influenced by unmeasured confounding. The following two sections focus on the E-value (developed in both Stata and R statistical software) and the Conditional C-dependence (only available in Stata) from a computationally applied perspective.",
"crumbs": [
"Sensitivity Analysis & Discussion",
"<span class='chapter-number'>8</span> <span class='chapter-title'>Sensitivity analysis</span>"
]
},
{
"objectID": "chapters/chapter8/index.html#the-e-value",
"href": "chapters/chapter8/index.html#the-e-value",
"title": "8 Sensitivity analysis",
"section": "8.2 The E-value",
"text": "8.2 The E-value\nThe E-value is the minimum strength of a causal effect, on the RR scale, that an unmeasured confounder would need to have with both the treatment (E) and the outcome (D) to fully explain away a specific treatment-outcome association, conditional on the measured covariate (note that before we defined the treatment or exposure as (A) and the outcome as (Y). We decide to introduce here E and D to match the software convenctions further presented in this section). The E-value makes no assumptions on whether the unmeasured confounders (U) are binary, continuous, or categorical, on how they are distributed, or on the number of confounders, and it can be applied to several common outcome types and estimands in observational research. A large E-value implies that considerable unmeasured confounding would be needed to explain away an effect estimate. A small E-value implies little unmeasured confounding would be needed to explain away an effect estimate. Further developments (VanderWeele & Arah, 2011) introduced a general “bias” formula for the difference between the possibly incorrect expression for the ATE under no unmeasured confounding and the correct expression for the ATE when accounting for both measured and unmeasured confounding in terms of many sensitivity parameters.\nTo facilitate these sensitivity analyses, an R package (“EValue”)(Maya B. Mathur, 2018) was developed and also an online E-value calculator is online available at https://mmathur.shinyapps.io/evalue/ that computes E-values for a variety of outcome measures.\nThe E-value seminal publication considered the historical study conducted by Hammond and Horn(Hammond, 1958) as an example to describe it. The study focused on the tobacco effect on lung cancer with a point estimate of the observed RR of cigarette smoking on lung cancer of 10.73 (95% CI 8.02, 14.36). Based on it we will illustrate the use of the R package to evaluate the effect of a common genetic confounder (U) on the observed RR of the treatment or exposure (E) on the outcome (D) using a set of boxes including the code and a detailed commented explanation.\nBox 7.1. Use of the E-value: R-package\n# You can install the EValue from CRAN using:\ninstall.packages(\"EValue\")\n# Then, load the package:\nlibrary(EValue)\n# The E-value for the association between cigarette smoking and lung cancer as observed by Hammond and Horn in 1958 can be computed as follows:\nevalues.RR(est = 10.73, lo = 8.02, hi = 14.36)\n#> point lower upper\n#> RR 10.73000 8.02000 14.36\n#> E-values 20.94777 15.52336 NA\nThe E-value of 20.95 tells us that a confounder, or set of confounders (U), would have to be associated with a 20-fold increase in the risk of lung cancer and must be 20 times more prevalent in smokers than non-smokers to explain the observed RR. If the strength of one of these relationships were weaker, the other would have to be stronger for the causal effect of smoking on lung cancer to be truly null.\nThe package provides a plot functionality that allows the user to see how the magnitude of the exposure-confounder and the confounder-outcome relationships would have to vary to fully explain the observed association.\nBox 7.2. Plotting the E-value: R-package\nbias_plot(10.73, xmax = 40)\n\n\n\n\n\n\nFigure 8.1: E-value upper bound\n\n\n\nThis tells us, for example, that if the exposure-confounder parameter \\(RR_{EU}\\) were 15, meaning that the confounder(s) is 15 times more likely among smokers, the \\(RR_{UD}\\) for the confounder outcome relationship parameter would have to be about 40 for it to even be possible that confounding explains the entire observed association.\nIt is also possible to plot the lower bound of the confidence interval\nBox 7.3. Plotting the E-value: R-package\nbias_plot(8.02, xmax = 40)\nwhich we calculated an E-value of 15.52 for the above.\n\n\n\n\n\n\nFigure 8.2: E-value lower bound\n\n\n\nScholars may evaluate the potential for confounding influences to alter the observed relationship to any other value, such as diminishing the observed relationship to a true causal effect that lacks scientific significance or amplifying a near-null observed relationship to one of scientific importance. For instance, to adjust an observed relative risk of 3.5 down to a true causal relative risk of 2.5, the E-value is 2.15. This represents the smallest amount of unmeasured confounding necessary to shift both the estimate and confidence interval toward your defined true value instead of the null value (Box 7.4).\nBox 7.4. E-value shifts: R-package\n# summary() used to print the E-value only\nsummary(evalues.RR(est = 3.5, true = 2.5))\n#[1] 2.148331\nThe E-value for the association between cigarette smoking and lung cancer as observed by Hammond and Horn in 1958 can be computed in Stata as follows (Ariel Linden, 2020):\nBox 7.5. E-value: Stata\nevalue rr 10.73, lcl(8.02) ucl(14.36) figure\n\n\n\n\n\n\nFigure 8.3: E-value lower and upper bounds in Stata",
"crumbs": [
"Sensitivity Analysis & Discussion",
"<span class='chapter-number'>8</span> <span class='chapter-title'>Sensitivity analysis</span>"
]
},
{
"objectID": "chapters/chapter8/index.html#conditional-c-dependence",
"href": "chapters/chapter8/index.html#conditional-c-dependence",
"title": "8 Sensitivity analysis",
"section": "8.3 Conditional c-dependence",
"text": "8.3 Conditional c-dependence\nIn causal inference, a fundamental question is determining and estimating how a treatment variable A influences an outcome variable Y. A frequently adopted assumption for identifying these effects is unconfoundedness, also referred to as selection on observables, conditional independence, ignorability, or exogenous selection. This assumption is non-falsifiable, as the data itself cannot confirm its validity. However, researchers often question: How crucial is this assumption for their analyses? In other words, how robust are the results derived under the conditional independence assumption?\nIn their work, (A. P. Matthew A. Masten, 2018) present theoretical findings aimed at addressing this question. They introduce the concept of conditional partial independence, which is a relaxation of full conditional independence. The focus is on a specific type of assumption known as conditional c-dependence, quantifying deviations from conditional independence using a parameter c. When c is positive, conditional independence is only partial, preventing precise determination of treatment effect parameters such as ATE or ATT, resulting in bounded estimates instead. (A. P. Matthew A. Masten, 2018) describe these bounds as dependent on C, with smaller c leading to tighter bounds and larger c producing wider ones. The extent of these bounds, and thus the sensitivity of results, is influenced by the data. The paper by (L. Z. Matthew A. Masten Alexandre Poirier, 2024) explains the estimation strategy used from an applied computational perspective by using a Stata package named tesensitivity.\nTo define conditional c-dependence, we first define the following random variables:\n\n\\(Y^{a}\\) : the potential outcome for a given treatment \\(a \\in\\{0,1\\}\\)\n\\(A\\) : the treatment\n\\(W\\) : a vector of covariates\n\\(Y\\) : the observed outcome\n\nThe observed outcome satisfies by consistency\n\\[Y = (1-A) Y^{0} + A Y^{1}.\\]\nRather than observing the full data generating process, \\((Y^{0}, Y^{1}, A, Y)\\), we only observe: O=(Y, A, W).\nWe say that \\(A\\) is conditionally c-dependent with \\(Y^{a}\\) given \\(W\\) if:\n\\[\\textbf{supp} \\underset{y_{a} \\in \\operatorname{supp}(Y^{a}\\mid W=w)}{\\left|\\mathbb{P}\\left(A=1 \\mid Y^{a}=a, W=w\\right)-\\mathbb{P}(A=1 \\mid W=w)\\right|} \\leq c,\\]\nfor all \\(w\\) in \\(\\operatorname{supp}(\\mathbf{W})\\).\nUnder this assumption, the identified set for a treatment effect statistic will be a closed interval, which depends on c and the distribution of O=(Y, A, W).\nThe main purpose of the tesensitivity package is to calculate these bounds and show how the identified set for treatment effect statistics i.e., ATE varies with the sensitivity parameter c. In addition to estimating these bounds for a range of values of c, tesensitivity also calculates a breakdown point relative to a conclusion about a treatment effect statistic i.e., the ATE. As discussed in (L. Z. Matthew A. Masten Alexandre Poirier, 2024), the breakdown point is the maximum value of c under which the conclusion still holds.\nEmploying a Stata excerpt dataset from (Cattaneo, 2010) and (Almond et al., 2005), alongside annotated boxes containing commented code, we demonstrate the computation and interpretation of the sensitivity parameter \\(c\\) using the Stata package tesensitivity.\nTreatment-effects modeling serves as a vital method for deriving causal effects akin to those from experiments, even when working with observational data. While conducting an experiment would be ideal, such endeavors are often impractical due to ethical or financial constraints. For instance, consider assessing the impact of cigarette smoking (the intervention) on infant birthweight (the resultant outcome). Ideally, an experiment would involve selecting a representative group of pregnant women, dividing them into a control group instructed not to smoke and a treatment group required to smoke a designated number of cigarettes each day.\nConsider addressing this question by employing the Stata command teffects. To ensure our estimates are reliable, it is crucial to confirm that when we account for observable characteristics, it appears as though pregnant mothers were randomly distributed between control and treatment groups. We model the birthweight (bweight) as a function of the number of prenatal visits (nprenatal), whether the mother is married (mmarried), whether this baby is her first pregnancy (fbaby), and maternal education (medu). The treatment, smoking during pregnancy (mbsmoke), is modeled as a function of the same variables and concerning whether the mother consumed alcohol during her pregnancy. For reference, we start by estimating the ATE of these experimental and non-experimental samples based on maternal smoking using the eltmle Stata package. (Luque-Fernandez, 2019) (Box 7.5)\nBox 7.6. ATE using effects and eltmle in Stata\n# To allow intalling Stata programs from GitHub:\n\n net install github, from(\"https://haghish.github.io/github/\")\n\n# To install eltmle Stata program to compute the ATE:\n\n github install migariane/eltmle\n which eltmle\n help eltmle\n\n# These will be the data and variables used in the analysis:\n\n webuse cattaneo2, clear\n describe\n local Y \"bweight\"\n local A \"mbsmoke\"\n local W \"nprenatal mmarried fbaby medu\"\n eltmle `Y' `A' `W', tmle\n\n# Output:\n\n Variable | Obs Mean Std. dev. Min Max\n-------------+---------------------------------------------------------\n POM1 | 4,642 2843.307 114.191 2369.31 3539.972\n POM0 | 4,642 3061.247 150.1519 2453.428 3931.552\n ps | 4,642 .1861267 .1110024 .0368017 .6847253\n--------------------------------\nTMLE: Average Treatment Effect\n--------------------------------\nATE: | -217.9\nSE: | 22.8\nP-value: | 0.0000\n95%CI: | -262.6, -173.3\n--------------------------------\n-----------------------------\nTMLE: Causal Risk Ratio (CRR)\n-----------------------------\nCRR: 0.93; 95%CI:(0.91, 0.94)\n-----------------------------\n-------------------------------\nTMLE: Marginal Odds Ratio (MOR)\n-------------------------------\nMOR: 0.84; 95%CI:(0.81, 0.87)\n-------------------------------\n\n# Using the Stata software command for causal inference and the augmented\n# inverse probability weights (AIPW) algorithm:\n\n teffects aipw (`Y' `W') (`A' `W')\n\n# Output:\nIteration 0: EE criterion = 3.069e-23\nIteration 1: EE criterion = 2.182e-25\n\nTreatment-effects estimation Number of obs = 4,642\nEstimator : augmented IPW\nOutcome model : linear by ML\nTreatment model: logit\n------------------------------------------------------------------------------\n | Robust\n bweight | Coefficient std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\nATE mbsmoke |\n (1 vs 0) | -223.4343 24.3635 -9.17 0.000 -271.1858 -175.6827\n-------------+----------------------------------------------------------------\nThe ATE is interpreted as the mean risk difference of 217.9 fewer grams in the birth weight from infants born to mothers who smoke vs. infants born from non-smoker mothers in an additive scale using eltmle and 223 fewer grams using the aipw Stata option from the teffects command.\nUnder the standard unconfoundedness assumption, the treatment effect is negative and statistically significant. Now we will use the tesensitivity package to analyze how sensitive these results are to this assumption. The main subcommand of the tesensitivity package is cpi, i.e., conditional partial independence. This command estimates bounds on the ATE given a set of c-dependence values and calculates the breakdown point for the conclusion that the treatment effect statistic is above a given threshold. First, we calculate bounds on the ATE. By default, the command calculates bounds for a uniform grid of 40 values of c, and the breakdown point for the conclusion that the ATE estimation does not contain the null.\nBox 7.7. tesensitivity: Stata\n# Running the command:\n\n tesensitivity cpi (`Y' `W') (`A' `W'), ate\n\n# Output:\n\nTreatment effects sensitivity\nAnalysis : cond. partial independence Number of obs= 4642\nOutcome model : linear quantile Breakdown = 0.058\nTreatment model : logistic Conclusion = ate > 0\nOutcome variable : bweight\n-------------------------------------\n c | ate\n-------------------+-----------------\n 0.000 | [ -220, -220]\n 0.026 | [ -309, -134]\n 0.051 | [ -414, -38]\n 0.077 | [ -587, 120]\n 0.103 | [ -826, 317]\n 0.128 | [-1,027, 493]\n 0.154 | [-1,218, 629]\n ...\n 0.769 | [-2,475, 1,825]\n 0.795 | [-2,487, 1,844]\n 0.821 | [-2,500, 1,867]\n 0.846 | [-2,511, 1,889]\n 0.872 | [-2,518, 1,901]\n 0.897 | [-2,523, 1,906]\n 0.923 | [-2,524, 1,906]\n 0.949 | [-2,524, 1,906]\n 0.974 | [-2,524, 1,906]\n 1.000 | [-2,524, 1,906]\n-------------------------------------\nThe grid of values show that the breakdown point computation for c is 0.077. Remember that the breakdown point is the maximum value of c under which the conclusion still holds. For example, if we consider the conclusion that the ATE is negative as in our example, then the breakdown point is the minimum value of c such that 0 is included in the identified 95% CI for the ATE in the set. The package also includes tools to visualize the analysis, interpret the scale of c-dependence, and compare results of multiple sensitivity analyses. Note that the value of c is small indicating weak unconfoundeness assumption based on the observed data.\nBox 7.8. tesensitivity visual tools in Stata\ntesensitivity cpiplot\n\n\n\n\n\n\nFigure 8.4: Conditional c-dependence: breakdown point",
"crumbs": [
"Sensitivity Analysis & Discussion",
"<span class='chapter-number'>8</span> <span class='chapter-title'>Sensitivity analysis</span>"
]
},
{
"objectID": "chapters/chapter8/index.html#glossary",
"href": "chapters/chapter8/index.html#glossary",
"title": "8 Sensitivity analysis",
"section": "8.4 Glossary",
"text": "8.4 Glossary\n\nMain term\n\nDescription of main term.\n\n\n\n\n\n\nAlmond, D., Chay, K. Y., & Lee, D. S. (2005). The costs of low birth weight. The Quarterly Journal of Economics, 120(3), 1031–1083.\n\n\nAriel Linden, T. J. V., Maya B. Mathur. (2020). Conducting sensitivity analysis for unmeasured confounding in observational studies using e-values: The evalue package. The Stata Journal: Promoting Communications on Statistics and Stata, 20(1), 162–175. https://doi.org/10.1177/1536867x20909696\n\n\nBonvini, M., & Kennedy, E. H. (2022). Sensitivity analysis via the proportion of unmeasured confounding. Journal of the American Statistical Association, 117(539), 1540–1550.\n\n\nCattaneo, M. D. (2010). Efficient semiparametric estimation of multi-valued treatment effects under ignorability. Journal of Econometrics, 155(2), 138–154. https://econpapers.repec.org/RePEc:eee:econom:v:155:y:2010:i:2:p:138-154\n\n\nDer Laan, M. J. van, & Rubin, D. (2006). Targeted maximum likelihood learning. The International Journal of Biostatistics, 2(1), Article 11.\n\n\nDing, P., & VanderWeele, T. J. (2016). Sensitivity analysis without assumptions. Epidemiology, 27(3), 368.\n\n\nDı́az, I., & Laan, M. J. van der. (2013). Sensitivity analysis for causal inference under unmeasured confounding and measurement error problems. The International Journal of Biostatistics, 9(2), 149–160.\n\n\nDı́az, I., Luedtke, A. R., & Laan, M. J. van der. (2018). Sensitivity analysis. In Targeted learning in data science (pp. 511–522). Springer.\n\n\nDorn, J., & Guo, K. (2022). Sharp sensitivity analysis for inverse propensity weighting via quantile balancing. Journal of the American Statistical Association, 1–13.\n\n\nDorn, J., Guo, K., & Kallus, N. (2021). Doubly-valid/doubly-sharp sensitivity analysis for causal inference with unmeasured confounding. arXiv Preprint arXiv:2112.11449.\n\n\nHammond, E. C. (1958). SMOKING AND DEATH RATES—REPORT ON FORTY-FOUR MONTHS OF FOLLOW-UP OF 187,783 MEN. Journal of the American Medical Association, 166(11), 1294. https://doi.org/10.1001/jama.1958.02990110030007\n\n\nHernán, M. A., & Robins, J. M. (2006). Estimating causal effects from epidemiological data. Journal of Epidemiology & Community Health, 60(7), 578–586.\n\n\nLuque-Fernandez, M. A. (2019). migariane/meltmle: Ensemble Learning Targeted Maximum Likelihood Estimation for Stata users | Zenodo. https://zenodo.org/record/2560828\n\n\nMatthew A. Masten, A. P. (2018). Identification of treatment effects under conditional partial independence. Econometrica, 86(1), 317–351. https://doi.org/10.3982/ecta14481\n\n\nMatthew A. Masten, L. Z., Alexandre Poirier. (2024). Assessing sensitivity to unconfoundedness: Estimation and inference. Journal of Business &Amp; Economic Statistics, 42(1), 1–13. https://doi.org/10.1080/07350015.2023.2183212\n\n\nMaya B. Mathur, C. A. R., Peng Ding. (2018). Web site and r package for computing e-values. Epidemiology, 29(5), e45–e47. https://doi.org/10.1097/ede.0000000000000864\n\n\nNeyman, J. (1923). Sur les applications de la thar des probabilities aux experiences agaricales: Essay des principle. Excerpts reprinted (1990) in English. Statistical Science, 5, 463–472.\n\n\nRobins, J. M. (1986). A new approach to causal inference in mortality studies with sustained exposure periods – application to control of the healthy worker survivor effect. Mathematical Modeling, 7, 1393–1512.\n\n\nRobins, J. M., Rotnitzky, A., & Zhao, L. P. (1994). Estimation of regression coefficients when some regressors are not always observed. Journal of the American Statistical Association, 89, 846–866.\n\n\nRosenbaum, P. R. (1987). Sensitivity analysis for certain permutation inferences in matched observational studies. Biometrika, 74(1), 13–26.\n\n\nRosenbaum, P. R., & Rubin, D. B. (1983). The central role of the propensity score in observational studies for causal effects. Biometrika, 70, 41–55.\n\n\nRubin, D. B. (1974). Estimating causal effects of treatments in randomized and non-randomized studies. Journal of Educational Psychology, 66, 688–701.\n\n\nTan, Z. (2006). A distributional approach for causal inference using propensity scores. Journal of the American Statistical Association, 101(476), 1619–1637.\n\n\nVanderWeele, T. J., & Arah, O. A. (2011). Bias formulas for sensitivity analysis of unmeasured confounding for general outcomes, treatments, and confounders. Epidemiology, 42–52.\n\n\nZhao, Q., Small, D. S., & Bhattacharya, B. B. (2019). Sensitivity analysis for inverse probability weighting estimators via the percentile bootstrap. Journal of the Royal Statistical Society: Series B, 81(4), 735–761.",
"crumbs": [
"Sensitivity Analysis & Discussion",
"<span class='chapter-number'>8</span> <span class='chapter-title'>Sensitivity analysis</span>"
]
},
{
"objectID": "chapters/chapter9/index.html",
"href": "chapters/chapter9/index.html",
"title": "9 Discussion",
"section": "",
"text": "9.1 Glossary",
"crumbs": [
"Sensitivity Analysis & Discussion",
"<span class='chapter-number'>9</span> <span class='chapter-title'>Discussion</span>"
]
},
{
"objectID": "chapters/chapter9/index.html#glossary",
"href": "chapters/chapter9/index.html#glossary",
"title": "9 Discussion",
"section": "",
"text": "Main term\n\nDescription of main term.",
"crumbs": [
"Sensitivity Analysis & Discussion",
"<span class='chapter-number'>9</span> <span class='chapter-title'>Discussion</span>"
]
}
]