diff --git a/exercises/01-whole-game-exercises.qmd b/exercises/01-whole-game-exercises.qmd index 5eab01a..9cca586 100644 --- a/exercises/01-whole-game-exercises.qmd +++ b/exercises/01-whole-game-exercises.qmd @@ -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") + @@ -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. diff --git a/exercises/03-ci-with-group-by-and-summarise-exercises.qmd b/exercises/03-ci-with-group-by-and-summarise-exercises.qmd index bfc66fb..ef49526 100644 --- a/exercises/03-ci-with-group-by-and-summarise-exercises.qmd +++ b/exercises/03-ci-with-group-by-and-summarise-exercises.qmd @@ -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)) ``` diff --git a/exercises/05-quartets-exercises.qmd b/exercises/05-quartets-exercises.qmd index 357efbd..982ff13 100644 --- a/exercises/05-quartets-exercises.qmd +++ b/exercises/05-quartets-exercises.qmd @@ -5,6 +5,7 @@ format: html ```{r} #| label: setup +library(tidyverse) library(quartets) ``` diff --git a/exercises/10-continuous-g-computation-exercises.qmd b/exercises/10-continuous-g-computation-exercises.qmd index 6f5f0ae..b04e5f2 100644 --- a/exercises/10-continuous-g-computation-exercises.qmd +++ b/exercises/10-continuous-g-computation-exercises.qmd @@ -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. diff --git a/slides/.DS_Store b/slides/.DS_Store deleted file mode 100644 index a5d5f2a..0000000 Binary files a/slides/.DS_Store and /dev/null differ