Description Usage Arguments Note References
Mediation analysis for time varying mediator, estimation based on g-formula. Output contains total effect, #' natrual direct effect and natural indirect effect for mediation or regular g-formula. data.frame will be returned.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
data |
Data set to be sued |
id.var |
ID variable per subject. |
base.vars |
A vector of time fixed baseline variables. |
exposure |
Intervention/Exposure variable |
outcome |
Name of the outcome variable. |
time.var |
Time variable. |
models |
A list of models for the G-formula, including exposure model,
covariate model (if any), mediator model (if any), outcome model or
censoring model (if any). See details in |
intervention |
A named list with a value of intervention on exposure. if kept as NULL (default), the natrual intervention cousre will be calculated. eg: list(natural = NULL, always = 1, never = 0) |
init.recode |
optional, recoding of variables done at the begaining of the Monte Carlo loop. Needed for operations initalize baseline variables. This is executed at begaining of the Monte Carlo g-formula, excuted only once at time 0. |
in.recode |
optional, On the fly recoding of variables done before the Monte Carlo loop starts. Needed to do any kind of functional forms for entry times. This is executed at each start of the Monte Carlo g-formula time steps |
out.recode |
optional, On the fly recoding of variables done at the end of the Monte Carlo loop. Needed for operations like counting the number of days with a treatment or creating lagged variables. This is executed at each end of the Monte Carlo g-formula time steps. @param is.survival Is the data survival data, defalt is FALSE. |
mc.sample |
Sample size of Monte Carlo simulation. |
verbose |
Print intervention information during calculation. |
Not that final outcome must be the same for in all rows per subject. If the dataset is survival settings, records after the interested outcome must be deleted. The funciton it self do some data manupilation internally. Please prepare the data as longitudinal format.
Lin, S. H., Young, J. G., Logan, R., & VanderWeele, T. J. (2017). Mediation analysis for a survival outcome with timeâvarying exposures, mediators, and confounders. Statistics in medicine, 36(26), 4153-4166. DOI:10.1002/sim.7426 Zheng, W., & van der Laan, M. (2017). Longitudinal mediation analysis with time-varying mediators and exposures, with application to survival outcomes. Journal of causal inference, 5(2). DOI:10.1515/jci-2016-0006
TODO: weights, time varying intervention
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.