Description Usage Arguments Note Author(s) References Examples
This function calculates the Controlled Direct Effect (CDE) for continuous outcomes as described in the publication of Valeri and VanderWeele (2013, doi: 10.1037/a0031034).
1 | CDE_cont(thetas, treatment, mediator, m = 0, a_old = 1, a_new = 0)
|
thetas |
The coefficients of the regression on the outcome variable. |
treatment |
The column name in the dataframe which contains the treatment values. |
mediator |
The column name in the dataframe which contains the mediator values. |
m |
The value of the mediator at which to evaluate the result. Default = 0. |
a_old |
The old value of the treatment at which to evaluate the result (a in the publication of Valeri and VanderWeele). Default = 1. |
a_new |
The new value of the treatment at which to evaluate the result (a* in the publication of Valeri and VanderWeele). Default = 0. |
This package is under continuous (but perhaps slow) development. Users are welcome to contribute to the development.
Egge van der Poel (e.vanderpoel@erasmusmc.nl).
Valeri and VanderWeele (2013, doi: 10.1037/a0031034).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | df <- data.frame('smoking' = c(0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0),
'lbw' = c(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0),
'death' = c(0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
'drinking' = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0),
'agebelow20' = c(0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
)
betas <- c('(Intercept)' = -2.4916567, 'smoking' = 0.4905681, 'drinking' = -0.5967808,
'agebelow20' = 0.2305012)
thetas <- c('(Intercept)' = -6.5108483, 'smoking' = 0.5290551, 'lbw' = 3.5778582,
'drinking' = -0.3125368, 'agebelow20' = 0.2668849, 'smoking:lbw' = -0.5336013)
outcome='death'
treatment='smoking'
mediator='lbw'
covariates=c('drinking', 'agebelow20')
CDE_cont(thetas = thetas, treatment = treatment, mediator = mediator)
## The function is currently defined as
function (thetas, treatment, mediator, m = 0, a_old = 1, a_new = 0)
{
interactionTerm <- ifelse(is.na(thetas[paste(treatment, mediator,
sep = ":")]), 0, thetas[paste(treatment, mediator, sep = ":")])
cde <- (thetas[treatment] + interactionTerm * m) * (a_old -
a_new)
unname(cde)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.