1 Star 1 Fork 2

连享会/causalgraphs_latex

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
graphical-models-causal.tex 90.58 KB
一键复制 编辑 原始数据 按行查看 历史
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268
\documentclass[a4paper]{report}
\usepackage{geometry}
\usepackage{fullpage}
\usepackage{amsmath}
\usepackage{lscape}
\usepackage{fancyvrb}
\usepackage{parskip}
\usepackage{enumerate}
\usepackage{framed}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{tikz}
\usetikzlibrary{positioning, calc, shapes.geometric, shapes, shapes.multipart, arrows.meta, arrows, decorations.markings, external, trees}
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=black,
filecolor=black,
urlcolor=blue,
}
\pagestyle{fancy}
\fancyhf{}
\lfoot{Murray}
\rfoot{\thepage}
\renewcommand{\headrulewidth}{0pt}
\title{Graphical Models for Causal Inference using LaTeX}
\author{Eleanor Murray}
\begin{document}
\maketitle
\tableofcontents
\chapter{Introduction}
This document contains LaTeX code for creating graphical models commonly used in causal inference and comparative effectiveness research. There are four types of graphical models included in this document:
\begin{itemize}
\item Directed acyclic graphs (DAGs);
\item Single-world intervention graphs (SWIGs);
\item Probability trees for inverse probability weighting;
\item Decision trees for Markov models.
\end{itemize}
For more information, the most up-to-date code, and additional software for causal inference and data visualization, or to suggest improvements, please visit: \url{github.com/eleanormurray}
\vspace{3mm}
\section{Setting up your LaTeX style}
For the graphical models presented here, I use the tikzpicture package in LaTeX. To easily standardize the appearance of your graphical models, I recommend creating a custom arrow command. To do this, use the following commands.
\vspace{3mm}
\begin{Verbatim}[frame=single]
Install the package tikzpicture, with the following libraries:
\usepackage{tikz}
\usetikzlibrary{positioning, calc, shapes.geometric, shapes.multipart,
shapes, arrows.meta, arrows,
decorations.markings, external, trees}
Create custom arrow style:
\tikzstyle{Arrow} = [
thick,
decoration={
markings,
mark=at position 1 with {
\arrow[thick]{latex}
}
},
shorten >= 3pt, preaction = {decorate}
]
\end{Verbatim}
\tikzstyle{Arrow} = [
thick,
decoration={
markings,
mark=at position 1 with {
\arrow[thick]{latex}
}
},
shorten >= 3pt, preaction = {decorate}
]
\vspace{3mm}
Your arrows will look like this:
\begin{tikzpicture}[]
\node[] at (0,0) {};
\draw[Arrow](0,0)--(2,0);
\end{tikzpicture}
\vspace{3mm}
Define the following variables for use throughout this document:
\begin{itemize}
\item Treatments, exposures, interventions, or independent variables for which the causal effect is of interest represented with A
\item Outcomes or dependent variables of interest with Y
\item Known covariates or confounders with L
\item Unknown covariates or confounders with U
\item Censoring, selection, loss to follow-up, or dropout with C
\item When multiple time points are of interest, they are indexed with a subscript
\item When counterfactual variables are of interest, they are indexed with a superscript
\end{itemize}
\vspace{5mm}
\chapter{Directed acyclic graphs (DAGs) }
Directed acyclic graphs (DAGs) are tools for evaluating hypothesized relationships between variables in terms of their potential to cause bias in a given study or analysis. They are useful tools for designing a study or analysis, for assessing potential causes of unexpected results, or for teaching causal inference.
\vspace{3mm}
There are two main types of DAGs that are commonly used in causal inference:
\begin{itemize}
\item Statistical DAGs contain measured or known variables only;
\item Causal DAGs contain all variables of interest plus all common parents of two or more variables of interest even if the identity of these variables is unknown.
\end{itemize}
\vspace{3mm}
DAGs typically also indicate the flow of time through a temporal ordering from either left (past) to right (future or present) or top (past) to bottom (future or present). The DAGs here use a left to right temporal ordering. These DAGs are also drawn under the null, meaning that they represent the null hypothesis that A has no causal effect on Y.
\vspace{3mm}
\section{Statistical DAGs}
Statistical DAGs encode beliefs about associations between known variables. In statistical DAGs arrows imply potential associations which may or may not be causal. Any variables not connected by arrows in the statistical DAG are known or assumed not to be associated.
Statistical DAGs can be built from datasets using machine learning or other statistical techniques, but should not be used to determine whether two variables are causally related.
\subsection{Statistical DAG for point exposures}
The two DAGs below represent the simplest possible statistical DAGs, with only two variables, an exposure or treatment variable, $A$, and an outcome or dependent variable, $Y$. The first DAG represents the assumption that the null hypothesis of no association between the exposure and the outcome is true (i.e. $E[Y|A=a]=E[Y|A=a']$). The second DAG does not make this assumption -- this DAG includes an arrow between $A$ and $Y$ and therefore allows the possibility of an association between exposure and outcome but does not require that this association exists.
\vspace{3mm}
\begin{framed}
\verb|DAG 1 - null hypothesis:|
\begin{tikzpicture}
\node (1) {A};
\node [right =of 1] (2) {Y};
\end{tikzpicture}
\begin{Verbatim}
Code for DAG 1:
\begin{tikzpicture}
\node (1) {A};
\node [right =of 1] (2) {Y};
\end{tikzpicture}
\end{Verbatim}
\verb|DAG 2 - no hypothesis:|
\begin{tikzpicture}
\node (1) {A};
\node [right =of 1] (2) {Y};
\draw[Arrow] (1.east) -- (2.west);
\end{tikzpicture}
\begin{Verbatim}
Code for DAG 2:
\begin{tikzpicture}
\node (1) {A};
\node [right =of 1] (2) {Y};
\draw[Arrow] (1.east) -- (2.west);
\end{tikzpicture}
\end{Verbatim}
\end{framed}
\vspace{3pt}
\subsubsection{Statistical DAG with confounding}
In the next DAG, we have added a known confounder, $L$ -- that is, a variable which is associated with the exposure, and with the outcome, and occurs before both in time, and which could therefore be an explanation for any spurious (non-causal) association which is detected between exposure and outcome. $L$ could also represent a set of confounding variables with similar relationships to $A$ and $Y$. The DAG below is drawn under the assumption that the null hypothesis is true.
\vspace{3mm}
\begin{framed}
\verb|DAG:|
\begin{tikzpicture}
\node (2) {L};
\node [right =of 2] (3) {A};
\node [right =of 3] (4) {Y};
\draw[Arrow] (2.east) -- (3.west);
\draw[Arrow] (2) to [out=25, in=160] (4);
\end{tikzpicture}
\begin{Verbatim}
Code:
\begin{tikzpicture}
\node (1) {L};
\node [right =of 1] (2) {A};
\node [right =of 2] (3) {Y};
\draw[Arrow] (1.east) -- (2.west);
\draw[Arrow] (1) to [out=25, in=160] (3);
\end{tikzpicture}
\end{Verbatim}
\end{framed}
\vspace{5mm}
\subsubsection{Conditioning or restricting on a confounder}
In this DAG, there is a box around $L$ to indicate that the variable, $L$, has been restricted to a certain set of values, or has been adjusted for statistically in the analysis. The DAG below is drawn under the assumption that the null hypothesis is true. The only difference in the code is that we have drawn a rectangle around the first node. However, the DAG now encodes the assumption that the exposure and outcome will not be associated in any analysis that conditions or restricts on $L$.
\vspace{3mm}
\begin{framed}
\verb|DAG:|
\begin{tikzpicture}
\node [rectangle, draw] (1) {L};
\node [right =of 1] (2) {A};
\node [right =of 2] (3) {Y};
\draw[Arrow, thick] (1.east) -- (2.west);
\draw[Arrow, thick] (1) to [out=25, in=160] (3);
\end{tikzpicture}
\begin{Verbatim}
Code:
\begin{tikzpicture}
\node [rectangle, draw] (1) {L};
\node [right =of 1] (2) {A};
\node [right =of 2] (3) {Y};
\draw[Arrow, thick] (1.east) -- (2.west);
\draw[Arrow, thick] (1) to [out=25, in=160] (3);
\end{tikzpicture}
\end{Verbatim}
\end{framed}
\vspace{3mm}
\subsubsection{Conditioning or restricting on a collider}
In this DAG, there is an additional variable, $C$, for censoring or loss to follow-up. Since we typically only have data on individuals who remain in our study, $C$ is equal to 0 (uncensored) for all individuals for whom we have data, and is therefore restricted on by definition. Thus, in any DAG with censoring, there should be a box around C to indicate this restriction.
Note, that when we are conditioning on a downstream consequence of exposure we create the possibility of collider bias. Therefore, it is likely that a statistical DAG created from data in which we condition or restrict on $C$ will detect an association between the exposure and outcome. This likelihood is represented in a statistical DAG by an arrow between $A$ and $Y$. If we omit this arrow from $A$ to $Y$, we are making an assumption of non-informative censoring. This is equivalent to assuming that any observations with missing outcome information are missing completely at random (MCAR). See the causal DAG section for a better way to represent this relationship.
The DAG below is drawn under the assumption that the null hypothesis is true.
\vspace{3mm}
\begin{framed}
\verb|DAG:|
\begin{tikzpicture}
\node (1) {A};
\node [rectangle, draw, right =of 1] (2) {C};
\node [right =of 2] (3) {Y};
\draw[Arrow, thick] (1) to [out=25, in=160] (3);
\draw[Arrow, thick] (1.east) -- (2.west);
\end{tikzpicture}
\begin{Verbatim}
Code:
\begin{tikzpicture}
\node (1) {A};
\node [rectangle, draw, right =of 1] (2) {C};
\node [right =of 2] (3) {Y};
\draw[Arrow, thick] (1) to [out=25, in=160] (3);
\draw[Arrow, thick] (1.east) -- (2.west);
\end{tikzpicture}
\end{Verbatim}
\end{framed}
\vspace{3mm}
\subsection{Statistical DAG for sustained exposures}
When the data are longitudinal and available at multiple time points, DAGs must have separate nodes for each variable at each time in order to remain acyclical and avoid loops. The time points can be indicated using subscripts.
Here, there is a time-varying confounder, $L$, which is also affected by prior treatment. If the analysis does not adjust for $L$ at all time points, there will be bias due to confounding. However, if the analysis adjusts for $L$ at all time points through simple stratification-based regression analyses, there could be bias due to conditioning on a collider at $L_k$.
The DAG below is a complete DAG, under the assumption that the null hypothesis is true, meaning that all possible arrows are present except those directly from each treatment, $A$, to the outcome, $Y$. However, if there are any common causes of the confounder $L_k$ and the outcome, then any attempt to create this statistical DAG from data alone will result in observed associations between $A$ and $Y$ at all time points. See the causal DAGs section for more information.
For simplicity, in the DAG below Y$_k$ is omitted and Y$_{k+1}$ can be considered an indicator for the cumulative probability (incidence) of the outcome by the end of follow-up.
\vspace{3mm}
\begin{framed}
\verb|DAG: |
\begin{tikzpicture}
\node (1) {L$_{k-1}$};
\node [right =of 1] (2) {A$_{k-1}$};
\node [right =of 2] (3) {L$_{k}$};
\node [right =of 3] (4) {A$_{k}$};
\node [right =of 4] (5) {Y$_{k+1}$};
\draw[Arrow, thick] (1.east) -- (2.west);
\draw[Arrow, thick] (1) to [out=25, in=160] (3);
\draw[Arrow, thick] (1) to [out=25, in=160] (4);
\draw[Arrow, thick] (1) to [out=25, in=160] (5);
\draw[Arrow, thick] (2.east) -- (3.west);
\draw[Arrow, thick] (2) to [out=25, in=160] (4);
\draw[Arrow, thick] (3.east) -- (4.west);
\draw[Arrow, thick] (3) to [out=25, in=160] (5);
\end{tikzpicture}
\begin{Verbatim}
Code:
\begin{tikzpicture}
\node (1) {L$_{k-1}$};
\node [right =of 1] (2) {A$_{k-1}$};
\node [right =of 2] (3) {L$_{k}$};
\node [right =of 3] (4) {A$_{k}$};
\node [right =of 4] (5) {Y$_{k+1}$};
\draw[Arrow, thick] (1.east) -- (2.west);
\draw[Arrow, thick] (1) to [out=25, in=160] (3);
\draw[Arrow, thick] (1) to [out=25, in=160] (4);
\draw[Arrow, thick] (1) to [out=25, in=160] (5);
\draw[Arrow, thick] (2.east) -- (3.west);
\draw[Arrow, thick] (2) to [out=25, in=160] (4);
\draw[Arrow, thick] (3.east) -- (4.west);
\draw[Arrow, thick] (3) to [out=25, in=160] (5);
\end{tikzpicture}
\end{Verbatim}
\end{framed}
\newpage
\section{Causal DAGs}
Causal DAGs encode beliefs about causal relationships between variables of interest. In causal DAGs, arrows between variables imply potential causal relationships. Any variables not connected by arrows in the causal DAG are known or assumed to lack of causal relationship. When two variables are known to be associated but not believed to be causally related, this is represented by the inclusion of an unknown variable, $U$.
\subsection{Causal DAG for point exposures}
The two DAGs below represent the simplest possible causal DAGs, with only two known variables, an exposure or treatment variable, $A$, and an outcome or dependent variable, $Y$. Unlike the statistical DAG, the first causal DAG does not represent the assumption that the null hypothesis of no association between the exposure and the outcome is true (i.e. $E[Y|A=a]=E[Y|A=a']$), since an association could be observed due to confounding by $U$. Instead, the first causal DAG represents the (stronger) assumption that the null hypothesis of no causal relationship between the exposure and the outcome is true (i.e. $E[Y^{a}|A=a]=E[Y^{a'}|A=a']$).
The second DAG does not make either of these assumptions -- this DAG includes an arrow between $A$ and $Y$, and an unknown common cause $U$, and therefore allows the possibility of a causal relationship or a non-causal association between exposure and outcome but does not require that either of these exists.
\vspace{3mm}
\begin{framed}
\verb|DAG 1 - null hypothesis:|
\begin{tikzpicture}
\node (1) {A};
\node [right =of 1] (2) {Y};
\node [left =of 1] (3) {U};
\draw[Arrow] (3.east) -- (1.west);
\draw[Arrow] (3) to [out=25, in=160] (2);
\end{tikzpicture}
\begin{Verbatim}
Code for DAG 1:
\begin{tikzpicture}
\node (1) {A};
\node [right =of 1] (2) {Y};
\node [left =of 1] (3) {U};
\draw[Arrow] (3.east) -- (1.west);
\draw[Arrow] (3) to [out=25, in=160] (2);
\end{tikzpicture}
\end{Verbatim}
\verb|DAG 2 - no hypothesis:|
\begin{tikzpicture}
\node (1) {A};
\node [right =of 1] (2) {Y};
\node [left =of 1] (3) {U};
\draw[Arrow] (1.east) -- (2.west);
\draw[Arrow] (3.east) -- (1.west);
\draw[Arrow] (3) to [out=25, in=160] (2);
\end{tikzpicture}
\begin{Verbatim}
Code for DAG 2:
\begin{tikzpicture}
\node (1) {A};
\node [right =of 1] (2) {Y};
\node [left =of 1] (3) {U};
\draw[Arrow] (1.east) -- (2.west);
\draw[Arrow] (3.east) -- (1.west);
\draw[Arrow] (3) to [out=25, in=160] (2);
\end{tikzpicture}
\end{Verbatim}
\end{framed}
\vspace{3pt}
\subsubsection{Causal DAG with confounding}
Any causal DAG must include all possible common causes of any two variables on the DAG. In the simplest case, where all confounders are known, the statistical DAG for confounding will be the same as the causal DAG for confounding. In more complex cases, the causal DAG for confounding can include additional unknown common causes of $A$ and $Y$, of $L$ and $A$, and / or of $L$ and $Y$.
\vspace{3mm}
\begin{framed}
\verb|DAG:|
\begin{tikzpicture}
\node (2) {L};
\node [right =of 2] (3) {A};
\node [right =of 3] (4) {Y};
\node [left =of 2] (5) {U$_1$};
\node [below =of 5] (6) {U$_2$};
\node [below =of 2] (7) {U$_3$};
\draw[Arrow] (2.east) -- (3.west);
\draw[Arrow] (2) to [out=25, in=160] (4);
\draw[Arrow] (5.east) -- (2.west);
\draw[Arrow] (5) to [out=25, in=160] (4);
\draw[Arrow] (6.north) -- (2.south);
\draw[Arrow] (6.north) -- (3.south);
\draw[Arrow] (7.north) -- (3.south);
\draw[Arrow] (7.north) -- (4.south);
\end{tikzpicture}
\begin{Verbatim}
Code:
\begin{tikzpicture}
\node (1) {L};
\node [right =of 1] (2) {A};
\node [right =of 2] (3) {Y};
\node [left =of 2] (5) {U$_1$};
\node [below =of 5] (6) {U$_2$};
\node [below =of 2] (7) {U$_3$};
\draw[Arrow] (2.east) -- (3.west);
\draw[Arrow] (2) to [out=25, in=160] (4);
\draw[Arrow] (5.east) -- (2.west);
\draw[Arrow] (5) to [out=25, in=160] (4);
\draw[Arrow] (6.north) -- (2.south);
\draw[Arrow] (6.north) -- (3.south);
\draw[Arrow] (7.north) -- (3.south);
\draw[Arrow] (7.north) -- (4.south);
\end{tikzpicture}
\end{Verbatim}
\end{framed}
\vspace{3mm}
\subsubsection{Causal DAG, conditioning or restricting on a collider}
As in the statistical DAG with a collider, the causal DAG has an additional variable, $C$, for censoring or loss to follow-up. Since we typically only have data on individuals who remain in our study, $C$ is equal to 0 (uncensored) for all individuals for whom we have data, and is therefore restricted on by definition. Thus, in any DAG with censoring, there should be a box around $C$ to indicate this restriction.
Unlike the statistical DAG, the causal DAG also includes an unknown common cause of $C$ and $Y$. It is likely that most studies with censoring or loss to follow-up have some known or unknown common causes of censoring and the outcome. Omitting $U$ (or some other, known, common cause) from the causal DAG makes the assumption of non-informative censoring or that the outcome information is missing completely at random (MCAR). By including $U$, we relax this (strong) assumption, and instead allow censoring to be informative. If we can identify, and measure, $U$ then we can adjust for the censoring process and are now only assuming that the outcome is missing at random (MAR), or that censoring is conditionally non-informative.
Note that since $C$ is a common effect of $A$ and of $U$, C is a collider. As such, a data analysis that does not account for U will result in an artificial (non-causal) association between A and Y through the path A$\rightarrow$C$\leftarrow$U$\rightarrow$L which is opened by restriction on the collider, C. Using a causal DAG allows us to easily see the potential for collider bias when conditioning or restricting on a post-exposure variable.
\vspace{3mm}
\begin{framed}
\verb|DAG:|
\begin{tikzpicture}
\node (1) {A};
\node [rectangle, draw, right =of 1] (2) {C};
\node [right =of 2] (3) {Y};
\node [below =of 1] (4) {U};
\draw[Arrow, thick] (1.east) -- (2.west);
\draw[Arrow, thick] (4.east) -- (2.west);
\draw[Arrow, thick] (4.east) -- (3.west);
\end{tikzpicture}
\begin{Verbatim}
Code:
\begin{tikzpicture}
\node (1) {A};
\node [rectangle, draw, right =of 1] (2) {C};
\node [right =of 2] (3) {Y};
\node [below =of 1] (4) {U};
\draw[Arrow, thick] (1.east) -- (2.west);
\draw[Arrow, thick] (4.east) -- (2.west);
\draw[Arrow, thick] (4.east) -- (3.west);
\end{tikzpicture}
\end{Verbatim}
\end{framed}
\vspace{3mm}
\subsection{Causal DAG for sustained exposures}
When the data are longitudinal and available at multiple time points, DAGs must have separate nodes for each variable at each time in order to remain acyclical and avoid loops. The time points can be indicated using subscripts.
Here, there is a time-varying confounder, $L$, which is also affected by prior treatment. If the analysis does not adjust for $L$ at all time points, there will be bias due to confounding. However, if the analysis adjusts for $L$ at all time points through simple stratification-based regression analyses, there could be bias due to conditioning on a collider at $L_k$.
In the causal DAG, we represent this potential for bias by including one or more common causes of $L$ and $Y$. Here, we make the simplest assumption that a single, baseline, cause (or set of causes) affects $L$ and $Y$ at all time points.
The DAG below is a complete DAG, under the assumption that the null hypothesis is true, meaning that all possible arrows are present except those directly from each treatment, $A$, to the outcome, $Y$.
For simplicity, in the DAG below Y$_k$ is omitted and Y$_{k+1}$ can be considered an indicator for the cumulative probability (incidence) of the outcome by the end of follow-up.
\newpage
\begin{framed}
\verb|DAG: |
\begin{tikzpicture}
\node (1) {L$_{k-1}$};
\node [right =of 1] (2) {A$_{k-1}$};
\node [right =of 2] (3) {L$_{k}$};
\node [right =of 3] (4) {A$_{k}$};
\node [right =of 4] (5) {Y$_{k+1}$};
\node [below =of 1] (6) {U};
\draw[Arrow, thick] (1.east) -- (2.west);
\draw[Arrow, thick] (1) to [out=25, in=160] (3);
\draw[Arrow, thick] (1) to [out=25, in=160] (4);
\draw[Arrow, thick] (1) to [out=25, in=160] (5);
\draw[Arrow, thick] (2.east) -- (3.west);
\draw[Arrow, thick] (2) to [out=25, in=160] (4);
\draw[Arrow, thick] (3.east) -- (4.west);
\draw[Arrow, thick] (3) to [out=25, in=160] (5);
\draw[Arrow, thick] (6.north) -- (1.south);
\draw[Arrow, thick] (6.east) -- (3.south);
\draw[Arrow, thick] (6.east) -- (5.south);
\end{tikzpicture}
\begin{Verbatim}
Code:
\begin{tikzpicture}
\node (1) {L$_{k-1}$};
\node [right =of 1] (2) {A$_{k-1}$};
\node [right =of 2] (3) {L$_{k}$};
\node [right =of 3] (4) {A$_{k}$};
\node [right =of 4] (5) {Y$_{k+1}$};
\node [below =of 1] (6) {U};
\draw[Arrow, thick] (1.east) -- (2.west);
\draw[Arrow, thick] (1) to [out=25, in=160] (3);
\draw[Arrow, thick] (1) to [out=25, in=160] (4);
\draw[Arrow, thick] (1) to [out=25, in=160] (5);
\draw[Arrow, thick] (2.east) -- (3.west);
\draw[Arrow, thick] (2) to [out=25, in=160] (4);
\draw[Arrow, thick] (3.east) -- (4.west);
\draw[Arrow, thick] (3) to [out=25, in=160] (5);
\draw[Arrow, thick] (6.north) -- (1.south);
\draw[Arrow, thick] (6.east) -- (3.south);
\draw[Arrow, thick] (6.east) -- (5.south);
\end{tikzpicture}
\end{Verbatim}
\end{framed}
\newpage
\section{Annotating DAG arrows}
When using DAGs for teaching biases such as confounding, it may sometimes be helpful to annotate the arrows to indicate the direction of bias as either positive or negative. The code adds labels or annotations to DAG arrows by placing a new text node above or below the midpoint of each arrow.
In the example below, the confounder $L$ is negatively associated with the outcome $Y$ and positively associated with the exposure $A$, leading to an expected negative (or downward) bias in the estimated association between $A$ and $Y$ if $L$ is not controlled for in the analysis.
\vspace{3mm}
\begin{framed}
\verb|DAG:|
\begin{tikzpicture}
\node (2) {L};
\node [right =of 2] (3) {A};
\node [right =of 3] (4) {Y};
\draw[Arrow] (2.east) -- (3.west) node[midway, below]{$+$};
\draw[Arrow] (2) to [out=25, in=160] node[midway, above] {$-$} (4);
\draw[Arrow] (3.east) --(4.west) node[midway, below] {$-$};
\end{tikzpicture}
\begin{Verbatim}
Code:
\begin{tikzpicture}
\node (1) {L};
\node [right =of 1] (2) {A};
\node [right =of 2] (3) {Y};
\draw[Arrow] (2.east) -- (3.west) node[midway, below]{$+$};
\draw[Arrow] (2) to [out=25, in=160] node[midway, above]{$-$} (4) ;
\draw[Arrow] (3.east) --(4.west) node[midway, below] {$-$};
\end{tikzpicture}
\end{Verbatim}
\end{framed}
\vspace{3mm}
\newpage
\chapter{Single-world intervention graphs (SWIGs)}
Single-world intervention graphs (SWIGs) are similar to DAGs in that they have the same key properties of being directed and acyclic. In addition, SWIGs explicitly include the intervention or experimental condition of interest and the counterfactual outcome of interest, allowing direct visual assessment of the causal inference assumption of exchangeability or conditional exchangeability.
The intervention or experimental condition of interest is indicated by the use of split nodes. These nodes are split in two by a $|$ symbol. The left-hand side of the split node (typically denoted with an upper case letter) indicates the observed value of intervention or experimental variable. The right-hand side of the split node (typically denoted with a lower case letter) indicates the investigator-determined intervention or experimental variable.
Counterfactual nodes are denoted by a superscript. For example, counterfactual outcomes or dependent variables of interest may be denoted Y$^a$, and known covariates or confounders which are affected by prior interventions may be denoted L$^a$ and are now also counterfactuals.
Note that to demonstrate the change in arrows related to the intervention in a SWIG, all SWIGs below are not drawn under the assumption that the null hypothesis is true -- that is, the SWIGs include arrows from the intervention nodes directly to the outcome. This is not a required feature.
We can draw two general types of SWIGs:
\begin{itemize}
\item Intervention-specific SWIGs, and
\item Template SWIGs
\end{itemize}
For teaching purposes, we will first work through intervention-specific SWIGs but then we will describe the general template. SWIG templates are more often used, since they allow assessment of a range of interventions.
\newpage
\section{Intervention-specific SWIGs}
Intervention-specific SWIGs specify the exact value which we are interested in for a specific research question. This could be the intervention that we will assign to individuals in one arm of a randomized trial, or it could be one of the hypothetical interventions we are interested in emulating using observational data to emulate a hypothetical target trial.
\subsection{Intervention-specific SWIG for interventions on point exposures}
The intervention-specific SWIG for an intervention on a point exposure looks similar to the DAG for point exposures, except that the intervention variable, A, is now split into two nodes - an observed node, and an intervention node. In the intervention-specific SWIG below, we are interested in the point intervention 'all individuals to take treatment (i.e. a=1)'.
In this SWIG, the intervention node is therefore set to 'a=1'. All downstream consequences of the intervention node are now counterfactual (unless we make assumptions), and are therefore labeled with superscripts which indicate the counterfactual intervention world in which they occur.
As noted above, the SWIG below is not drawn under the assumption that the null hypothesis is true.
\vspace{3mm}
\begin{framed}
\verb|SWIG: |
\begin{tikzpicture}
[
array/.style={rectangle split,
rectangle split parts = 3,
rectangle split horizontal,
minimum height = 2em
}
]
\node (1) {L};
\node [array, right =of 1] (2) {%
{A}
\nodepart{two}{$|$}
\nodepart{three}{a=1}
};
\node [right =of 2] (3) {Y$^{a=1}$};
\draw[Arrow, thick] (1.east) -- (2.west);
\draw[Arrow, thick] (2.two east) -- (3.west);
\draw[Arrow, thick] (1) to [out=25, in=160] (3);
\end{tikzpicture}
\begin{Verbatim}
Code:
\begin{tikzpicture}
[
array/.style={rectangle split,
rectangle split parts = 3,
rectangle split horizontal,
minimum height = 2em
}
]
\node (1) {L};
\node [array, right =of 1] (2) {%
{A}
\nodepart{two}{$|$}
\nodepart{three}{a=1}
};
\node [right =of 2] (3) {Y$^{a=1}$};
\draw[Arrow, thick] (1.east) -- (2.west);
\draw[Arrow, thick] (2.two east) -- (3.west);
\draw[Arrow, thick] (1) to [out=25, in=160] (3);
\end{tikzpicture}
\end{Verbatim}
\end{framed}
\vspace{3mm}
\subsection{Intervention-specific SWIG for static interventions on sustained exposures}
The intervention-specific SWIG for a sustained intervention looks similar to the DAG for sustained exposures, except for the SWIG-specific features. However, in the SWIG we can now represent two different types of interventions on sustained exposures: static interventions, and dynamic interventions. Static interventions are interventions which are determined from baseline and are either identical for every individual or dependent only on baseline or pre-baseline characteristics. Dynamic interventions are interventions which are not fully known until the end of follow-up; these interventions depend on characteristics which change over time.
In the intervention-specific SWIG below, we are interested in the point intervention 'all individuals to take treatment at all time points (i.e. $a_k$=1)'. In this SWIG the intervention node is therefore set to 'a=1' at every time point.
All downstream consequences of the intervention node are now counterfactual (unless we make assumptions), and are therefore labeled with superscripts which indicate the counterfactual intervention world in which they occur. Now, these nodes are labeled with all prior interventions, so that variables which are downstream of multiple intervention nodes will have multiple counterfactual superscripts. Note that the $L_1$ node is not split because this is a time-varying covariate and not an intervention variable.
\vspace{3mm}
\begin{framed}
\Verb|SWIG: |
\begin{tikzpicture}[
array/.style={rectangle split,
rectangle split parts = 3,
rectangle split horizontal,
minimum height = 2em
}
]
\node (1) {L$_0$};
\node [array, right =of 1] (2) {%
{A$_0$}
\nodepart{two}{$|$}
\nodepart{three}{a$_0 =1$}
};
\node [right =of 2] (3) {L$_1^{a_{0}=1}$};
\node [array, right =of 3] (4) {%
{A$_1^{a_{0}=1}$}
\nodepart{two}{$|$}
\nodepart{three}{a$_1 =1$}
};
\node [right =of 4] (5) {Y$_{k+1}^{a_0 =1, a_1 =1}$};
\draw[Arrow, thick] (1.east) -- (2.west);
\draw[Arrow, thick] (1) to [out=25, in=160] (3);
\draw[Arrow, thick] (1) to [out=25, in=160] (4);
\draw[Arrow, thick] (1) to [out=25, in=160] (5);
\draw[Arrow, thick] (2.east) -- (3.west);
\draw[Arrow, thick] (2) to [out=25, in=160] (4);
\draw[Arrow, thick] (2) to [out=25, in=160] (5);
\draw[Arrow, thick] (3.east) -- (4.west);
\draw[Arrow, thick] (3) to [out=25, in=160] (5);
\draw[Arrow, thick] (4.east) -- (5.west);
\end{tikzpicture}
\begin{Verbatim}
Code:
\begin{tikzpicture}[
array/.style={rectangle split,
rectangle split parts = 3,
rectangle split horizontal,
minimum height = 2em
}
]
\node (1) {L$_0$};
\node [array, right =of 1] (2) {%
{A$_0$}
\nodepart{two}{$|$}
\nodepart{three}{a$_0 =1$}
};
\node [right =of 2] (3) {L$_1^{a_{0}=1}$};
\node [array, right =of 3] (4) {%
{A$_1^{a_{0}=1}$}
\nodepart{two}{$|$}
\nodepart{three}{a$_1 =1$}
};
\node [right =of 4] (5) {Y$_{k+1}^{a_0 =1, a_1 =1}$};
\draw[Arrow, thick] (1.east) -- (2.west);
\draw[Arrow, thick] (1) to [out=25, in=160] (3);
\draw[Arrow, thick] (1) to [out=25, in=160] (4);
\draw[Arrow, thick] (1) to [out=25, in=160] (5);
\draw[Arrow, thick] (2.east) -- (3.west);
\draw[Arrow, thick] (2) to [out=25, in=160] (4);
\draw[Arrow, thick] (2) to [out=25, in=160] (5);
\draw[Arrow, thick] (3.east) -- (4.west);
\draw[Arrow, thick] (3) to [out=25, in=160] (5);
\draw[Arrow, thick] (4.east) -- (5.west);
\end{tikzpicture}
\end{Verbatim}
\end{framed}
\vspace{3mm}
\subsection{Intervention-specific SWIG for dynamic interventions on sustained exposures}
Intervention-specific SWIGs for dynamic interventions allow the intervention value to depend on time-varying characteristics of the individual. Here, we are interested in the dynamic intervention 'all individuals to take treatment at baseline, and continue treatment only while the time-varying covariate $L$=1'. This means that we treat everyone at baseline, and then continue to treat only those individuals whose the time-varying covariate indicates that treatment remains appropriate. In the example below, this is indicated by $L$=1.
We indicate that the specific treatment received by an individual during follow-up depends on $L$ by assigning the intervention value $a_1 = L$. This shorthand allows us to see that treatment is given at time $t=1$ (i.e. $a_1$=1) only when the time-varying covariate indicates this is appropriate (i.e. $L_1$ =1), and that treatment is withheld (i.e. $a_1$=0) when the time-varying covariate indicates treatment is no longer appropriate (i.e. $L_1$ =0).
We indicate the association between the variable which guides the intervention value and the intervention node with a dotted line since this arrow may or may not exist in the real world (outside our interventions on $A$), but must exist in the world of our intervention-specific SWIG.
\vspace{3mm}
\begin{framed}
\Verb|SWIG: |
\begin{tikzpicture}[
array/.style={rectangle split,
rectangle split parts = 3,
rectangle split horizontal,
minimum height = 2em
}
]
\node (1) {L$_0$};
\node [array, right =of 1] (2) {%
{A$_0$}
\nodepart{two}{$|$}
\nodepart{three}{a$_0 =1$}
};
\node [right =of 2] (3) {L$_1^{a_{0}=1}$};
\node [array, right =of 3] (4) {%
{A$_1^{a_{0}=1}$}
\nodepart{two}{$|$}
\nodepart{three}{a$_1 = L$}
};
\node [right =of 4] (5) {Y$_{k+1}^{a_0 =1, a_1 = L}$};
\draw[Arrow, thick] (1.east) -- (2.west);
\draw[Arrow, thick] (1) to [out=25, in=160] (3);
\draw[Arrow, thick] (1) to [out=25, in=160] (4);
\draw[Arrow, thick] (1) to [out=25, in=160] (5);
\draw[Arrow, thick] (2.east) -- (3.west);
\draw[Arrow, thick] (2) to [out=25, in=160] (4);
\draw[Arrow, thick] (2) to [out=25, in=160] (5);
\draw[Arrow, thick] (3.east) -- (4.west);
\draw[Arrow, dashed] (3) to [out=-25, in =-160] (4.three south);
\draw[Arrow, thick] (3) to [out=25, in=160] (5);
\draw[Arrow, thick] (4.east) -- (5.west);
\end{tikzpicture}
\begin{Verbatim}
Code:
\begin{tikzpicture}[
array/.style={rectangle split,
rectangle split parts = 3,
rectangle split horizontal,
minimum height = 2em
}
]
\node (1) {L$_0$};
\node [array, right =of 1] (2) {%
{A$_0$}
\nodepart{two}{$|$}
\nodepart{three}{a$_0 =1$}
};
\node [right =of 2] (3) {L$_1^{a_{0}=1}$};
\node [array, right =of 3] (4) {%
{A$_1^{a_{0}=1}$}
\nodepart{two}{$|$}
\nodepart{three}{a$_1 = L$}
};
\node [right =of 4] (5) {Y$_{k+1}^{a_0 =1, a_1 = L}$};
\draw[Arrow, thick] (1.east) -- (2.west);
\draw[Arrow, thick] (1) to [out=25, in=160] (3);
\draw[Arrow, thick] (1) to [out=25, in=160] (4);
\draw[Arrow, thick] (1) to [out=25, in=160] (5);
\draw[Arrow, thick] (2.east) -- (3.west);
\draw[Arrow, thick] (2) to [out=25, in=160] (4);
\draw[Arrow, thick] (2) to [out=25, in=160] (5);
\draw[Arrow, thick] (3.east) -- (4.west);
\draw[Arrow, dashed] (3) to [out=-25, in =-160] (4.three south);
\draw[Arrow, thick] (3) to [out=25, in=160] (5);
\draw[Arrow, thick] (4.east) -- (5.west);
\end{tikzpicture}
\end{Verbatim}
\end{framed}
\vspace{3mm}
\section{SWIG templates}
Template SWIGs denote all possible intervention values through the use of a random intervention variable. To create a SWIG template, we construct the same SWIGs as above but no longer label the intervention node nor the counterfactual with a specific intervention value.
Note that, in general, SWIG templates should not be used for assessing potential collider bias or whether a lack identifiability resulting from cross-world problems, since SWIG templates no longer represent only one single world.
\subsection{SWIG template for interventions on point exposures}
The SWIG template for interventions on point exposures represents all possible interventions on the variable of interest. This means that the intervention node is no longer labeled with a specific value as above. Instead, we label with a generic intervention $a$.
As above, this and all SWIG templates below do not make the assumption that the null hypothesis is true, but SWIG templates can be drawn under this assumption if preferred.
\vspace{3mm}
\begin{framed}
\Verb|SWIG: |
\begin{tikzpicture}
[
array/.style={rectangle split,
rectangle split parts = 3,
rectangle split horizontal,
minimum height = 2em
}
]
\node (1) {L};
\node [array, right =of 1] (2) {%
{A}
\nodepart{two}{$|$}
\nodepart{three}{a}
};
\node [right =of 2] (3) {Y$^{a}$};
\draw[Arrow, thick] (1.east) -- (2.west);
\draw[Arrow, thick] (2.two east) -- (3.west);
\draw[Arrow, thick] (1) to [out=25, in=160] (3);
\end{tikzpicture}
\begin{Verbatim}
Code:
\begin{tikzpicture}
[
array/.style={rectangle split,
rectangle split parts = 3,
rectangle split horizontal,
minimum height = 2em
}
]
\node (1) {L};
\node [array, right =of 1] (2) {%
{A}
\nodepart{two}{$|$}
\nodepart{three}{a}
};
\node [right =of 2] (3) {Y$^{a}$};
\draw[Arrow, thick] (1.east) -- (2.west);
\draw[Arrow, thick] (2.two east) -- (3.west);
\draw[Arrow, thick] (1) to [out=25, in=160] (3);
\end{tikzpicture}
\end{Verbatim}
\end{framed}
\vspace{3mm}
\subsection{SWIG template for static interventions on sustained exposures}
The SWIG template for all possible static interventions on sustained exposures operates the same way as the point intervention template. Static interventions are any intervention that does not depend on characteristics of the individual which can change over time. Therefore, the sequence of intervention values is fixed at baseline for every individual.
\vspace{3mm}
\begin{framed}
\Verb|SWIG: |
\begin{tikzpicture}[
array/.style={rectangle split,
rectangle split parts = 3,
rectangle split horizontal,
minimum height = 2em
}
]
\node (1) {L$_0$};
\node [array, right =of 1] (2) {%
{A$_0$}
\nodepart{two}{$|$}
\nodepart{three}{a$_0$}
};
\node [right =of 2] (3) {L$_1^{a_{0}}$};
\node [array, right =of 3] (4) {%
{A$_1^{a_{0}}$}
\nodepart{two}{$|$}
\nodepart{three}{a$_1$}
};
\node [right =of 4] (5) {Y$_{k+1}^{a_0, a_1}$};
\draw[Arrow, thick] (1.east) -- (2.west);
\draw[Arrow, thick] (1) to [out=25, in=160] (3);
\draw[Arrow, thick] (1) to [out=25, in=160] (4);
\draw[Arrow, thick] (1) to [out=25, in=160] (5);
\draw[Arrow, thick] (2.east) -- (3.west);
\draw[Arrow, thick] (2) to [out=25, in=160] (4);
\draw[Arrow, thick] (2) to [out=25, in=160] (5);
\draw[Arrow, thick] (3.east) -- (4.west);
\draw[Arrow, thick] (3) to [out=25, in=160] (5);
\draw[Arrow, thick] (4.east) -- (5.west);
\end{tikzpicture}
\begin{Verbatim}
Code:
\begin{tikzpicture}[
array/.style={rectangle split,
rectangle split parts = 3,
rectangle split horizontal,
minimum height = 2em
}
]
\node (1) {L$_0$};
\node [array, right =of 1] (2) {%
{A$_0$}
\nodepart{two}{$|$}
\nodepart{three}{a$_0$}
};
\node [right =of 2] (3) {L$_1^{a_{0}}$};
\node [array, right =of 3] (4) {%
{A$_1^{a_{0}}$}
\nodepart{two}{$|$}
\nodepart{three}{a$_1$}
};
\node [right =of 4] (5) {Y$_{k+1}^{a_0, a_1}$};
\draw[Arrow, thick] (1.east) -- (2.west);
\draw[Arrow, thick] (1) to [out=25, in=160] (3);
\draw[Arrow, thick] (1) to [out=25, in=160] (4);
\draw[Arrow, thick] (1) to [out=25, in=160] (5);
\draw[Arrow, thick] (2.east) -- (3.west);
\draw[Arrow, thick] (2) to [out=25, in=160] (4);
\draw[Arrow, thick] (2) to [out=25, in=160] (5);
\draw[Arrow, thick] (3.east) -- (4.west);
\draw[Arrow, thick] (3) to [out=25, in=160] (5);
\draw[Arrow, thick] (4.east) -- (5.west);
\end{tikzpicture}
\end{Verbatim}
\end{framed}
\vspace{3mm}
\subsection{SWIG template for dynamic interventions on sustained exposures}
The template SWIG for dynamic interventions on sustained exposures allows the intervention value to depend on time-varying characteristics of the individual, but does not specify that value. We indicate the association between the variable which guides the intervention value and the intervention node with a dotted line.
\vspace{3mm}
\begin{framed}
\Verb|SWIG: |
\begin{tikzpicture}[
array/.style={rectangle split,
rectangle split parts = 3,
rectangle split horizontal,
minimum height = 2em
}
]
\node (1) {L$_0$};
\node [right =of 1] (2) {A$_0 | $a$_0$};
\node [right =of 2] (3) {L$_1^{a_{0}}$};
\node [array, right =of 3] (4) {%
{A$_1^{a_{0}}$}
\nodepart{two}{$|$}
\nodepart{three}{a$_1$}
};
\node [right =of 4] (5) {Y$_{k+1}^{a_0, a_1}$};
\draw[Arrow, thick] (1.east) -- (2.west);
\draw[Arrow, thick] (1) to [out=25, in=160] (3);
\draw[Arrow, thick] (1) to [out=25, in=160] (4);
\draw[Arrow, thick] (1) to [out=25, in=160] (5);
\draw[Arrow, thick] (2.east) -- (3.west);
\draw[Arrow, thick] (2) to [out=25, in=160] (4);
\draw[Arrow, thick] (2) to [out=25, in=160] (5);
\draw[Arrow, thick] (3.east) -- (4.west);
\draw[Arrow, dashed] (3) to [out=-25, in =-160] (4.three south);
\draw[Arrow, thick] (3) to [out=25, in=160] (5);
\draw[Arrow, thick] (4.east) -- (5.west);
\end{tikzpicture}
\begin{Verbatim}
Code:
\begin{tikzpicture}[
array/.style={rectangle split,
rectangle split parts = 3,
rectangle split horizontal,
minimum height = 2em
}
]
\node (1) {L$_0$};
\node [right =of 1] (2) {A$_0 | $a$_0$};
\node [right =of 2] (3) {L$_1^{a_{0}}$};
\node [array, right =of 3] (4) {%
{A$_1^{a_{0}}$}
\nodepart{two}{$|$}
\nodepart{three}{a$_1$}
};
\node [right =of 4] (5) {Y$_{k+1}^{a_0, a_1}$};
\draw[Arrow, thick] (1.east) -- (2.west);
\draw[Arrow, thick] (1) to [out=25, in=160] (3);
\draw[Arrow, thick] (1) to [out=25, in=160] (4);
\draw[Arrow, thick] (1) to [out=25, in=160] (5);
\draw[Arrow, thick] (2.east) -- (3.west);
\draw[Arrow, thick] (2) to [out=25, in=160] (4);
\draw[Arrow, thick] (2) to [out=25, in=160] (5);
\draw[Arrow, thick] (3.east) -- (4.west);
\draw[Arrow, dashed] (3) to [out=-25, in =-160] (4.three south);
\draw[Arrow, thick] (3) to [out=25, in=160] (5);
\draw[Arrow, thick] (4.east) -- (5.west);
\end{tikzpicture}
\end{Verbatim}
\end{framed}
\newpage
\chapter{Probability trees for inverse probability weighting}
Probability trees can be useful teaching tools for explaining the use of inverse probability weighting for estimating causal effects. When drawing probability trees for inverse probability weighting we use the following conventions:
\begin{itemize}
\item Temporal ordering such that nodes to the left-most side of the tree represent the earliest occurring variables,
\item Circular nodes for covariates and outcome variables,
\item Tree branches within the circular covariate and outcome nodes to indicate the possible values of these variables, with labels to specify the conditional probability of each value given all prior tree branches,
\item Tree branches outside circular nodes to indicate intervention variables (treatment or exposure), labeled with the conditional probability of each intervention variable value given all prior tree branches and the number of individuals expected in each intervention branch,
\item Final tally of individuals in each tree leaf at the right-most side of the probability tree.
\end{itemize}
Using these conventions, the probability tree includes all required information for calculation of inverse probability of treatment weights for simple examples. When inverse probability of censoring weights are desired, branches for censoring can be added in a similar fashion to the intervention nodes.
\newpage
\section{Probability tree for point exposures}
The example below draws a tree for this scenario for a population of 1,000 individuals, where the intervention probability depends on the baseline confounder only.
\vspace{3mm}
\begin{framed}
Probability tree:
%Step 1: create styles for labeling nodes
\tikzstyle{observed} = [circle, thick, text centered, draw, minimum height=1in, minimum width=1in, text width=9em, text height = 16pt]
\tikzstyle{end_text} = [thick, text centered]
%Step 2: draw probability tree
\begin{tikzpicture}
\node[observed] at (0, 0) (1){};
\draw[black] (1.west) --node[midway, sloped, above]{L=1 (0.4)} (1.north east);
\draw[black] (1.west) --node[midway, sloped, above]{L=0 (0.6)} (1.south east);
\node[observed] at (10, 6) (2){};
\node[observed] at (10, 2) (3){};
\node[observed] at (10,-2) (4){};
\node[observed] at (10,-6) (5){};
\draw[black] (1.north east) -- node[midway, sloped, above]{A=0 (0.1)}
node[midway, sloped, below]{40} (2.west);
\draw[black] (2.west) --node[midway, sloped, above]{Y=0 (0.75)} (2.north east);
\draw[black] (2.west) --node[midway, sloped, above]{Y=1 (0.25)} (2.south east);
\node[end_text] at (12, 7) {30};
\node[end_text] at (12, 5) {10};
\draw[black] (1.north east) -- node[midway, sloped, above]{A=1 (0.9)}
node[midway, sloped, below]{360} (3.west);
\draw[black] (3.west) --node[midway, sloped, above]{Y=0 (0.67)} (3.north east);
\draw[black] (3.west) --node[midway, sloped, above]{Y=1 (0.33)} (3.south east);
\node[end_text] at (12, 3) {240};
\node[end_text] at (12, 1) {120};
\draw[black] (1.south east) -- node[midway, sloped, above]{A=0 (0.5)}
node[midway, sloped, below]{300} (4.west);
\draw[black] (4.west) --node[midway, sloped, above]{Y=0 (0.9)} (4.north east);
\draw[black] (4.west) --node[midway, sloped, above]{Y=1 (0.1)} (4.south east);
\node[end_text] at (12, -1) {270};
\node[end_text] at (12, -3) {30};
\draw[black] (1.south east) -- node[midway, sloped, above]{A=1 (0.5)}
node[midway, sloped, below]{300} (5.west);
\draw[black] (5.west) --node[midway, sloped, above]
{Y=0 $(\frac{1}{3})$} (5.north east);
\draw[black] (5.west) --node[midway, sloped, above]
{Y=1 $(\frac{2}{3})$} (5.south east);
\node[end_text] at (12, -5) {100};
\node[end_text] at (12, -7) {200};
\end{tikzpicture}
\begin{Verbatim}
Code:
%Step 1: create styles for labeling nodes
\tikzstyle{observed} = [circle, thick, text centered, draw, minimum height=1in,
minimum width=1in, text width=9em, text height = 16pt]
\tikzstyle{end_text} = [thick, text centered]
%Step 2: draw probability tree
\begin{tikzpicture}
\node[observed] at (0, 0) (1){};
\draw[black] (1.west) --node[midway, sloped, above]{L=1 (0.4)} (1.north east);
\draw[black] (1.west) --node[midway, sloped, above]{L=0 (0.6)} (1.south east);
\node[observed] at (10, 6) (2){};
\node[observed] at (10, 2) (3){};
\node[observed] at (10,-2) (4){};
\node[observed] at (10,-6) (5){};
\draw[black] (1.north east) -- node[midway, sloped, above]{A=0 (0.1)}
node[midway, sloped, below]{40} (2.west);
\draw[black] (2.west) --node[midway, sloped, above]{Y=0 (0.75)} (2.north east);
\draw[black] (2.west) --node[midway, sloped, above]{Y=1 (0.25)} (2.south east);
\node[end_text] at (12, 7) {30};
\node[end_text] at (12, 5) {10};
\draw[black] (1.north east) -- node[midway, sloped, above]{A=1 (0.9)}
node[midway, sloped, below]{360} (3.west);
\draw[black] (3.west) --node[midway, sloped, above]{Y=0 (0.67)} (3.north east);
\draw[black] (3.west) --node[midway, sloped, above]{Y=1 (0.33)} (3.south east);
%Step 2: draw probability tree
\begin{tikzpicture}
\node[observed] at (0, 0) (1){};
\draw[black] (1.west) --node[midway, sloped, above]{L=1 (0.4)} (1.north east);
\draw[black] (1.west) --node[midway, sloped, above]{L=0 (0.6)} (1.south east);
\node[observed] at (10, 6) (2){};
\node[observed] at (10, 2) (3){};
\node[observed] at (10,-2) (4){};
\node[observed] at (10,-6) (5){};
\draw[black] (1.north east) -- node[midway, sloped, above]{A=0 (0.1)}
node[midway, sloped, below]{40} (2.west);
\draw[black] (2.west) --node[midway, sloped, above]{Y=0 (0.75)} (2.north east);
\draw[black] (2.west) --node[midway, sloped, above]{Y=1 (0.25)} (2.south east);
\node[end_text] at (12, 7) {30};
\node[end_text] at (12, 5) {10};
\draw[black] (1.north east) -- node[midway, sloped, above]{A=1 (0.9)}
node[midway, sloped, below]{360} (3.west);
\draw[black] (3.west) --node[midway, sloped, above]{Y=0 (0.67)} (3.north east);
\draw[black] (3.west) --node[midway, sloped, above]{Y=1 (0.33)} (3.south east);
\node[end_text] at (12, 3) {240};
\node[end_text] at (12, 1) {120};
\draw[black] (1.south east) -- node[midway, sloped, above]{A=0 (0.5)}
node[midway, sloped, below]{300} (4.west);
\draw[black] (4.west) --node[midway, sloped, above]{Y=0 (0.9)} (4.north east);
\draw[black] (4.west) --node[midway, sloped, above]{Y=1 (0.1)} (4.south east);
\node[end_text] at (12, -1) {270};
\node[end_text] at (12, -3) {30};
\draw[black] (1.south east) -- node[midway, sloped, above]{A=1 (0.5)}
node[midway, sloped, below]{300} (5.west);
\draw[black] (5.west) --node[midway, sloped, above]
{Y=0 $(\frac{1}{3})$} (5.north east);
\draw[black] (5.west) --node[midway, sloped, above]
{Y=1 $(\frac{2}{3})$} (5.south east);
\node[end_text] at (12, -5) {100};
\node[end_text] at (12, -7) {200};
\end{tikzpicture}
\end{Verbatim}
\end{framed}
\newpage
\subsection{Using probability trees to estimate inverse probability weights for point exposures}
The following figure demonstrates the use of probability trees as a didactic tool for estimating inverse probability of treatment weights with a point intervention.
The figure below is identical to the probability tree for a point exposure, except that it now includes a final column displaying the value of the unstabilized inverse probability of treatment weights, calculated as $W^a = \frac{1}{f\left(A|L\right)}$. That is, for those individuals who received an intervention value of $A$ = 1, their inverse probability of treatment weight is equal to 1 over their conditional probability of having received intervention $A$ = 1 given their observed covariate value, $L$, or $\frac{1}{P\left(A=1|L\right)}$.
\vspace{3mm}
\begin{framed}
Probability tree:
%Step 1: create styles for labeling nodes
\tikzstyle{observed} = [circle, thick, text centered, draw, minimum height=1in, minimum width=1in, text width=9em, text height = 16pt]
\tikzstyle{end_text} = [thick, text centered]
%Step 2: draw probability tree
\begin{tikzpicture}
\node[observed] at (0, 0) (1){};
\draw[black] (1.west) --node[midway, sloped, above]{L=1 (0.4)} (1.north east);
\draw[black] (1.west) --node[midway, sloped, above]{L=0 (0.6)} (1.south east);
\node[observed] at (10, 6) (2){};
\node[observed] at (10, 2) (3){};
\node[observed] at (10,-2) (4){};
\node[observed] at (10,-6) (5){};
\draw[black] (1.north east) -- node[midway, sloped, above]{A=0 (0.1)}
node[midway, sloped, below]{40} (2.west);
\draw[black] (2.west) --node[midway, sloped, above]{Y=0 (0.75)} (2.north east);
\draw[black] (2.west) --node[midway, sloped, above]{Y=1 (0.25)} (2.south east);
\node[end_text] at (12, 7) {30};
\node[end_text] at (12, 5) {10};
\draw[black] (1.north east) -- node[midway, sloped, above]{A=1 (0.9)}
node[midway, sloped, below]{360} (3.west);
\draw[black] (3.west) --node[midway, sloped, above]{Y=0 (0.67)} (3.north east);
\draw[black] (3.west) --node[midway, sloped, above]{Y=1 (0.33)} (3.south east);
\node[end_text] at (12, 3) {240};
\node[end_text] at (12, 1) {120};
\draw[black] (1.south east) -- node[midway, sloped, above]{A=0 (0.5)}
node[midway, sloped, below]{300} (4.west);
\draw[black] (4.west) --node[midway, sloped, above]{Y=0 (0.9)} (4.north east);
\draw[black] (4.west) --node[midway, sloped, above]{Y=1 (0.1)} (4.south east);
\node[end_text] at (12, -1) {270};
\node[end_text] at (12, -3) {30};
\draw[black] (1.south east) -- node[midway, sloped, above]{A=1 (0.5)}
node[midway, sloped, below]{300} (5.west);
\draw[black] (5.west) --node[midway, sloped, above]
{Y=0 $(\frac{1}{3})$} (5.north east);
\draw[black] (5.west) --node[midway, sloped, above]
{Y=1 $(\frac{2}{3})$} (5.south east);
\node[end_text] at (12, -5) {100};
\node[end_text] at (12, -7) {200};
\node[end_text] at (13, 9) {W$^a$ = };
\node[end_text] at (13, 8) {$\frac{1}{f(A|L)}$};
\node[end_text] at (13, 7) {$\frac{1}{0.1}$};
\node[end_text] at (13, 5) {$\frac{1}{0.1}$};
\node[end_text] at (13, 3) {$\frac{1}{0.9}$};
\node[end_text] at (13, 1) {$\frac{1}{0.9}$};
\node[end_text] at (13, -1) {$\frac{1}{0.5}$};
\node[end_text] at (13, -3) {$\frac{1}{0.5}$};
\node[end_text] at (13, -5) {$\frac{1}{0.5}$};
\node[end_text] at (13, -7) {$\frac{1}{0.5}$};
\end{tikzpicture}
\begin{Verbatim}
Code:
%Step 1: create styles for labeling nodes
\tikzstyle{observed} = [circle, thick, text centered, draw, minimum height=1in,
minimum width=1in, text width=9em, text height = 16pt]
\tikzstyle{end_text} = [thick, text centered]
%Step 2: draw probability tree
\begin{tikzpicture}
\node[observed] at (0, 0) (1){};
\draw[black] (1.west) --node[midway, sloped, above]{L=1 (0.4)} (1.north east);
\draw[black] (1.west) --node[midway, sloped, above]{L=0 (0.6)} (1.south east);
\node[observed] at (10, 6) (2){};
\node[observed] at (10, 2) (3){};
\node[observed] at (10,-2) (4){};
\node[observed] at (10,-6) (5){};
\draw[black] (1.north east) -- node[midway, sloped, above]{A=0 (0.1)}
node[midway, sloped, below]{40} (2.west);
\draw[black] (2.west) --node[midway, sloped, above]{Y=0 (0.75)} (2.north east);
\draw[black] (2.west) --node[midway, sloped, above]{Y=1 (0.25)} (2.south east);
\node[end_text] at (12, 7) {30};
\node[end_text] at (12, 5) {10};
\draw[black] (1.north east) -- node[midway, sloped, above]{A=1 (0.9)}
node[midway, sloped, below]{360} (3.west);
\draw[black] (3.west) --node[midway, sloped, above]{Y=0 (0.67)} (3.north east);
\draw[black] (3.west) --node[midway, sloped, above]{Y=1 (0.33)} (3.south east);
\node[end_text] at (12, 3) {240};
\node[end_text] at (12, 1) {120};
\draw[black] (1.south east) -- node[midway, sloped, above]{A=0 (0.5)}
node[midway, sloped, below]{300} (4.west);
\draw[black] (4.west) --node[midway, sloped, above]{Y=0 (0.9)} (4.north east);
\draw[black] (4.west) --node[midway, sloped, above]{Y=1 (0.1)} (4.south east);
\node[end_text] at (12, -1) {270};
\node[end_text] at (12, -3) {30};
\draw[black] (1.south east) -- node[midway, sloped, above]{A=1 (0.5)}
node[midway, sloped, below]{300} (5.west);
\draw[black] (5.west) --node[midway, sloped, above]
{Y=0 $(\frac{1}{3})$} (5.north east);
\draw[black] (5.west) --node[midway, sloped, above]
{Y=1 $(\frac{2}{3})$} (5.south east);
\node[end_text] at (12, -5) {100};
\node[end_text] at (12, -7) {200};
\node[end_text] at (13, 9) {W$^a$ = };
\node[end_text] at (13, 8) {$\frac{1}{f(A|L)}$};
\node[end_text] at (13, 7) {$\frac{1}{0.1}$};
\node[end_text] at (13, 5) {$\frac{1}{0.1}$};
\node[end_text] at (13, 3) {$\frac{1}{0.9}$};
\node[end_text] at (13, 1) {$\frac{1}{0.9}$};
\node[end_text] at (13, -1) {$\frac{1}{0.5}$};
\node[end_text] at (13, -3) {$\frac{1}{0.5}$};
\node[end_text] at (13, -5) {$\frac{1}{0.5}$};
\node[end_text] at (13, -7) {$\frac{1}{0.5}$};
\end{tikzpicture}
\end{Verbatim}
\end{framed}
\vspace{3pt}
\subsection{Probability tree for point exposures with loss to follow-up}
When individuals can be lost to follow-up or censored for dropout or non-compliance, we may also be interested in inverse probability of censoring weights. The probability tree below demonstrates the case where censoring occurs after the point intervention but before outcome ascertainment. Censoring is depicted in the tree using an additional set of intervention-style branches.
A similar approach can be used to build probability trees for sustained exposures. However, these trees rapidly become larger than can easily be displayed and their utility as teaching tools is reduced the more complex these trees become.
\newpage
\begin{framed}
\verb|Probability tree:|
%Step 1: create styles for labeling nodes
\tikzstyle{observed} = [circle, thick, text centered, draw, minimum height=1in,
minimum width=1in, text height = 8pt]
\tikzstyle{end_text} = [thick, text centered]
%Step 2: draw probability tree
\begin{tikzpicture}
\node[observed] at (0, 0) (1){};
\draw[black] (1.west) --node[midway, sloped, above]{L=1 (0.4)} (1.north east);
\draw[black] (1.west) --node[midway, sloped, above]{L=0 (0.6)} (1.south east);
\draw[black] (1.north east) --node[midway, sloped, above]{A=1 (0.1)}
node[midway, sloped, below]{40}(5,5);
\draw[black] (1.north east) --node[midway, sloped, above]{A=0 (0.9)}
node[midway, sloped, below]{360} (5,1.8);
\draw[black] (1.south east) --node[midway, sloped, above]{A=1 (0.5)}
node[midway, sloped, below]{300} (5,-1.8);
\draw[black] (1.south east) --node[midway, sloped, above]{A=0 (0.5)}
node[midway, sloped, below]{300} (5,-5);
\node[observed] at (10, 9.20) (2){};
\node[observed] at (10, 6.55) (3){};
\node[observed] at (10, 3.90) (4){};
\node[observed] at (10, 1.32) (5){};
\node[observed] at (10,-1.32) (6){};
\node[observed] at (10,-3.90) (7){};
\node[observed] at (10,-6.55) (8){};
\node[observed] at (10,-9.20) (9){};
\draw[black] (5,5) -- node[midway, sloped, above]{C=0 (0.9)}
node[midway, sloped, below]{36} (2.west);
\draw[black] (5,5) -- node[midway, sloped, above]{C=1 (0.1)}
node[midway, sloped, below]{4} (3.west);
\draw[black] (2.west) --node[midway, sloped, above]{Y=0 0.75)} (2.north east);
\draw[black] (2.west) --node[midway, sloped, below]{Y=1 (0.25)} (2.south east);
\node[end_text] at (12, 10) {24};
\node[end_text] at (12, 8.3) {8};
\draw[black] (3.west) --node[midway, sloped, above]{Y=0 (0.75)} (3.north east);
\draw[black] (3.west) --node[midway, sloped, below]{Y=1 (0.25)} (3.south east);
\node[end_text] at (12, 7.3) {3};
\node[end_text] at (12, 5.8) {1};
\draw[black] (5, 1.8) -- node[midway, sloped, above]{C=0 (0.2)}
node[midway, sloped, below]{72} (4.west);
\draw[black] (5, 1.8) -- node[midway, sloped, above]{C=1 (0.8)}
node[midway, sloped, below]{288} (5.west);
\draw[black] (4.west) --node[midway, sloped, above]{Y=0 0.67)} (4.north east);
\draw[black] (4.west) --node[midway, sloped, below]{Y=1 (0.33)} (4.south east);
\node[end_text] at (12, 4.5) {48};
\node[end_text] at (12, 2.8) {24};
\draw[black] (5.west) --node[midway, sloped, above]{Y=0 (0.50)} (5.north east);
\draw[black] (5.west) --node[midway, sloped, below]{Y=1 (0.50)} (5.south east);
\node[end_text] at (12, 2.0) {144};
\node[end_text] at (12, 0.5) {144};
\draw[black] (5,-1.8) -- node[midway, sloped, above]{C=0 (0.9)}
node[midway, sloped, below]{270} (6.west);
\draw[black] (5,-1.8) -- node[midway, sloped, above]{C=1 (0.1)}
node[midway, sloped, below]{30} (7.west);
\draw[black] (6.west) --node[midway, sloped, above]{Y=0 0.9)} (6.north east);
\draw[black] (6.west) --node[midway, sloped, below]{Y=1 (0.1)} (6.south east);
\node[end_text] at (12, -0.5) {247};
\node[end_text] at (12, -2.0) {27};
\draw[black] (7.west) --node[midway, sloped, above]{Y=0 (0.8)} (7.north east);
\draw[black] (7.west) --node[midway, sloped, below]{Y=1 (0.2)} (7.south east);
\node[end_text] at (12, -2.8) {24};
\node[end_text] at (12, -4.5) {6};
\draw[black] (5,-5) -- node[midway, sloped, above]{C=0 (0.8)}
node[midway, sloped, below]{240} (8.west);
\draw[black] (5,-5) -- node[midway, sloped, above]{C=1 (0.2)}
node[midway, sloped, below]{60} (9.west);
\draw[black] (8.west) --node[midway, sloped, above]{Y=0 0.75)} (8.north east);
\draw[black] (8.west) --node[midway, sloped, below]{Y=1 (0.25)} (8.south east);
\node[end_text] at (12, -5.8) {180};
\node[end_text] at (12, -7.3) {60};
\draw[black] (9.west) --node[midway, sloped, above]{Y=0 (0.67)} (9.north east);
\draw[black] (9.west) --node[midway, sloped, below]{Y=1 (0.33)} (9.south east);
\node[end_text] at (12, -8.3) {40};
\node[end_text] at (12, -10) {20};
\end{tikzpicture}
\begin{Verbatim}
Code:
%Step 1: create styles for labeling nodes
\tikzstyle{observed} = [circle, thick, text centered, draw, minimum height=1in,
minimum width=1in, text height = 8pt]
\tikzstyle{end_text} = [thick, text centered]
%Step 2: draw probability tree
\begin{tikzpicture}
\node[observed] at (0, 0) (1){};
\draw[black] (1.west) --node[midway, sloped, above]{L=1 (0.4)} (1.north east);
\draw[black] (1.west) --node[midway, sloped, above]{L=0 (0.6)} (1.south east);
\draw[black] (1.north east) --node[midway, sloped, above]{A=1 (0.1)}
node[midway, sloped, below]{40}(5,5);
\draw[black] (1.north east) --node[midway, sloped, above]{A=0 (0.9)}
node[midway, sloped, below]{360} (5,1.8);
\draw[black] (1.south east) --node[midway, sloped, above]{A=1 (0.5)}
node[midway, sloped, below]{300} (5,-1.8);
\draw[black] (1.south east) --node[midway, sloped, above]{A=0 (0.5)}
node[midway, sloped, below]{300} (5,-5);
\node[observed] at (10, 9.20) (2){};
\node[observed] at (10, 6.55) (3){};
\node[observed] at (10, 3.90) (4){};
\node[observed] at (10, 1.32) (5){};
\node[observed] at (10,-1.32) (6){};
\node[observed] at (10,-3.90) (7){};
\node[observed] at (10,-6.55) (8){};
\node[observed] at (10,-9.20) (9){};
\draw[black] (5,5) -- node[midway, sloped, above]{C=0 (0.9)}
node[midway, sloped, below]{36} (2.west);
\draw[black] (5,5) -- node[midway, sloped, above]{C=1 (0.1)}
node[midway, sloped, below]{4} (3.west);
\draw[black] (2.west) --node[midway, sloped, above]{Y=0 0.75)} (2.north east);
\draw[black] (2.west) --node[midway, sloped, below]{Y=1 (0.25)} (2.south east);
\node[end_text] at (12, 10) {24};
\node[end_text] at (12, 8.3) {8};
\draw[black] (3.west) --node[midway, sloped, above]{Y=0 (0.75)} (3.north east);
\draw[black] (3.west) --node[midway, sloped, below]{Y=1 (0.25)} (3.south east);
\node[end_text] at (12, 7.3) {3};
\node[end_text] at (12, 5.8) {1};
\draw[black] (5, 1.8) -- node[midway, sloped, above]{C=0 (0.2)}
node[midway, sloped, below]{72} (4.west);
\draw[black] (5, 1.8) -- node[midway, sloped, above]{C=1 (0.8)}
node[midway, sloped, below]{288} (5.west);
\draw[black] (4.west) --node[midway, sloped, above]{Y=0 0.67)} (4.north east);
\draw[black] (4.west) --node[midway, sloped, below]{Y=1 (0.33)} (4.south east);
\node[end_text] at (12, 4.5) {48};
\node[end_text] at (12, 2.8) {24};
\draw[black] (5.west) --node[midway, sloped, above]{Y=0 (0.50)} (5.north east);
\draw[black] (5.west) --node[midway, sloped, below]{Y=1 (0.50)} (5.south east);
\node[end_text] at (12, 2.0) {144};
\node[end_text] at (12, 0.5) {144};
\draw[black] (5,-1.8) -- node[midway, sloped, above]{C=0 (0.9)}
node[midway, sloped, below]{270} (6.west);
\draw[black] (5,-1.8) -- node[midway, sloped, above]{C=1 (0.1)}
node[midway, sloped, below]{30} (7.west);
\draw[black] (6.west) --node[midway, sloped, above]{Y=0 0.9)} (6.north east);
\draw[black] (6.west) --node[midway, sloped, below]{Y=1 (0.1)} (6.south east);
\node[end_text] at (12, -0.5) {247};
\node[end_text] at (12, -2.0) {27};
\draw[black] (7.west) --node[midway, sloped, above]{Y=0 (0.8)} (7.north east);
\draw[black] (7.west) --node[midway, sloped, below]{Y=1 (0.2)} (7.south east);
\node[end_text] at (12, -2.8) {24};
\node[end_text] at (12, -4.5) {6};
\draw[black] (5,-5) -- node[midway, sloped, above]{C=0 (0.8)}
node[midway, sloped, below]{240} (8.west);
\draw[black] (5,-5) -- node[midway, sloped, above]{C=1 (0.2)}
node[midway, sloped, below]{60} (9.west);
\draw[black] (8.west) --node[midway, sloped, above]{Y=0 0.75)} (8.north east);
\draw[black] (8.west) --node[midway, sloped, below]{Y=1 (0.25)} (8.south east);
\node[end_text] at (12, -5.8) {180};
\node[end_text] at (12, -7.3) {60};
\draw[black] (9.west) --node[midway, sloped, above]{Y=0 (0.67)} (9.north east);
\draw[black] (9.west) --node[midway, sloped, below]{Y=1 (0.33)} (9.south east);
\node[end_text] at (12, -8.3) {40};
\node[end_text] at (12, -10) {20};
\end{tikzpicture}
\end{Verbatim}
\end{framed}
\vspace{3mm}
\chapter{Decision trees for Markov processes}
Decision trees are widely used in health policy and comparative effectiveness research to both visualize the decision making process and to describe Markov models. Markov models can be individual-level simulation models or compartmental models, and are tools for assessing counterfactual outcomes under a set of hypotheses and assumptions about the world.
The trees begin with the potential states into which each individual or type of individual must be categorized at the start of every time-step. Typically, at least one of these states is a sink -- i.e. a state from which individuals cannot leave. This state has as a descendant only an end node (typically denoted with a triangle). All other states have as descendants a series of one or more decision nodes. Some of these nodes represent decisions based on the intervention of interest and are indicated by a black box at the decision point. Other nodes represent characteristics that are updated based on a (conditional) probability distribution and are represented by hollow circles at the decision point.
In the decision tree, at any time a series of descendants can be replaced by a 'copy node' (a + symbol inscribed in a circle) to denote that all descendants of this node follow the same series as the descendants of its sibling nodes.
\vspace{3mm}
\section{Decision tree for a Markov model of dynamic interventions on sustained exposures}
The decision tree in this section depicts a decision tree for a Markov model when treatment decisions are deterministic and based on some stochastic covariate test, and the potential health states of interest are 'alive' and 'dead'.
In this scenario, individuals who have a covariate score of above a treatment threshold will have a higher probability of receiving the intervention than individuals with a covariate score below the threshold. This represents the same basic scenario depicted by the statistical and causal DAGs for sustained exposures and the intervention-specific SWIG and SWIG template for dynamic interventions on sustained exposures. However, we have omitted the unknown common cause of $L$ and $Y$ because decision trees for Markov models generally include only known variables.
\begin{landscape}
\begin{framed}
\verb|Decision tree:|
%Step 1: create styles for labeling nodes
\tikzstyle{startnode} = [circle, thick, draw = black,text centered, minimum height=8pt, minimum width=8pt, fill=white, inner sep=0pt, xshift = -1.3cm]
\tikzstyle{choice} = [regular polygon, regular polygon sides = 4, thick, minimum width=8pt, fill, inner sep=0pt]
\tikzstyle{textbox} = [rectangle, thick, text width=9em, text height = 16pt, text centered, draw]
\tikzstyle{fixedchoice} = [circle, thick, draw = black, minimum height=8pt, minimum width=8pt, fill=white, inner sep=0pt]
\tikzstyle{copynode}=[circle, thick, draw, text centered, minimum width=8pt, inner sep=0pt]
\tikzstyle{endnode} = [regular polygon, draw = black,thick, regular polygon sides=3, minimum width=10pt, fill=white, inner sep=0pt,shape border rotate=90,outer sep=-\pgflinewidth, xshift = -0.2cm]
\tikzstyle{endtext}=[thick, text centered]
%Step 2: draw decision tree -- note tree builds from left to right and bottom to top
\begin{tikzpicture}[
grow=right,child anchor=west,
level 1/.style={sibling distance=6.6cm},level 2/.style={sibling distance=5.8cm},
level 3/.style={sibling distance=5.8cm},level 4/.style={sibling distance=5.8cm},
level 5/.style={sibling distance=3.0cm},level 6/.style={sibling distance=3.0cm},
level 7/.style={sibling distance=1.2cm},level 8/.style={sibling distance=1.2cm},
level 9/.style={sibling distance=1.2cm},
level distance = 2.75cm, thick]
\node[startnode]{}
child{node[textbox]{Die \\($Y_{k}=1$)}
child{node[endnode]{}}
}
child{node[textbox]{Survive \\(${Y}_{k}=0$)}
child{node[fixedchoice]{}
child {node[textbox]{Test $<$ threshold \\ ($L_{k}=0$)}
child{node[copynode]{+}
}
}
child{node[textbox](1){Test $\geq$ threshold \\ ($L_{k}=1$) }
child{node[choice]{}
child{node[textbox]{Untreated ($A_{k}=0$)}
child{node[copynode]{+}
}
}
child{node[textbox](2){Treated ($A_{k}=1$)}
child{node[fixedchoice]{}
child{node[textbox](3){Die ($Y_{k+1}=1$)}
child{node[endnode]{} }
}
child{node[textbox]{Survive ($Y_{k+1}=0$)}
child{node[endnode]{}}
}
}
}
}
}
}
}
;
%optional code to label conditional probabilities associated with nodes;
\node [below=0.7cm, align=right, thick, xshift = 0.5cm] at (1) {$P\left(L_{k}=1|L_{k-1},A_{k-1}, Y_{k}=0\right)$};
\node [below=0.5cm, align=right, thick, xshift = 0.5cm] at (2) {$P\left(A_{k}=1|L_{k},A_{k-1}, Y_{k}=0\right)$};
\node [below=0.5cm, align=right, thick, xshift = 0.2cm] at (3) {$P\left(Y_{k+1}=1|L_{k},A_{k}, Y_{k}=0\right)$};
\end{tikzpicture}
\end{framed}
\end{landscape}
\begin{framed}
\begin{Verbatim}
Code:
%Step 1: create styles for labeling nodes
\tikzstyle{startnode} = [circle, thick, draw = black, text centered,
minimum height=8pt, minimum width=8pt, fill=white,
inner sep=0pt, xshift = -1.3cm]
\tikzstyle{choice} = [regular polygon, regular polygon sides = 4, thick,
minimum width=8pt, fill, inner sep=0pt]
\tikzstyle{textbox} = [rectangle, thick, text width=9em, text height = 16pt,
text centered, draw]
\tikzstyle{fixedchoice} = [circle, thick, draw = black, minimum height=8pt,
minimum width=8pt, fill=white, inner sep=0pt]
\tikzstyle{copynode}=[circle, thick, draw, text centered,
minimum width=8pt, inner sep=0pt]
\tikzstyle{endnode} = [regular polygon, draw = black,thick,
regular polygon sides=3, minimum width=10pt,
fill=white, inner sep=0pt,shape border rotate=90,
outer sep=-\pgflinewidth, xshift = -0.2cm]
\tikzstyle{endtext}=[thick, text centered]
%Step 2: draw decision tree -- note tree builds from left to right and bottom to top
\begin{tikzpicture}[
grow=right,child anchor=west,
level 1/.style={sibling distance=6.6cm},level 2/.style={sibling distance=5.8cm},
level 3/.style={sibling distance=5.8cm},level 4/.style={sibling distance=5.8cm},
level 5/.style={sibling distance=3.0cm},level 6/.style={sibling distance=3.0cm},
level 7/.style={sibling distance=1.2cm},level 8/.style={sibling distance=1.2cm},
level 9/.style={sibling distance=1.2cm},
level distance = 2.75cm, thick]
\node[startnode]{}
child{node[textbox]{Die \\($Y_{k}=1$)}
child{node[endnode]{}}
}
child{node[textbox]{Survive \\(${Y}_{k}=0$)}
child{node[fixedchoice]{}
child {node[textbox]{Test $<$ threshold \\ ($L_{k}=0$)}
child{node[copynode]{+}}
}
child{node[textbox](1){Test $\geq$ threshold \\ ($L_{k}=1$)}
child{node[choice]{}
child{node[textbox]{Untreated ($A_{k}=0$)}
child{node[copynode]{+}}
}
child{node[textbox](2){Treated ($A_{k}=1$)}
child{node[fixedchoice]{}
child{node[textbox](3){Die ($Y_{k+1}=1$)}
child{node[endnode]{}}
}
child{node[textbox]{Survive ($Y_{k+1}=0$)}
child{node[endnode]{}}
}
}
}
}
}
}
}
;
%optional code to label conditional probabilities associated with nodes;
\node [below=0.7cm, align=right, thick, xshift = 0.5cm] at (1)
{$P\left(L_{k}=1|L_{k-1},A_{k-1}, Y_{k}=0\right)$};
\node [below=0.5cm, align=right, thick, xshift = 0.5cm] at (2)
{$P\left(A_{k}=1|L_{k},A_{k-1}, Y_{k}=0\right)$};
\node [below=0.5cm, align=right, thick, xshift = 0.2cm] at (3)
{$P\left(Y_{k+1}=1|L_{k},A_{k}, Y_{k}=0\right)$};
\end{tikzpicture}
\end{Verbatim}
\end{framed}
\chapter{Path Diagrams for Structural Equation Models}
Structural Equation Models (SEMs) are commonly used for causal inference in psychology, sociology, and social sciences. This class of models includes path analysis and confirmatory factor analysis. SEMs are generally designed to provide an overall analysis of a set of complex interrelationships rather than to estimate the specific causal effect of one variable on another. Another distinguishing features of SEMs is the use of latent variables to describe unmeasureable concepts that may be important.
Structural equation models are generally visualized through the use of a path diagram. Path diagrams may look similar to DAGs but encode different information.
\section{Path diagram conventions}
Path diagrams have four different types of nodes:
\begin{itemize}
\item Observed variables: the exposure, covariate, and outcome information you have collected in your study. An example of an observed variable is measured score from the Short Form 36 (SF-36) Health Questionnaire. Observed nodes are enclosed in a rectangular box.
\item Latent variables: important unobserved, and typically unobservable, variables that you would like to know about and think are important but you don't have in your data. An example of a latent variable is Quality of Life, which is one of the constructs the SF-36 is hoping to measure but which cannot be directly observed. Latent nodes are enclosed in a circle or oval.
\item Error nodes: these represent other, unmeasured and/or unknown causes of the variables in your model, including randomness. These nodes are optional. Error nodes can be enclosed in a circle or oval or not enclosed.
\item Confounding node: in many published path diagrams, a node labeled 'Confounders' or 'Confounding' will be included to remind the reader than other unknown confounders may exist. This node is optional, and usually enclosed in a rectangular box.
\end{itemize}
\vspace{2em}
Path diagrams also have three different types of arrows:
\begin{itemize}
\item Solid arrows with single arrowheads: these arrows have the same meaning as an arrow in a DAG; they represent known or suspected causal effects from cause to effect in the direction of the arrow.
\item Solid arrows with double arrowheads: these arrows are used when the covariance structure between two variables is important. This will often be because of unmeasured or unknown common causes of the two variables.
\item Dashed arrows with a single arrowhead: these arrows represent possible causal effects and are generally used to show variables which may have unknown relationships with unmeasured confounders.
\end{itemize}
\vspace{2em}
Finally, path diagrams can also have annotations on the arrows:
\begin{itemize}
\item Model output: after the model described by the path diagram has been analyzed the estimated associations may be included in the diagram as arrow annotations.
\item Model constraints: in some analyses, certain relationships will be constrained by design. For example, the covariance between two variables may be fixed at 0. These constraints may be added as arrow annotations.
\end{itemize}
\section{A path diagram using error nodes}
The code below is a modified version of a path diagram that was used to analyze a structural equation model of worker and workplace factors in prolonged absence from work among nurses \cite{franche2011examining}.
\vspace{3em}
\begin{framed}
\begin{tikzpicture}[
observed/.style = {rectangle, thick, text centered, draw, text width = 6em},
latent/.style = {ellipse, thick, draw, text centered, text width = 6em},
error/.style ={circle, thick, draw, text centered},
confounding/.style = {rectangle, thick, text centered, draw, text width = 6em, minimum width = 5.5in},
outcome/.style = {rectangle, thick, draw, text centered, minimum height = 3.5in, text width = 6em},
<-> /.tip =Latex, thick
]
\node[observed] (age) at (0, 0) {Age};
\node[observed] (region) at (0,-1) {Region};
\node[observed] (aboriginal) at (0,-2) {Aboriginal status};
\node[observed] (income) at (0,-3) {Household income};
\node[observed] (marital) at (0,-4) {Martial status};
\node[observed] (role scale) at (0,-5) {Role overload scale};
\node[observed] (overtime) at (0,-6) {Unpaid overtime};
\node[observed] (insecurity) at (0,-7) {Job insecurity};
\node[observed] (employment) at (0,-8) {Employment status};
\node[error](e1) at (-2.5,0.5) {e1}; \draw[Arrow] (e1)--(age);
\node[error](e2) at (-2.5,-0.5) {e2}; \draw[Arrow] (e2) -- (region);
\node[error](e3) at (-2.5,-1.5) {e3}; \draw[Arrow] (e3) -- (aboriginal);
\node[error](e4) at (-2.5,-2.5) {e4}; \draw[Arrow] (e4) -- (income);
\node[error](e5) at (-2.5,-3.5) {e5}; \draw[Arrow] (e5) -- (marital);
\node[error](e6) at (-2.5,-4.5) {e6}; \draw[Arrow] (e6) -- (role scale);
\node[error](e7) at (-2.5,-5.5) {e7}; \draw[Arrow] (e7) -- (overtime);
\node[error](e8) at (-2.5,-6.5) {e8}; \draw[Arrow] (e8) -- (insecurity);
\node[error](e9) at (-2.5,-7.5) {e9}; \draw[Arrow] (e9) -- (employment);
\node[observed, text width = 6.7em] (multimorbid) at (3.5,-2) {Multimorbidity};
\node[latent] (role) at (3.5,-5.5) {Role overload};
\node[error](e10) at (4.5,-1) {e10}; \draw[Arrow] (e10) -- (multimorbid);
\node[error](e11) at (4.5,-6.5) {e11};\draw[Arrow](e11) --(role);
\node[observed] (nonwork pain) at (7,-1) {Non-work-related pain severity};
\node[observed] (work pain) at (7,-3) {Work-related pain severity};
\node[observed] (depression) at (7,-4) {Depression};
\node[error](e12) at (9,0) {e12}; \draw[Arrow] (e12) -- (nonwork pain);
\node[error](e13) at (9,-2.5) {e13}; \draw[Arrow] (e13) -- (work pain);
\node[error](e14) at (8.5,-5) {e14}; \draw[Arrow] (e14) -- (depression);
\node[outcome] (outcome) at (11,-4) {Prolonged work absences due to physical or mental health};
\draw[Arrow] (age.east)--(multimorbid.west);
\draw[Arrow] (region.east)--(multimorbid.west);
\draw[Arrow] (aboriginal.east)--(multimorbid.west);
\draw[Arrow] (income.east)--(multimorbid.west);
\draw[Arrow] (income.east)--(depression.west);
\draw[Arrow] (marital.east)--(depression.west);
\draw[<->] (income) to [out=-180, in=-180](marital);
\draw[Arrow] (multimorbid.east)--(nonwork pain.west);
\draw[Arrow] (multimorbid.east)--(work pain.west);
\draw[Arrow] (multimorbid)--(9.8, -2);
\draw[Arrow] (role.west)--(role scale.east);
\draw[Arrow] (role.west)--(overtime);
\draw[Arrow] (role.east)-- (9.8, -5.5);
\draw[Arrow] (insecurity.east)--(role.south);
\draw[Arrow] (employment.east)--(role.south);
\draw[Arrow] (employment.east)--(9.8, -8);
\draw[Arrow] (nonwork pain)--(9.8, -1);
\draw[Arrow] (work pain)--(9.8, -3);
\draw[Arrow] (depression)--(9.8, -4);
\end{tikzpicture}
\end{framed}
\begin{framed}
\begin{Verbatim}
\begin{tikzpicture}[
observed/.style = {rectangle, thick, text centered, draw, text width = 6em},
latent/.style = {ellipse, thick, draw, text centered, text width = 6em},
error/.style ={circle, thick, draw, text centered},
confounding/.style = {rectangle, thick, text centered, draw, text width = 6em,
minimum width = 5.5in},
outcome/.style = {rectangle, thick, draw, text centered, minimum height = 3.5in,
text width = 6em},
<-> /.tip =Latex, thick
]
\node[observed] (age) at (0, 0) {Age};
\node[observed] (region) at (0,-1) {Region};
\node[observed] (aboriginal) at (0,-2) {Aboriginal status};
\node[observed] (income) at (0,-3) {Household income};
\node[observed] (marital) at (0,-4) {Martial status};
\node[observed] (role scale) at (0,-5) {Role overload scale};
\node[observed] (overtime) at (0,-6) {Unpaid overtime};
\node[observed] (insecurity) at (0,-7) {Job insecurity};
\node[observed] (employment) at (0,-8) {Employment status};
\node[error](e1) at (-2.5,0.5) {e1}; \draw[Arrow] (e1)--(age);
\node[error](e2) at (-2.5,-0.5) {e2}; \draw[Arrow] (e2) -- (region);
\node[error](e3) at (-2.5,-1.5) {e3}; \draw[Arrow] (e3) -- (aboriginal);
\node[error](e4) at (-2.5,-2.5) {e4}; \draw[Arrow] (e4) -- (income);
\node[error](e5) at (-2.5,-3.5) {e5}; \draw[Arrow] (e5) -- (marital);
\node[error](e6) at (-2.5,-4.5) {e6}; \draw[Arrow] (e6) -- (role scale);
\node[error](e7) at (-2.5,-5.5) {e7}; \draw[Arrow] (e7) -- (overtime);
\node[error](e8) at (-2.5,-6.5) {e8}; \draw[Arrow] (e8) -- (insecurity);
\node[error](e9) at (-2.5,-7.5) {e9}; \draw[Arrow] (e9) -- (employment);
\node[observed, text width = 6.7em] (multimorbid) at (3.5,-2) {Multimorbidity};
\node[latent] (role) at (3.5,-5.5) {Role overload};
\node[error](e10) at (4.5,-1) {e10}; \draw[Arrow] (e10) -- (multimorbid);
\node[error](e11) at (4.5,-6.5) {e11};\draw[Arrow](e11) --(role);
\node[observed] (nonwork pain) at (7,-1) {Non-work-related pain severity};
\node[observed] (work pain) at (7,-3) {Work-related pain severity};
\node[observed] (depression) at (7,-4) {Depression};
\node[error](e12) at (9,0) {e12}; \draw[Arrow] (e12) -- (nonwork pain);
\node[error](e13) at (9,-2.5) {e13}; \draw[Arrow] (e13) -- (work pain);
\node[error](e14) at (8.5,-5) {e14}; \draw[Arrow] (e14) -- (depression);
\node[outcome] (outcome) at (11,-4)
{Prolonged work absences due to physical or mental health};
\draw[Arrow] (age.east)--(multimorbid.west);
\draw[Arrow] (region.east)--(multimorbid.west);
\draw[Arrow] (aboriginal.east)--(multimorbid.west);
\draw[Arrow] (income.east)--(multimorbid.west);
\draw[Arrow] (income.east)--(depression.west);
\draw[Arrow] (marital.east)--(depression.west);
\draw[<->] (income) to [out=-180, in=-180](marital);
\draw[Arrow] (multimorbid.east)--(nonwork pain.west);
\draw[Arrow] (multimorbid.east)--(work pain.west);
\draw[Arrow] (multimorbid)--(9.8, -2);
\draw[Arrow] (role.west)--(role scale.east);
\draw[Arrow] (role.west)--(overtime);
\draw[Arrow] (role.east)-- (9.8, -5.5);
\draw[Arrow] (insecurity.east)--(role.south);
\draw[Arrow] (employment.east)--(role.south);
\draw[Arrow] (employment.east)--(9.8, -8);
\draw[Arrow] (nonwork pain)--(9.8, -1);
\draw[Arrow] (work pain)--(9.8, -3);
\draw[Arrow] (depression)--(9.8, -4);
\end{tikzpicture}
\end{Verbatim}
\end{framed}
\section{A path diagram using a confounding node}
As alternative that simplifies the visual presentation, many path diagrams include a confounding node and omit the error nodes. The code below uses this simplified presentation.
\vspace{3em}
\begin{framed}
\begin{tikzpicture}[
observed/.style = {rectangle, thick, text centered, draw, text width = 6em},
latent/.style = {ellipse, thick, draw, text centered, text width = 6em},
error/.style ={circle, thick, draw, text centered},
confounding/.style = {rectangle, thick, text centered, draw, text width = 6em,
minimum width = 5.5in},
outcome/.style = {rectangle, thick, draw, text centered,
minimum height = 3.5in, text width = 6em},
<-> /.tip =Latex, thick
]
\node[observed] (age) at (0, 0) {Age};
\node[observed] (region) at (0,-1) {Region};
\node[observed] (aboriginal) at (0,-2) {Aboriginal status};
\node[observed] (income) at (0,-3) {Household income};
\node[observed] (marital) at (0,-4) {Martial status};
\node[observed] (role scale) at (0,-5) {Role overload scale};
\node[observed] (overtime) at (0,-6) {Unpaid overtime};
\node[observed] (insecurity) at (0,-7) {Job insecurity};
\node[observed] (employment) at (0,-8) {Employment status};
\node[observed, text width = 6.7em] (multimorbid) at (3.5,-2) {Multimorbidity};
\node[latent] (role) at (3.5,-5.5) {Role overload};
\node[observed] (nonwork pain) at (7,-1) {Non-work-related pain severity};
\node[observed] (work pain) at (7,-3) {Work-related pain severity};
\node[observed] (depression) at (7,-4) {Depression};
\node[outcome] (outcome) at (11,-4)
{Prolonged work absences due to physical or mental health};
\node[confounding](conf) at (5.2,1.5) {Unmeasured confounders};
\draw[Arrow] (age.east)--(multimorbid.west);
\draw[Arrow] (region.east)--(multimorbid.west);
\draw[Arrow] (aboriginal.east)--(multimorbid.west);
\draw[Arrow] (income.east)--(multimorbid.west);
\draw[Arrow] (income.east)--(depression.west);
\draw[Arrow] (marital.east)--(depression.west);
\draw[<->] (income) to [out=-180, in=-180](marital);
\draw[Arrow] (multimorbid.east)--(nonwork pain.west);
\draw[Arrow] (multimorbid.east)--(work pain.west);
\draw[Arrow] (multimorbid)--(9.8, -2);
\draw[Arrow] (role.west)--(role scale.east);
\draw[Arrow] (role.west)--(overtime);
\draw[Arrow] (role.east)-- (9.8, -5.5);
\draw[Arrow] (insecurity.east)--(role.south);
\draw[Arrow] (employment.east)--(role.south);
\draw[Arrow] (employment.east)--(9.8, -8);
\draw[Arrow, dashed](0, 1.25)--(0, 0.25);
\draw[Arrow, dashed](3, 1.25)--(3, 0.25);
\draw[Arrow, dashed](7, 1.25)--(7, 0.25);
\draw[Arrow, dashed](11, 1.25)--(11, 0.5);
\draw[Arrow] (nonwork pain)--(9.8, -1);
\draw[Arrow] (work pain)--(9.8, -3);
\draw[Arrow] (depression)--(9.8, -4);
\end{tikzpicture}
\end{framed}
\begin{framed}
\begin{Verbatim}
\begin{tikzpicture}[
observed/.style = {rectangle, thick, text centered, draw, text width = 6em},
latent/.style = {ellipse, thick, draw, text centered, text width = 6em},
error/.style ={circle, thick, draw, text centered},
confounding/.style = {rectangle, thick, text centered, draw, text width = 6em,
minimum width = 5.5in},
outcome/.style = {rectangle, thick, draw, text centered,
minimum height = 3.5in, text width = 6em},
<-> /.tip =Latex, thick
]
\node[observed] (age) at (0, 0) {Age};
\node[observed] (region) at (0,-1) {Region};
\node[observed] (aboriginal) at (0,-2) {Aboriginal status};
\node[observed] (income) at (0,-3) {Household income};
\node[observed] (marital) at (0,-4) {Martial status};
\node[observed] (role scale) at (0,-5) {Role overload scale};
\node[observed] (overtime) at (0,-6) {Unpaid overtime};
\node[observed] (insecurity) at (0,-7) {Job insecurity};
\node[observed] (employment) at (0,-8) {Employment status};
\node[observed, text width = 6.7em] (multimorbid) at (3.5,-2) {Multimorbidity};
\node[latent] (role) at (3.5,-5.5) {Role overload};
\node[observed] (nonwork pain) at (7,-1) {Non-work-related pain severity};
\node[observed] (work pain) at (7,-3) {Work-related pain severity};
\node[observed] (depression) at (7,-4) {Depression};
\node[outcome] (outcome) at (11,-4)
{Prolonged work absences due to physical or mental health};
\node[confounding](conf) at (5.2,1.5) {Unmeasured confounders};
\draw[Arrow] (age.east)--(multimorbid.west);
\draw[Arrow] (region.east)--(multimorbid.west);
\draw[Arrow] (aboriginal.east)--(multimorbid.west);
\draw[Arrow] (income.east)--(multimorbid.west);
\draw[Arrow] (income.east)--(depression.west);
\draw[Arrow] (marital.east)--(depression.west);
\draw[<->] (income) to [out=-180, in=-180](marital);
\draw[Arrow] (multimorbid.east)--(nonwork pain.west);
\draw[Arrow] (multimorbid.east)--(work pain.west);
\draw[Arrow] (multimorbid)--(9.8, -2);
\draw[Arrow] (role.west)--(role scale.east);
\draw[Arrow] (role.west)--(overtime);
\draw[Arrow] (role.east)-- (9.8, -5.5);
\draw[Arrow] (insecurity.east)--(role.south);
\draw[Arrow] (employment.east)--(role.south);
\draw[Arrow] (employment.east)--(9.8, -8);
\draw[Arrow, dashed](0, 1.25)--(0, 0.25);
\draw[Arrow, dashed](3, 1.25)--(3, 0.25);
\draw[Arrow, dashed](7, 1.25)--(7, 0.25);
\draw[Arrow, dashed](11, 1.25)--(11, 0.5);
\draw[Arrow] (nonwork pain)--(9.8, -1);
\draw[Arrow] (work pain)--(9.8, -3);
\draw[Arrow] (depression)--(9.8, -4);
\end{tikzpicture}
\end{Verbatim}
\end{framed}
\section{An annotated path diagram}
Finally, we can annotate the arrows of the path diagram to display either our model estimates or our model constraints. The annotations in the example below are standardized regression coefficients taken from a published model but should not be used for decision-making since the published model had more model components \cite{franche2011examining}.
\vspace{3em}
\begin{framed}
\begin{tikzpicture}[
observed/.style = {rectangle, thick, text centered, draw, text width = 6em},
latent/.style = {ellipse, thick, draw, text centered, text width = 6em},
error/.style ={circle, thick, draw, text centered},
confounding/.style = {rectangle, thick, text centered, draw, text width = 6em,
minimum width = 5.5in},
outcome/.style = {rectangle, thick, draw, text centered,
minimum height = 3.5in, text width = 6em},
<-> /.tip =Latex, thick
]
\node[observed] (age) at (0, -1) {Age};
\node[observed] (income) at (0,-2.5) {Household income};
\node[observed] (marital) at (0,-4) {Martial status};
\node[observed] (role scale) at (0,-5) {Role overload scale};
\node[observed] (overtime) at (0,-6) {Unpaid overtime};
\node[observed] (insecurity) at (0,-7) {Job insecurity};
\node[observed] (employment) at (0,-8) {Employment status};
\node[observed, text width = 6.7em] (multimorbid) at (3.5,-2) {Multimorbidity};
\node[latent] (role) at (3.5,-5.5) {Role overload};
\node[observed] (nonwork pain) at (7,-1) {Non-work-related pain severity};
\node[observed] (work pain) at (7,-3) {Work-related pain severity};
\node[observed] (depression) at (7,-4) {Depression};
\node[outcome] (outcome) at (11,-4)
{Prolonged work absences due to physical or mental health};
\node[confounding](conf) at (5.2,1.5) {Unmeasured confounders};
\draw[Arrow] (age.east)--node[midway, right] {0.2}(multimorbid.west);
\draw[Arrow] (income.east)--node[midway, above] {-0.1}(multimorbid.west);
\draw[Arrow] (marital.east)--node[midway, above] {0.04} (depression.west);
\draw[Arrow] (multimorbid.east)--(nonwork pain.west);
\draw[Arrow] (multimorbid.east)--node[midway,left] {0.5} (work pain.west);
\draw[Arrow] (role.west)--(role scale.east);
\draw[Arrow] (role.west)--(overtime);
\draw[Arrow] (role.east)--node[midway,above] {0.7} (9.8, -5.5);
\draw[Arrow] (insecurity.east)--node[midway, below right] {-0.2} (role.south);
\draw[Arrow] (employment.east)--node[midway, above] {-0.1} (9.8, -8);
\draw[Arrow, dashed](0, 1.25)--(0, 0.25);
\draw[Arrow, dashed](3, 1.25)--(3, 0.25);
\draw[Arrow, dashed](7, 1.25)--(7, 0.25);
\draw[Arrow, dashed](11, 1.25)--(11, 0.5);
\draw[Arrow] (nonwork pain)--node[midway, above] {0.1} (9.8, -1);
\draw[Arrow] (work pain)--node[midway,above] {0.8} (9.8, -3);
\draw[Arrow] (depression)--node[midway, above] {0.3} (9.8, -4);
\end{tikzpicture}
\end{framed}
\begin{framed}
\begin{Verbatim}
\begin{tikzpicture}[
observed/.style = {rectangle, thick, text centered, draw, text width = 6em},
latent/.style = {ellipse, thick, draw, text centered, text width = 6em},
error/.style ={circle, thick, draw, text centered},
confounding/.style = {rectangle, thick, text centered, draw, text width = 6em,
minimum width = 5.5in},
outcome/.style = {rectangle, thick, draw, text centered,
minimum height = 3.5in, text width = 6em},
<-> /.tip =Latex, thick
]
\node[observed] (age) at (0, -1) {Age};
\node[observed] (income) at (0,-2.5) {Household income};
\node[observed] (marital) at (0,-4) {Martial status};
\node[observed] (role scale) at (0,-5) {Role overload scale};
\node[observed] (overtime) at (0,-6) {Unpaid overtime};
\node[observed] (insecurity) at (0,-7) {Job insecurity};
\node[observed] (employment) at (0,-8) {Employment status};
\node[observed, text width = 6.7em] (multimorbid) at (3.5,-2) {Multimorbidity};
\node[latent] (role) at (3.5,-5.5) {Role overload};
\node[observed] (nonwork pain) at (7,-1) {Non-work-related pain severity};
\node[observed] (work pain) at (7,-3) {Work-related pain severity};
\node[observed] (depression) at (7,-4) {Depression};
\node[outcome] (outcome) at (11,-4)
{Prolonged work absences due to physical or mental health};
\node[confounding](conf) at (5.2,1.5) {Unmeasured confounders};
\draw[Arrow] (age.east)--node[midway, right] {0.2}(multimorbid.west);
\draw[Arrow] (income.east)--node[midway, above] {-0.1}(multimorbid.west);
\draw[Arrow] (marital.east)--node[midway, above] {0.04} (depression.west);
\draw[Arrow] (multimorbid.east)--(nonwork pain.west);
\draw[Arrow] (multimorbid.east)--node[midway,left] {0.5} (work pain.west);
\draw[Arrow] (role.west)--(role scale.east);
\draw[Arrow] (role.west)--(overtime);
\draw[Arrow] (role.east)--node[midway,above] {0.7} (9.8, -5.5);
\draw[Arrow] (insecurity.east)--node[midway, below right] {-0.2} (role.south);
\draw[Arrow] (employment.east)--node[midway, above] {-0.1} (9.8, -8);
\draw[Arrow, dashed](0, 1.25)--(0, 0.25);
\draw[Arrow, dashed](3, 1.25)--(3, 0.25);
\draw[Arrow, dashed](7, 1.25)--(7, 0.25);
\draw[Arrow, dashed](11, 1.25)--(11, 0.5);
\draw[Arrow] (nonwork pain)--node[midway, above] {0.1} (9.8, -1);
\draw[Arrow] (work pain)--node[midway,above] {0.8} (9.8, -3);
\draw[Arrow] (depression)--node[midway, above] {0.3} (9.8, -4);
\end{tikzpicture}
\end{Verbatim}
\end{framed}
\bibliographystyle{plain}
\bibliography{bibliography.bib}
\end{document}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/arlionn/causalgraphs_latex.git
git@gitee.com:arlionn/causalgraphs_latex.git
arlionn
causalgraphs_latex
causalgraphs_latex
master

搜索帮助