Skip to content

Commit

Permalink
updated group work solution
Browse files Browse the repository at this point in the history
  • Loading branch information
danielibsen committed May 28, 2024
1 parent 613c49b commit 4b831ca
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 7 deletions.
9 changes: 5 additions & 4 deletions sessions/group_work_day2.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
## Objective of this session

In this session, We will get hands on practice using the Framingham
dataset. You will conduct a proper causal mediation analysis,
considering:
dataset. You will conduct a causal mediation analysis, considering:

- Conduct causal mediation analyses with exposure induced
mediator-outcome confounder or multiple mediators
Expand All @@ -31,6 +30,8 @@ can either use the **mediation** package or **CMAverse** package.

2. Perform a causal mediation analysis

3. Conduct a sensitivity analyses and discuss the results
3. Conduct a sensitivity analyses for uncontrolled confounding and
discuss the results

4. Write a short report of your mediation models
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.
94 changes: 94 additions & 0 deletions sessions/group_work_day2_solution.qmd
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.
8 changes: 5 additions & 3 deletions sessions/reporting-guidelines.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ report. See @fig-agrema-checklist-sf.
![AGReMA checklist from Lee et
al.](/images/agrema-checklist-sf.PNG){#fig-agrema-checklist-sf}

## Exercise
::: callout-note \## Exercise - 15 min

- how many of the items are reported in the mediation analysis papers
- How many of the items are reported in the mediation analysis papers
you reviewed in the beginning of the course?
- what do you think are the most important things missing?
- What do you think are the most important things missing?

:::

## References

0 comments on commit 4b831ca

Please sign in to comment.