knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
This document describes how the six causal mediation analysis approaches
including the regression-based approach by Valeri et al.
(2013) and
VanderWeele et al.
(2014), the
weighting-based approach by VanderWeele et al.
(2014), the
inverse odd-ratio weighting approach by Tchetgen Tchetgen
(2013), the
natural effect model by Vansteelandt et al.
(2012),
the marginal structural model by VanderWeele et al.
(2017), and
the $g$-formula approach by Robins
(1986)
are implemented by the CMAverse
package. See publications of these
approaches for methodological details.
CMAverse
currently supports a single exposure, multiple sequential
mediators and a single outcome. When multiple mediators are of interest,
CMAverse
estimates the joint mediated effect through the set of
mediators. CMAverse
also supports time varying confounders preceding
the mediators.
We categorize the causal mediation analysis approaches based on whether the approach can deal with mediator-outcome confounders affected by the exposure. Among the six approaches, only The marginal structural model and the $g$-formula approach are able to deal with mediator-outcome confounders affected by the exposure.
In this document, the outcome and the exposure are denoted as $Y$ and $A$ respectively. The set of exposure-mediator confounders, exposure-outcome confounders and mediator-outcome confounders not affected by the exposure is denoted as $C$. The set of mediators is denoted as $M$ and $M=(M_1,...,M_k)$ follows the temporal order. The set of mediator-outcome confounders affected by the exposure is denoted as $L$ and $L=(L_1,...,L_s)$ follows the temporal order.
Since weights calculated from noncategorical variables are unstable, which hurts the performance of effect estimation and inference, weighted approaches can be implemented only for categorical exposure and mediator(s).
library(dagitty) g1 <- dagitty( "dag { A -> Y A -> M -> Y C -> A C -> M C -> Y }") coordinates(g1) <- list(x=c(A=0,Y=4,M=2,C=0.2),y=c(A=0,Y=0,M=-0.8,C=-1)) plot(g1)
For a continuous outcome, causal effects are estimated on the difference scale (summarized in table 1). For a categorical, count, or survival outcome, causal effects are estimated on the ratio scale (summarized in table 2). See Valeri et al. (2013) and VanderWeele (2015) for details about these effects.
library(knitr) library(dplyr) library(kableExtra) tb1 <- data.frame(c("Controlled Direct Effect", "Pure Natural Direct Effect", "Total Natural Direct Effect", "Pure Natural Indirect Effect", "Total Natural Indirect Effect", "Total Effect", "Reference Interaction", "Mediated Interaction", "Proportion $CDE$", "Proportion $INT_{ref}$", "Proportion $INT_{med}$", "Proportion $PNIE$", "Proportion Mediated", "Proportion Attributable to Interaction", "Proportion Eliminated", "Residual Disparity", "Shifting Distribution Effect"), c("$CDE$", "$PNDE$", "$TNDE$", "$PNIE$", "$TNIE$", "$TE$", "$INT_{ref}$", "$INT_{med}$", "$prop^{CDE}$", "$prop^{INT_{ref}}$", "$prop^{INT_{med}}$", "$prop^{PNIE}$", "$PM$", "$INT$", "$PE$", "$RD$", "$SD$"), c("$E[Y_{am}-Y_{a^*m}]$", "$E[Y_{aM_a^*}-Y_{a^*M_a^*}]$", "$E[Y_{aM_a}-Y_{a^*M_a}]$", "$E[Y_{a^*M_a}-Y_{a^*M_a^*}]$", "$E[Y_{aM_a}-Y_{aM_a^*}]$", "$PNDE+TNIE$ or $TNDE+PNIE$", "$PNDE-CDE$", "$TNIE-PNIE$", "$CDE/TE$", "$INT_{ref}/TE$", "$INT_{med}/TE$", "$PNIE/TE$", "$TNIE/TE$", "$(INT_{ref}+INT_{med})/TE$", "$(INT_{ref}+INT_{med}+PNIE)/TE$", "$P(S_g>s|A=a,C) - P(S_g>s|A=a^*,C)$", "$P(S_{g'}>s|A=a,C) - P(S_g>s|A=a,C)$")) colnames(tb1) <- c("Full Name", "Abbreviation", "Formula") knitr::kable(tb1, escape = FALSE, caption = "Table 1: Causal Effects on the Difference Scale") %>% footnote(general = "$a$ and $a^*$ are the active and control values for $A$ respectively. $m$ is the value at which $M$ is controlled. $M_a$ denotes the counterfactual value of $M$ that would have been observed had $A$ been set to be $a$. $Y_{am}$ denotes the counterfactual value of $Y$ that would have been observed had $A$ been set to be $a$, and $M$ to be $m$. $Y_{aMa*}$ denotes the counterfactual value of $Y$ that would have been observed had $A$ been set to be $a$, and $M$ to be the counterfactual value $M_{a*}$.") %>% column_spec(1, width = "20em") %>% column_spec(2, width = "8em") %>% column_spec(3, width = "10em") %>% kable_styling(bootstrap_options = c("bordered", "striped", "hover", "responsive", "condensed"))
tb2 <- data.frame(c("Controlled Direct Effect", "Pure Natural Direct Effect", "Total Natural Direct Effect", "Pure Natural Indirect Effect", "Total Natural Indirect Effect", "Total Effect", "Excess Ratio due to Controlled Direct Effect", "Excess Ratio due to Reference Interaction", "Excess Ratio due to Mediated Interaction", "Excess Ratio due to Pure Natural Indirect Effect", "Proportion $ER^{CDE}$", "Proportion $ER^{INT_{ref}}$", "Proportion $ER^{INT_{med}}$", "Proportion $ER^{PNIE}$", "Proportion Mediated", "Proportion Attributable to Interaction", "Proportion Eliminated"), c("$R^{CDE}$", "$R^{PNDE}$", "$R^{TNDE}$", "$R^{PNIE}$", "$R^{TNIE}$", "$R^{TE}$", "$ER^{CDE}$", "$ER^{INT_{ref}}$", "$ER^{INT_{med}}$", "$ER^{PNIE}$", "$prop^{ER^{CDE}}$", "$prop^{ER^{INT_{ref}}}$", "$prop^{ER^{INT_{med}}}$", "$prop^{ER^{PNIE}}$", "$PM$", "$INT$", "$PE$"), c("$E[Y_{am}]/E[Y_{a^*m}]$", "$E[Y_{aM_a^*}]/E[Y_{a^*M_a^*}]$", "$E[Y_{aM_a}]/E[Y_{a^*M_a}]$", "$E[Y_{a^*M_a}]/E[Y_{a^*M_a^*}]$", "$E[Y_{aM_a}]/E[Y_{aM_a^*}]$", "$R^{PNDE}\\times R^{TNIE}$ or $R^{TNDE}\\times R^{PNIE}$", "$(E[Y_{am}-Y_{a^*m}])/E[Y_{a^*M_a^*}]$", "$R^{PNDE}-1-ER^{CDE}$", "$R^{TNIE}*R^{PNDE}-R^{PNDE}-R^{PNIE}+1$", "$R^{PNIE}-1$", "$ER^{CDE}/(R^{TE}-1)$", "$ER^{INT_{ref}}/(R^{TE}-1)$", "$ER^{INT_{med}}/(R^{TE}-1)$", "$ER^{PNIE}/(R^{TE}-1)$", "$(R^{PNDE}*(R^{TNIE}-1))/(R^{TE}-1)$", "$(ER^{INT_{ref}}+ER^{INT_{med}})/(R^{TE}-1)$", "$(ER^{INT_{ref}}+ER^{INT_{med}}+ER^{PNIE})/(R^{TE}-1)$")) colnames(tb2) <- c("Full Name", "Abbreviation", "Formula") knitr::kable(tb2, escape = FALSE, caption = "Table 2: Causal Effects on the Ratio Scale") %>% footnote(general = "$a$ and $a^*$ are the active and control values for $A$ respectively. $m$ is the value at which $M$ is controlled. $M_a$ denotes the counterfactual value of $M$ that would have been observed had $A$ been set to be $a$. $Y_{am}$ denotes the counterfactual value of $Y$ that would have been observed had $A$ been set to be $a$, and $M$ to be $m$. $Y_{aMa*}$ denotes the counterfactual value of $Y$ that would have been observed had $A$ been set to be $a$, and $M$ to be the counterfactual value $M_{a*}$. If $Y$ is categorical, $E[Y]$ represents the probability of $Y=y$ where $y$ is a pre-specified value of $Y$.") %>% column_spec(1, width = "20em") %>% column_spec(2, width = "8em") %>% column_spec(3, width = "10em") %>% kable_styling(bootstrap_options = c("bordered", "striped", "hover", "responsive"))
With the regression-based approach, all causal effects are estimated through either closed-form parameter function estimation or direct counterfactual imputation estimation. Standard errors of causal effects are estimated through either the delta method or bootstrapping.
Closed-form parameter function estimation is available when there is
only a single mediator, i.e., $M=M_1$. Also, yreg
must be chosen from
linear
, logistic
, loglinear
, poisson
, quasipoisson
, negbin
,
coxph
, aft_exp
and aft_weibull
. mreg
must be chosen from
linear
, logistic
and multinomial
. To use yreg = "logistic"
and
yreg = "coxph"
in closed-form parameter function estimation, the
outcome must be rare. Additionally, the causal effects estimated through
closed-form parameter function estimation are conditional on the value
of $C$ specified by the basecval
argument. Closed-form parameter
functions are summarized below.
yreg
, Linear mreg
and Noncategorical ExposureIf the exposure is not categorical, yreg="linear"
and
mreg=list("linear")
, CMAverse
estimates the causal effects by the
following steps:
Fit a linear regression model for the mediator: $$E[M|A,C]=\beta_0+\beta_1A+\beta_2'C$$
Fit a linear regression model for the outcome: $$E[Y|A,M,C]=\theta_0+\theta_1A+\theta_2M+\theta_3AM+\theta_4'C$$
Estimate $CDE$, $PNDE$, $TNDE$, $PNIE$ and $TNIE$ by the following parameter functions:
Calculate other effects using formulas in table 1.
yreg
, Linear mreg
and Categorical ExposureIf the exposure is categorical, yreg="linear"
and
mreg=list("linear")
, CMAverse
estimates the causal effects by the
following steps:
Fit a linear regression model for the mediator: $$E[M|A,C]=\beta_0+\sum_{h=1}^H\beta_{1h}I{A=h}+\beta_2'C$$
Fit a linear regression model for the outcome: $$E[Y|A,M,C]=\theta_0+\sum_{h=1}^H\theta_{1h}I{A=h}+\theta_2M+\sum_{h=1}^H\theta_{3h}I{A=h}M+\theta_4'C$$
Estimate $CDE$, $PNDE$, $TNDE$, $PNIE$ and $TNIE$ by the following parameter functions:
Calculate other effects using formulas in table 1.
yreg
, Logistic mreg
and Noncategorical ExposureIf the exposure is not categorical, yreg="linear"
and
mreg=list("logistic")
, CMAverse
estimates the causal effects by the
following steps:
Fit a logistic regression model for the mediator: $$logitE[M|A,C]=\beta_0+\beta_1A+\beta_2'C$$
Fit a linear regression model for the outcome: $$E[Y|A,M,C]=\theta_0+\theta_1A+\theta_2M+\theta_3AM+\theta_4'C$$
Estimate $CDE$, $PNDE$, $TNDE$, $PNIE$ and $TNIE$ by the following parameter functions:
Calculate other effects using formulas in table 1.
yreg
, Logistic mreg
and Categorical ExposureIf the exposure is categorical, yreg="linear"
and
mreg=list("logistic")
, CMAverse
estimates the causal effects by the
following steps:
Fit a logistic regression model for the mediator: $$logitE[M|A,C]=\beta_0+\sum_{h=1}^H\beta_{1h}I{A=h}+\beta_2'C$$
Fit a linear regression model for the outcome: $$E[Y|A,M,C]=\theta_0+\sum_{h=1}^H\theta_{1h}I{A=h}+\theta_2M+\sum_{h=1}^H\theta_{3h}I{A=h}M+\theta_4'C$$
Estimate $CDE$, $PNDE$, $TNDE$, $PNIE$ and $TNIE$ by the following parameter functions:
Calculate other effects using formulas in table 1.
yreg
, Multinomial mreg
and Noncategorical ExposureIf the exposure is not categorical, yreg="linear"
and
mreg=list("multinomial")
, CMAverse
estimates the causal effects by
the following steps:
Fit a multinomial regression model for the mediator: $$log\frac{E[M=j|A,C]}{E[M=0|A,C]}=\beta_{0j}+\beta_{1j}A+\beta_{2j}'C, j=1,2,...,J$$
Fit a linear regression model for the outcome: $$E[Y|A,M,C]=\theta_0+\theta_1A+\sum_{j=1}^J\theta_{2j}I{M=j}+A\sum_{j=1}^J\theta_{3j}I{M=j}+\theta_4'C$$
Estimate $CDE$, $PNDE$, $TNDE$, $PNIE$ and $TNIE$ by the following parameter functions:
Calculate other effects using formulas in table 1.
yreg
, Multinomial mreg
and Categorical ExposureIf the exposure is categorical, yreg="linear"
and
mreg=list("multinomial")
, CMAverse
estimates the causal effects by
the following steps:
Fit a multinomial regression model for the mediator: $$log\frac{E[M=j|A,C]}{E[M=0|A,C]}=\beta_{0j}+\sum_{h=1}^H\beta_{1jh}I{A=h}+\beta_{2j}'C, j=1,2,...,J$$
Fit a linear regression model for the outcome: $$E[Y|A,M,C]=\theta_0+\sum_{h=1}^H\theta_{1h}I{A=h}+\sum_{j=1}^J\theta_{2j}I{M=j}+\sum_{j=1}^J\sum_{h=1}^H\theta_{3jh}I{M=j}I{A=h}+\theta_4'C$$
Estimate $CDE$, $PNDE$, $TNDE$, $PNIE$ and $TNIE$ by the following parameter functions:
Calculate other effects using formulas in table 1.
yreg
, Linear mreg
and Noncategorical ExposureIf the exposure is not categorical, yreg!="linear"
and
mreg=list("linear")
, CMAverse
estimates the causal effects by the
following steps:
Fit a linear regression model for the mediator: $$E[M|A,C]=\beta_0+\beta_1A+\beta_2'C+\epsilon_M,\epsilon_M\sim N(0,\sigma^2)$$
Fit the specified regression model for the outcome: $$g(E[Y|A,M,C])=\theta_0+\theta_1A+\theta_2M+\theta_3AM+\theta_4'C$$
Estimate $R^{CDE}$, $R^{PNDE}$, $R^{TNDE}$, $R^{PNIE}$, $R^{TNIE}$ and $ER^{CDE}$ by the following parameter functions:
Calculate other effects using formulas in table 2.
yreg
, Linear mreg
and Categorical ExposureIf the exposure is categorical, yreg!="linear"
and
mreg=list("linear")
, CMAverse
estimates the causal effects by the
following steps:
Fit a linear regression model for the mediator: $$E[M|A,C]=\beta_0+\sum_{h=1}^H\beta_{1h}I{A=h}+\beta_2'C+\epsilon_M,\epsilon_M\sim N(0,\sigma^2)$$
Fit the specified regression model for the outcome: $$g(E[Y|A,M,C])=\theta_0+\sum_{h=1}^H\theta_{1h}I{A=h}+\theta_2M+\sum_{h=1}^H\theta_{3h}I{A=h}M+\theta_4'C$$
Estimate $R^{CDE}$, $R^{PNDE}$, $R^{TNDE}$, $R^{PNIE}$, $R^{TNIE}$ and $ER^{CDE}$ by the following parameter functions:
Calculate other effects using formulas in table 2.
yreg
, Logistic mreg
and Noncategorical ExposureIf the exposure is not categorical, yreg!="linear"
and
mreg=list("logistic")
, CMAverse
estimates the causal effects by the
following steps:
Fit a logistic regression model for the mediator: $$logitE[M|A,C]=\beta_0+\beta_1A+\beta_2'C$$
Fit the specified regression model for the outcome: $$g(E[Y|A,M,C])=\theta_0+\theta_1A+\theta_2M+\theta_3AM+\theta_4'C$$
Estimate $R^{CDE}$, $R^{PNDE}$, $R^{TNDE}$, $R^{PNIE}$, $R^{TNIE}$ and $ER^{CDE}$ by the following parameter functions:
Calculate other effects using formulas in table 2.
yreg
, Logistic mreg
and Categorical ExposureIf the exposure is categorical, yreg!="linear"
and
mreg=list("logistic")
, CMAverse
estimates the causal effects by the
following steps:
Fit a logistic regression model for the mediator: $$logitE[M|A,C]=\beta_0+\sum_{h=1}^H\beta_{1h}I{A=h}+\beta_2'C$$
Fit the specified regression model for the outcome: $$g(E[Y|A,M,C])=\theta_0+\sum_{h=1}^H\theta_{1h}I{A=h}+\theta_2M+\sum_{h=1}^H\theta_{3h}I{A=h}M+\theta_4'C$$
Estimate $R^{CDE}$, $R^{PNDE}$, $R^{TNDE}$, $R^{PNIE}$, $R^{TNIE}$ and $ER^{CDE}$ by the following parameter functions:
Calculate other effects using formulas in table 2.
yreg
, Multinomial mreg
and Noncategorical ExposureIf the exposure is not categorical, yreg!="linear"
and
mreg=list("multinomial")
, CMAverse
estimates the causal effects by
the following steps:
Fit a multinomial regression model for the mediator: $$log\frac{E[M=j|A,C]}{E[M=0|A,C]}=\beta_{0j}+\beta_{1j}A+\beta_{2j}'C, j=1,2,...,J$$
Fit the specified regression model for the outcome: $$g(E[Y|A,M,C])=\theta_0+\theta_1A+\sum_{j=1}^J\theta_{2j}I{M=j}+A\sum_{j=1}^J\theta_{3j}I{M=j}+\theta_4'C$$
Estimate $R^{CDE}$, $R^{PNDE}$, $R^{TNDE}$, $R^{PNIE}$, $R^{TNIE}$ and $ER^{CDE}$ by the following parameter functions:
Calculate other effects using formulas in table 2.
yreg
, Multinomial mreg
and Categorical ExposureIf the exposure is categorical, yreg!="linear"
and
mreg=list("multinomial")
, CMAverse
estimates the causal effects by
the following steps:
Fit a multinomial regression model for the mediator: $$log\frac{E[M=j|A,C]}{E[M=0|A,C]}=\beta_{0j}+\sum_{h=1}^H\beta_{1jh}I{A=h}+\beta_{2j}'C, j=1,2,...,J$$
Fit the specified regression model for the outcome: $$g(E[Y|A,M,C])=\theta_0+\sum_{h=1}^H\theta_{1h}I{A=h}+\sum_{j=1}^J\theta_{2j}I{M=j}+\sum_{j=1}^J\sum_{h=1}^H\theta_{3jh}I{M=j}I{A=h}+\theta_4'C$$
Estimate $R^{CDE}$, $R^{PNDE}$, $R^{TNDE}$, $R^{PNIE}$, $R^{TNIE}$ and $ER^{CDE}$ by the following parameter functions:
Calculate other effects using formulas in table 2.
CMAverse
conducts direct counterfactual imputation estimation by the
following steps:
Fit a regression model for $E(Y|A,M,C)$. This regression model is
specified by the yreg
argument.
For $p=1,...,k$, fit a regression model for the distribution of
$M_p$ given $A$ and $C$. These regression models are specified by
the mreg
argument.
For $p=1,...,k$ and $i=1,...,n$, simulate the counterfactuals $M_{a,p,i}$ and $M_{a^*,p,i}$.
For $i=1,...,n$, obtain $E[Y_i|A=a^,M=m,C=C_i]$, $E[Y_i|A=a,M=m,C=C_i]$, $E[Y_i|A=a^,M=M_{a^,i},C=C_i]$, $E[Y_i|A=a^,M=M_{a,i},C=C_i]$, $E[Y_i|A=a,M=M_{a^*,i},C=C_i]$ and $E[Y_i|A=a,M=M_{a,i},C=C_i]$ from the regression model in step 1.
Impute the counterfactuals $E[Y_{a^m}]$, $E[Y_{am}]$, $E[Y_{a^Ma^}]$, $E[Y_{aMa}]$, $E[Y_{aMa^}]$ and $E[Y_{a^*Ma}]$.
Calculate causal effects with formulas in table 1 or table 2.
With the weighting-based approach, CMAverse
estimates causal effects
through direct counterfactual imputation estimation by the following
steps:
Fit a regression model for the distribution of $E(Y|A,M,C)$. This
regression model is specified by the yreg
argument.
If $C$ is not empty, fit a regression model for $P(A|C)$ and obtain
$P(A=A_i|C=C_i)$ for $i=1,...,n$. This regression model is specified
by the ereg
argument.
For $i=1,...,n$, obtain $E[Y_i|A=a^,M=m,C=C_i]$, $E[Y_i|A=a,M=m,C=C_i]$, $E[Y_i|A=a^,M=M_i,C=C_i]$ and $E[Y_i|A=a,M=M_i,C=C_i]$ from the regression model in step 1.
Impute the counterfactuals $E[Y_{a^m}]$, $E[Y_{am}]$, $E[Y_{a^Ma^}]$, $E[Y_{aMa}]$, $E[Y_{aMa^}]$ and $E[Y_{a^*Ma}]$.
Calculate causal effects with formulas in table 1 or table 2.
With the inverse odds ratio weighting approach, CMAverse
estimates
causal effects through direct counterfactual imputation estimation by
the following steps:
Fit a regression model for $P(A|M,C)$ and obtain
$\frac{P(A=0|M=M_i,C=C_i)}{P(A=A_i|M=M_i,C=C_i)}$ for $i=1,...,n$.
This regression model is specified by the ereg
argument.
Fit a regression model for $E(Y|A,C)$. This regression model is
specified by the yreg
argument.
Fit a weighted regression model for $E(Y|A,C)$ and each subject $i$ is given a weight $\frac{P(A=0|M=M_i,C=C_i)}{P(A=A_i|M=M_i,C=C_i)}$. This regression model is obtained by adding the weights to the regression model in step 2.
Impute the counterfactuals $E_{tot}[Y_{a}]$, $E_{tot}[Y_{a^}]$, $E_{dir}[Y_{a}]$ and $E_{dir}[Y_{a^}]$.
With the natural effect model, CMAverse
estimates causal effects
through direct counterfactual imputation estimation by the following
steps:
Fit a regression model for $E(Y|A,M,C)$. This regression model is
specified by the yreg
argument.
Expand the dataset using the regression model in step 1 and the
neImpute
function in the medflex
package. The expanded dataset
gives $A0$ for the direct effect and $A1$ for the indirect effect.
Fit the regression model in step 1 by the expanded dataset in step 2 with the exposure in the regression formula replaced by $A0$ and mediators in the regression formula replaced by $A1$, i.e., $Y\sim A0+A1+A0A1+C$ if the regression formula in step 1 is $Y\sim A+M_1+M_2+AM_1+C$.
For $i=1,...,n$, obtain $E[Y_i|A=a^,M=m,C=C_i]$ and $E[Y_i|A=a,M=m,C=C_i]$ from the regression model in step 1; obtain $E[Y_i|A0=a^,A1=a^,C=C_i]$, $E[Y_i|A0=a^,A1=a,C=C_i]$, $E[Y_i|A0=a,A1=a^*,C=C_i]$ and $E[Y_i|A0=a,A1=a,C=C_i]$ from the regression model in step 3.
Impute the counterfactuals $E[Y_{a^m}]$, $E[Y_{am}]$, $E[Y_{a^Ma^}]$, $E[Y_{aMa}]$, $E[Y_{aMa^}]$ and $E[Y_{a^*Ma}]$.
Calculate causal effects with formulas in table 1 or table 2.
g2 <- dagitty::dagitty( "dag { A -> Y A -> M -> Y C -> A C -> M C -> Y A -> L L -> Y L -> M C -> L }") dagitty::coordinates(g2) <- list(x=c(A=0,Y=4,M=2,C=0.2,L=2),y=c(A=0,Y=0,M=-0.8,C=-1,L=0.5)) plot(g2)
For a continuous outcome, causal effects are estimated on the difference scale (summarized in table 3). For a categorical, count, or survival outcome, causal effects are estimated on the ratio scale (summarized in table 4). Because of the existence of $L$, some causal effects in table 1 and table 2 are not identifiable. However, their randomized analogues are still identifiable. See VanderWeele et al. (2014) for details about randomized analogues of causal effects.
library(knitr) library(dplyr) library(kableExtra) tb3 <- data.frame(c("Controlled Direct Effect", "Randomized Analogue of $PNDE$", "Randomized Analogue of $TNDE$", "Randomized Analogue of $PNIE$", "Randomized Analogue of $TNIE$", "Total Effect", "Randomized Analogue of $INT_{ref}$", "Randomized Analogue of $INT_{med}$", "Proportion $CDE$", "Proportion $rINT_{ref}$", "Proportion $rINT_{med}$", "Proportion $rPNIE$", "Randomized Analogue of $PM$", "Randomized Analogue of $INT$", "Randomized Analogue of $PE$"), c("$CDE$", "$rPNDE$", "$rTNDE$", "$rPNIE$", "$rTNIE$", "$TE$", "$rINT_{ref}$", "$rINT_{med}$", "$prop^{CDE}$", "$prop^{rINT_{ref}}$", "$prop^{rINT_{med}}$", "$prop^{rPNIE}$", "$rPM$", "$rINT$", "$rPE$"), c("$E[Y_{am}-Y_{a^*m}]$", "$E[Y_{aG_{a^*}}-Y_{a^*G_{a^*}}]$", "$E[Y_{aG_{a}}-Y_{a^*G_{a}}]$", "$E[Y_{a^*G_{a}}-Y_{a^*G_{a^*}}]$", "$E[Y_{aG_{a}}-Y_{aG_{a^*}}]$", "$rPNDE+rTNIE$ or $rTNDE+rPNIE$", "$rPNDE-CDE$", "$rTNIE-rPNIE$", "$CDE/TE$", "$rINT_{ref}/TE$", "$rINT_{med}/TE$", "$rPNIE/TE$", "$rTNIE/TE$", "$(rINT_{ref}+rINT_{med})/TE$", "$(rINT_{ref}+rINT_{med}+rPNIE)/TE$")) colnames(tb3) <- c("Full Name", "Abbreviation", "Formula") knitr::kable(tb3, escape = FALSE, caption = "Table 3: Causal Effects on the Difference Scale") %>% footnote(general = "$a$ and $a^*$ are the active and control values for $A$. $m$ is the value at which $M$ is controlled. $G_{a}$ denotes a random draw from the distribution of $M$ had $A=a$. $Y_{am}$ denotes the counterfactual value of $Y$ that would have been observed had $A$ been set to be $a$, and $M$ to be $m$. $Y_{aG_{a*}}$ denotes the counterfactual value of $Y$ that would have been observed had $A$ been set to be $a$, and $M$ to be the counterfactual value $G_{a*}$.") %>% column_spec(1, width = "20em") %>% column_spec(2, width = "8em") %>% column_spec(3, width = "10em") %>% kable_styling(bootstrap_options = c("bordered", "striped", "hover", "responsive", "condensed"))
tb4 <- data.frame(c("Controlled Direct Effect", "Randomized Analogue of $PNDE$", "Randomized Analogue of $TNDE$", "Randomized Analogue of $PNIE$", "Randomized Analogue of $TNIE$", "Total Effect", "Excess Ratio due to Controlled Direct Effect", "Randomized Analogue of $ER^{INT_{ref}}$", "Randomized Analogue of $ER^{INT_{med}}$", "Randomized Analogue of $ER^{PNIE}$", "Proportion $ER^{CDE}$", "Proportion $rER^{INT_{ref}}$", "Proportion $rER^{INT_{med}}$", "Proportion $rER^{PNIE}$", "Randomized Analogue of $PM$", "Randomized Analogue of $INT$", "Randomized Analogue of $PE$"), c("$R^{CDE}$", "$rR^{PNDE}$", "$rR^{TNDE}$", "$rR^{PNIE}$", "$rR^{TNIE}$", "$R^{TE}$", "$ER^{CDE}$", "$rER^{INT_{ref}}$", "$rER^{INT_{med}}$", "$rER^{PNIE}$", "$prop^{ER^{CDE}}$", "$prop^{rER^{INT_{ref}}}$", "$prop^{rER^{INT_{med}}}$", "$prop^{rER^{PNIE}}$", "$rPM$", "$rINT$", "$rPE$"), c("$E[Y_{am}]/E[Y_{a^*m}]$", "$E[Y_{aG_{a^*}}]/E[Y_{a^*G_{a^*}}]$", "$E[Y_{aG_{a}}]/E[Y_{a^*G_{a}}]$", "$E[Y_{a^*G_{a}}]/E[Y_{a^*G_{a^*}}]$", "$E[Y_{aG_{a}}]/E[Y_{aG_{a^*}}]$", "$rR^{PNDE}\\times rR^{TNIE}$ or $rR^{TNDE}\\times rR^{PNIE}$", "$(E[Y_{am}-Y_{a^*m}])/E[Y_{a^*M_a^*}]$", "$rR^{PNDE}-1-ER^{CDE}$", "$rR^{TNIE}*rR^{PNDE}-rR^{PNDE}-rR^{PNIE}+1$", "$rR^{PNIE}-1$", "$ER^{CDE}/(rR^{TE}-1)$", "$rER^{INT_{ref}}/(R^{TE}-1)$", "$rER^{INT_{med}}/(R^{TE}-1)$", "$rER^{PNIE}/(R^{TE}-1)$", "$(rR^{PNDE}*(rR^{TNIE}-1))/(R^{TE}-1)$", "$(rER^{INT_{ref}}+rER^{INT_{med}})/(R^{TE}-1)$", "$(rER^{INT_{ref}}+rER^{INT_{med}}+rER^{PNIE})/(R^{TE}-1)$")) colnames(tb4) <- c("Full Name", "Abbreviation", "Formula") knitr::kable(tb4, escape = FALSE, caption = "Table 4: Causal Effects on the Ratio Scale") %>% footnote(general = "$a$ and $a^*$ are the active and control values for $A$. $m$ is the value at which $M$ is controlled. $G_{a}$ denotes a random draw from the distribution of $M$ among those with $A=a$. $Y_{am}$ denotes the counterfactual value of $Y$ that would have been observed had $A$ been set to be $a$, and $M$ to be $m$. $Y_{aG_{a*}}$ denotes the counterfactual value of $Y$ that would have been observed had $A$ been set to be $a$, and $M$ to be the counterfactual value $G_{a*}$. If $Y$ is categorical, $E[Y]$ represents the probability of $Y=y$ where $y$ is a pre-specified value of $Y$.") %>% column_spec(1, width = "20em") %>% column_spec(2, width = "8em") %>% column_spec(3, width = "10em") %>% kable_styling(bootstrap_options = c("bordered", "striped", "hover", "responsive"))
With the marginal structural model, CMAverse
estimates causal effects
through direct counterfactual imputation estimation by the following
steps:
For $p=1,...,k$, fit the regression model specified by wmnomreg[p]
for $P(M_p|A,M_1, ...,M_{p-1})$ and obtain
$P(M_p=M_{p,i}|A=A_i,M_1=M_{1,i},...,M_{p-1}=M_{p-1,i})$ for
$i=1,...,n$.
For $p=1,...,k$, fit the regression model specified by
wmdenomreg[p]
for $P(M_p|A,M_1, ...,M_{p-1},L,C)$ and obtain
$P(M_p=M_{p,i}|A=A_i,M_1=M_{1,i},...,M_{p-1}=M_{p-1,i},L=L_i,C=C_i)$
for $i=1,...,n$.
If $C$ is not empty, fit the regression model specified by ereg
for $P(A|C)$ and obtain $P(A=A_i|C=C_i)$ for $i=1,...,n$.
Add weights to the regression model specified by yreg
for
$E(Y|A,M)$ and each subject $i,i=1,...,n$ is given a weight
$\frac{P(A=A_i)}{P(A=A_i|C=C_i)}\frac{P(M_1=M_{1,i}|A=A_i)}{P(M_1=M_{1,i}|A=A_i,C=C_i,L=L_i)}...\frac{P(M_k=M_{k,i}|A=A_i,M_1=M_{1,i},...,M_{k-1}=M_{k-1,i})}{P(M_k=M_{k,i}|A=A_i,M_1=M_{1,i},...,M_{k-1}=M_{k-1,i},C=C_i,L=L_i)}$.
For $p=1,...,k$, add weights to the regression model specified by
mreg[p]
for the distribution of $M_p$ given $A$ and each subject
$i,i=1,...,n$ is given a weight $\frac{P(A=A_i)}{P(A=A_i|C=C_i)}$.
For $p=1,...,k$ and $i=1,...,n$, simulate the counterfactuals $M_{a,p,i}$ and $M_{a^*,p,i}$ from the regression models in step 5.
For $i=1,...,n$, obtain $E[Y_i|A=a^,M=m]$, $E[Y_i|A=a,M=m]$, $E[Y_i|A=a^,M=M_{a^,i}]$, $E[Y_i|A=a^,M=M_{a,i}]$, $E[Y_i|A=a,M=M_{a^*,i}]$ and $E[Y_i|A=a,M=M_{a,i}]$ from the regression model in step 4.
Impute the counterfactuals $E[Y_{a^m}]$, $E[Y_{am}]$, $E[Y_{a^Ga^}]$, $E[Y_{aGa}]$, $E[Y_{aGa^}]$ and $E[Y_{a^*Ga}]$.
each subject $i,i=1,...,n$ is given a weight $\frac{P(A=A_i)}{P(A=A_i|C=C_i)}\frac{P(M_1=M_{1,i}|A=A_i)}{P(M_1=M_{1,i}|A=A_i,C=C_i,L=L_i)}...\frac{P(M_k=M_{k,i}|A=A_i,M_1=M_{1,i},...,M_{k-1}=M_{k-1,i})}{P(M_k=M_{k,i}|A=A_i,M_1=M_{1,i},...,M_{k-1}=M_{k-1,i},C=C_i,L=L_i)}$.
Calculate causal effects with formulas in table 3 or table 4.
With the $g$-formula approach, CMAverse
estimates causal effects
through direct counterfactual imputation estimation by the following
steps:
For $q=1,...,s$, fit the regression model specified by postcreg[q]
for the distribution of $L_q$ given $A$ and $C$.
For $q=1,...,s$ and $i=1,...,n$, simulate the counterfactuals $L_{a,q,i}$ and $L_{a^*,q,i}$ from the regression models in step 1.
For $p=1,...,k$, fit the regression model specified by mreg[p]
for
the distribution of $M_p$ given $A$, $L$ and $C$.
For $p=1,...,k$ and $i=1,...,n$, simulate the counterfactuals $M_{a,p,i}$ and $M_{a^*,p,i}$ from the regression models in step 3.
Obtain ${G_{a,i}}{i=1,...,n}$ by randomly permuting ${M{a,i}}{i=1,...,n}$ and obtain ${G{a^,i}}{i=1,...,n}$ by randomly permuting ${M{a^,i}}_{i=1,...,n}$.
Fit the regression model specified by yreg
for $E(Y|A,M,L,C)$.
For $i=1,...,n$, obtain $E[Y_i|A=a^,M=m,L=L_{a^,i},C=C_i]$, $E[Y_i|A=a,M=m,L=L_{a,i},C=C_i]$, $E[Y_i|A=a^,M=G_{a^,i},L=L_{a^,i},C=C_i]$, $E[Y_i|A=a^,M=G_{a,i},L=L_{a^,i},C=C_i]$, $E[Y_i|A=a,M=G_{a^,i},L=L_{a,i},C=C_i]$ and $E[Y_i|A=a,M=G_{a,i},L=L_{a,i},C=C_i]$ from the regression model in step 5.
Impute the counterfactuals $E[Y_{a^m}]$, $E[Y_{am}]$, $E[Y_{a^Ga^}]$, $E[Y_{aGa}]$, $E[Y_{aGa^}]$ and $E[Y_{a^*Ga}]$.
Calculate causal effects with formulas in table 3 or table 4.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.