Skip to content

Commit 4398644

Browse files
Merge pull request #65 from tgerke/tg-edits
2 parents 67d57e2 + 568df1e commit 4398644

File tree

5 files changed

+11
-18
lines changed

5 files changed

+11
-18
lines changed

exercises/01-whole-game-exercises.qmd

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ Let's look at the distribution of weight gain between the two groups.
3636
```{r}
3737
nhefs_complete_uc |>
3838
ggplot(aes(wt82_71, fill = factor(qsmk))) +
39-
geom_vline(xintercept = 0, color = "grey60", size = 1) +
40-
geom_density(color = "white", alpha = .75, size = .5) +
39+
geom_vline(xintercept = 0, color = "grey60", linewidth = 1) +
40+
geom_density(color = "white", alpha = .75, linewidth = .5) +
4141
scale_color_okabe_ito(order = c(1, 5)) +
4242
theme_minimal() +
4343
theme(legend.position = "bottom") +
@@ -60,19 +60,6 @@ nhefs_complete_uc |>
6060
)
6161
```
6262

63-
---
64-
65-
```{r}
66-
# ~2.5 kg gained for quit vs. not quit
67-
nhefs_complete_uc |>
68-
group_by(qsmk) |>
69-
summarize(
70-
mean_weight_change = mean(wt82_71),
71-
sd = sd(wt82_71),
72-
.groups = "drop"
73-
)
74-
```
75-
7663
Here, it looks like those who quit smoking gained, on average, 2.5 kg. But is there something else that could explain these results? There are many factors associated with both quitting smoking and gaining weight; could one of those factors explain away the results we're seeing here?
7764

7865
To truly answer this question, we need to specify a causal diagram based on domain knowledge. Sadly, for most circumstances, there is no data-driven approach that consistently identify confounders. Only our causal assumptions can help us identify them. Causal diagrams are a visual expression of those assumptions linked to rigorous mathematics that allow us to understand what we need to account for in our model.

exercises/03-ci-with-group-by-and-summarise-exercises.qmd

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,11 @@ sim2 <- tibble(
7272
sim2 |>
7373
group_by(_____, _____, _____) |>
7474
summarise(avg_y = mean(_____)) |>
75-
pivot_wider(names_from = exposure,
76-
values_from = avg_y,
77-
names_prefix = "x_") |>
75+
pivot_wider(
76+
names_from = exposure,
77+
values_from = avg_y,
78+
names_prefix = "x_"
79+
) |>
7880
summarise(estimate = x_1 - x_0, .groups = "drop") |>
7981
summarise(estimate = mean(estimate))
8082
```

exercises/05-quartets-exercises.qmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ format: html
55

66
```{r}
77
#| label: setup
8+
library(tidyverse)
89
library(quartets)
910
```
1011

exercises/10-continuous-g-computation-exercises.qmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ library(tidyverse)
99
library(broom)
1010
library(touringplans)
1111
library(splines)
12+
13+
seven_dwarfs <- seven_dwarfs_train_2018 |>
14+
filter(wait_hour == 9)
1215
```
1316

1417
For this set of exercises, we'll use g-computation to calculate a causal effect for continuous exposures.

slides/.DS_Store

-6 KB
Binary file not shown.

0 commit comments

Comments
 (0)