-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
613c49b
commit 4b831ca
Showing
3 changed files
with
104 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# Day 2: Group work | ||
|
||
::: callout-note | ||
## Objective of this session | ||
|
||
In this session, We will get hands on practice using the Framingham | ||
dataset. You will conduct a causal mediation analysis, considering: | ||
|
||
- Conduct causal mediation analyses with exposure induced | ||
mediator-outcome confounder or multiple mediators | ||
- Conduct sensitivity analyses | ||
- Report the results following the guidelines | ||
::: | ||
|
||
We will continue working with the obesity and cardiovascular disease | ||
example. | ||
|
||
First, reflect on the group work from yesterday and discuss the | ||
following questions with your group members: | ||
|
||
- Review the assumptions of causal mediation, and discuss the | ||
robustness of your estimates | ||
- Are there other mediators than systolic blood pressure? | ||
- Are there interactions between obesity and the mediators? | ||
|
||
Re-conduct the mediation analysis and address the discussion points. You | ||
can either use the **mediation** package or **CMAverse** package. | ||
|
||
1. Re-do the DAG, and investigate the potential pathways | ||
|
||
2. Perform a causal mediation analysis | ||
|
||
Load data: | ||
|
||
```{r setup} | ||
library(here) | ||
library(tidyverse) | ||
load(here::here("data/frmghamdata.RData")) | ||
``` | ||
|
||
Clean the data: | ||
|
||
```{r} | ||
frmgham_clean <- frmgham %>% | ||
select( | ||
id = randid, | ||
w1 = sex, | ||
w2 = age, | ||
w3 = cursmoke, | ||
w4 = educ, | ||
a = bmi, # this is the exposure | ||
m = sysbp, # this is the mediator | ||
y = cvd # this is the outcome | ||
) %>% | ||
na.omit() | ||
frmgham_clean <- frmgham_clean %>% | ||
mutate(a = case_when(a >= 30 ~ 1, | ||
TRUE ~ 0)) | ||
``` | ||
|
||
Do causal mediation analysis: | ||
|
||
```{r} | ||
library(CMAverse) | ||
res_rb <- cmest( | ||
data = frmgham_clean, model = "rb", outcome = "y", exposure = "a", | ||
mediator = "m", basec = c("w1", "w2", "w3", "w4"), EMint = TRUE, | ||
mreg = list("linear"), yreg = "logistic", | ||
astar = 0, a = 1, mval = list(120), | ||
estimation = "paramfunc", inference = "delta" | ||
) | ||
summary(res_rb) | ||
``` | ||
|
||
3. Conduct a sensitivity analyses for uncontrolled confounding and | ||
discuss the results | ||
|
||
```{r} | ||
uc_sens <- cmsens( | ||
object = res_rb, | ||
sens = "uc" | ||
) | ||
uc_sens | ||
``` | ||
|
||
4. Write a short report of your mediation models. Focus on item | ||
6,9,10,11,14,15,18,19,20,21,22 in the long Agrema checklist. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters