Skip to content

Commit

Permalink
Addedd binary outcomes and NDE and NIE
Browse files Browse the repository at this point in the history
  • Loading branch information
omarsilverman committed May 28, 2024
1 parent 881878c commit 01fc171
Showing 1 changed file with 89 additions and 29 deletions.
118 changes: 89 additions & 29 deletions sessions/causal-mediation-analysis-sensitivity-analysis.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,10 @@ covariables *C* obtained from a logistic regression model.
The bias factor is defined as **B~*mult*~(*c*)** on the multiplicative
scale as the ratio of:

1- the risk ratio (or odds ratio, with a **rare outcome**) comparing *A*
1- The risk ratio (or odds ratio, with a **rare outcome**) comparing *A*
= *a* and *A* = *a*^\*^ conditional on covariables *C*= *c* and

2- what we would have obtained as the risk ratio (or odds ratio) had we
2- What we would have obtained as the risk ratio (or odds ratio) had we
been able to condition on both C and U.

We now make the simplifying assumptions that **(A8.1.3)** *U* is binary
Expand All @@ -216,11 +216,11 @@ the same for those with exposure level *A* = *a* and exposure level *A*
If these assumptions hold, we will let *γ* be the effect of *U* on *Y*
conditional on *A* and *C* on the risk ratio scale, that is:

$\frac{γ = P(Y = 1\|a, c,U = 1)}{P(Y = 1\|a, c,U = 0)}$
$γ = \frac{ P(Y = 1\|a, c,U = 1)}{P(Y = 1\|a, c,U = 0)}$

By assumption **(A8.1.2b)**

$\frac{γ = P(Y=1\|a,c,U=1)}{P(Y=1\|a,c,U=0)}$
$γ = \frac{P(Y=1\|a,c,U=1)}{P(Y=1\|a,c,U=0)}$

is the same for both levels of the exposure.

Expand All @@ -237,19 +237,19 @@ We can use the bias formula by specifying the effect of *U* on *Y* on
the risk ratio scale and the prevalence of *U* among those with exposure
levels *A* = *a* and *A* = *a*^\*^.

Once we have calculated the bias term B\~*mult\~*(*c*), we can estimate
our risk ratio controlling only for *C* (if the outcome is rare, fit a
logistic regression) and we divide our estimate by B~mult~(*c*) to get
the corrected estimate for risk ratio—that is, what we would have
obtained if we had adjusted for *U* as well.
Once we have calculated the bias term **B~*mult*~(*c*)**, we can
estimate our risk ratio controlling only for *C* (if the outcome is
rare, fit a logistic regression) and we divide our estimate by
**B~*mult*~(*c*)** to get the corrected estimate for risk ratio—that is,
what we would have obtained if we had adjusted for *U* as well.

Under the simplifying assumptions of (A8.1.1) and (A8.1.2b), we can also
obtain corrected confidence intervals by dividing both limits of the
confidence interval by B\~*mult\~*(*c*).
confidence interval by **B~*mult*~(*c*)**.

Note that to use the bias factor in (8.2), we must specify the
prevalence of the unmeasured confounder in both exposure groups *P*(*U*
= 1\|*a*, *c*) and *P*(*U* = 1\|*a*^\*^, *c*), not just the difference
prevalence of the unmeasured confounder in both exposure groups *P*(*U*=
1\|*a*, *c*) and *P*(*U* = 1\|*a*^\*^, *c*), not just the difference
between these two prevalences as in (8.1) for outcomes on the additive
scale.

Expand All @@ -261,7 +261,9 @@ explain away an effect and also
2- the sensitivity analysis parameters that would be required to shift
the confidence interval to just include the null.

## Sensitivity analysis for controled direct effects for a continuous outcome
## Sensitivity analysis for controled direct effects

### Continuous outcomes

Assume that controlling for (*C,U*) would suffice to control for
exposure--outcome and mediator--outcome confounding but that no data are
Expand Down Expand Up @@ -299,7 +301,7 @@ If we have not adjusted for *U*, then our estimates controlling only for
We will consider estimating the controlled direct effect, *CDE*(*m*),
with the mediator fixed to *m* conditional on the covariables *C* = *c*.

Let \*B\^{CDE}\_{add}*(*m*\|*c\*) denote the difference between:
Let $B^{CDE}_{add}(m|c)$ denote the difference between:

1- the estimate of the *CDE* conditional on *C*

Expand Down Expand Up @@ -332,11 +334,11 @@ Under assumptions (A8.1.1) and (A8.2.2b), the bias factor is simply
given by the product of these two sensitivity-analysis parameters
(VanderWeele, 2010a):

\*B\^{CDE}\_{add}*(*m*\|*c*) =* δmγm\*
$B^{CDE}_{add}(m|c) = δmγm$ **8.3**

This formula states that under assumptions (A8.1.1) and (A8.2.2b) the
bias factor B\^{CDE}\_{add}(*m*\|*c*) for the *CDE*(*m*) is simply given
by the product *δmγm*.
bias factor $B^{CDE}_{add}(m|c)$ for the *CDE*(*m*) is simply given by
the product *δmγm*.

Under these simplifying assumptions, this gives rise to a particularly
simple sensitivity analysis technique for assessing the sensitivity of
Expand All @@ -359,10 +361,9 @@ on *Y*) and by varying *δm*, interpreted as the prevalence difference of
*U*, comparing exposure levels *a* and *a*^\*^ conditional on *M* = *m*
and *C* = *c*.

We can subtract the bias factor \*B\^{CDE}\_{add}*(*m*\|*c*) =* δmγm\*
from the observed estimate to obtain a corrected estimate of the effect
(what we would have obtained had it been possible to adjust for *U* as
well).
We can subtract the bias factor $B^{CDE}_{add}(m|c)$ from the observed
estimate to obtain a corrected estimate of the effect (what we would
have obtained had it been possible to adjust for *U* as well).

Under the simplifying assumptions (A8.1.1) and (A8.2.2b), we could also
subtract this bias factor from both limits of a confidence interval to
Expand All @@ -376,6 +377,54 @@ If there is no interaction between the effects of *A* and *M* on *Y*,
then this simple sensitivity analysis technique based on using formula
above will also be applicable to natural direct effects as well.

### Binary outcomes

We will consider estimating the controlled direct effect odds ratio from
Chapter 2, $OR^{CDE}(m)$, with the mediator fixed at level *m*,
conditional on the covariates *C* = *c*.

This approach will assume a rare outcome but can also be used for risk
ratios with a common outcome. Let $B^{CDE}_{mult}(m|c)$ denote the ratio
of

1- The estimate of the controlled direct effect conditional on *C* (

2- What would have been obtained had adjustment been made for *U* as
well.

Suppose that (A8.1.1) *U* is binary and that (A8.1.2d) the effect of *U*
on *Y* on the ratio scale, conditional on exposure, mediator, and
covariables (*A,M,C*), is the same for both exposure levels *A = a* and
*a*^\*^.

Let *γm* be the effect of *U* on *Y* conditional on *A, C*, and *M = m*,
that is:

$γm = \frac{P(Y = 1|a, c,m,U = 1)}{P(Y = 1|a, c,m,U = 0)}$

Note that by (A8.1.2), *γm* is the same for both levels of the exposure
of interest.

Under assumptions (A8.1.1) and (A8.1.2d), the bias factor on the
multiplicative scale is given by:

$B^{CDE}_{mult}(m|c) = \frac{1+(γm −1)P(U= 1|a,m, c)}{1+(γm−1)P(U = 1\|a∗,m, c)}$
**(8.4)**

Once we have calculated the bias term $B^{CDE}_{mult}(m|c)$, we can
estimate the *CDE* risk ratio controlling only for *C* (if the outcome
is rare), we fit a logistic regression) and we divide our estimate and
confidence intervals by the bias factor $B^{CDE}_{mult}(m|c)$ to get the
corrected estimate for CDE risk ratio and its confidence interval—that
is, what we would have obtained if we had adjusted for *U* a well.

We have to specify the two prevalences of U, namely $P(U = 1|a,m, c)$
and $P(U = 1|a∗,m, c)$, in the different exposure groups conditional on
*M* and *C*.

As with *CDE* on an additive scale, the issue of conditioning on *M* in
the interpretation of these prevalences is important

## Sensitivity analysis for natural direct and indirect effects

### Sensitivity analysis for natural direct and indirect effects in the abscence of exposure-mediator interaction
Expand Down Expand Up @@ -429,24 +478,35 @@ Because a mediator--outcome confounder does not confound the
exposure-outcome relationship, we can still obtain valid estimates of
the total effect.

And, it turns out that the combination of the DE and IE do constitute a
consistent estimator of the total effect, even though the *DE* and *IE*
estimators will themselves be biased for the true *NDE* and *NIE*.
And, it turns out that the combination of the *DE* and *IE* do
constitute a consistent estimator of the total effect, even though the
*DE* and *IE* estimators will themselves be biased for the true *NDE*
and *NIE*.

Knowing that the DE and IE estimates combine to a valid estimate of the
total effect then allows us to employ the sensitivity analysis
Knowing that the *DE* and *IE* estimates combine to a valid estimate of
the total effect then allows us to employ the sensitivity analysis
techniques for *CDE* for *NIE* as well.

To do so, we use the negation (on the additive scale) of the bias
formulas that we used for *CDE* (and *NDE*). Thus on the additive scale,
for a continuous outcome, our bias factor for the *NDE* would simply be:
To do so, we use the negation (on the additive scale) or the inverse (on
the multiplicative ratio scale) of the bias formulas used for *CDE* (and
*NDE*). Thus on the additive scale, for a continuous outcome, our bias
factor for the *NDE* would simply be:

*δmγm*

and we could subtract this from the estimate and both limits of the
confidence interval to obtain a corrected estimate and confidence
interval for the *NIE*.

For a binary outcome, on the odds ratio scale with rare outcome or risk
ratio scale with common outcome, our bias factor for the *NIE* would be
the inverse of that in **(8.4)**:

$\frac{1+(γm−1)P(U=1|a∗,m,c)}{1+(γm−1)P(U=1|a,m,c)}$

and we could divide our *NIE* estimates and its confidence interval by
this bias factor to obtain a corrected estimate and confidence interval.

We first load the nhanes data:

```{r}
Expand Down

0 comments on commit 01fc171

Please sign in to comment.