Skip to content

Commit

Permalink
Merge pull request #65 from tgerke/tg-edits
Browse files Browse the repository at this point in the history
  • Loading branch information
malcolmbarrett authored Sep 2, 2023
2 parents 67d57e2 + 568df1e commit 4398644
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 18 deletions.
17 changes: 2 additions & 15 deletions exercises/01-whole-game-exercises.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ Let's look at the distribution of weight gain between the two groups.
```{r}
nhefs_complete_uc |>
ggplot(aes(wt82_71, fill = factor(qsmk))) +
geom_vline(xintercept = 0, color = "grey60", size = 1) +
geom_density(color = "white", alpha = .75, size = .5) +
geom_vline(xintercept = 0, color = "grey60", linewidth = 1) +
geom_density(color = "white", alpha = .75, linewidth = .5) +
scale_color_okabe_ito(order = c(1, 5)) +
theme_minimal() +
theme(legend.position = "bottom") +
Expand All @@ -60,19 +60,6 @@ nhefs_complete_uc |>
)
```

---

```{r}
# ~2.5 kg gained for quit vs. not quit
nhefs_complete_uc |>
group_by(qsmk) |>
summarize(
mean_weight_change = mean(wt82_71),
sd = sd(wt82_71),
.groups = "drop"
)
```

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?

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.
Expand Down
8 changes: 5 additions & 3 deletions exercises/03-ci-with-group-by-and-summarise-exercises.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ sim2 <- tibble(
sim2 |>
group_by(_____, _____, _____) |>
summarise(avg_y = mean(_____)) |>
pivot_wider(names_from = exposure,
values_from = avg_y,
names_prefix = "x_") |>
pivot_wider(
names_from = exposure,
values_from = avg_y,
names_prefix = "x_"
) |>
summarise(estimate = x_1 - x_0, .groups = "drop") |>
summarise(estimate = mean(estimate))
```
Expand Down
1 change: 1 addition & 0 deletions exercises/05-quartets-exercises.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ format: html

```{r}
#| label: setup
library(tidyverse)
library(quartets)
```

Expand Down
3 changes: 3 additions & 0 deletions exercises/10-continuous-g-computation-exercises.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ library(tidyverse)
library(broom)
library(touringplans)
library(splines)
seven_dwarfs <- seven_dwarfs_train_2018 |>
filter(wait_hour == 9)
```

For this set of exercises, we'll use g-computation to calculate a causal effect for continuous exposures.
Expand Down
Binary file removed slides/.DS_Store
Binary file not shown.

0 comments on commit 4398644

Please sign in to comment.