Skip to content

Commit f6e0ec2

Browse files
sync
1 parent cf90fd9 commit f6e0ec2

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

exercises/01-whole-game-exercises.qmd

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ smk_wt_dag <- dagify(
9090
# specify causal question:
9191
exposure = "qsmk",
9292
outcome = "wt82_71",
93+
coords = time_ordered_coords(),
9394
# set up labels:
9495
# here, I'll use the same variable names as the data set, but I'll label them
9596
# with clearer names
@@ -113,7 +114,8 @@ smk_wt_dag <- dagify(
113114
"smokeintensity" = "smoking\nintensity",
114115
"smokeyrs" = "yrs of\nsmoking"
115116
)
116-
) |>tidy_dagitty(layout = "star")
117+
) |>
118+
tidy_dagitty()
117119
118120
smk_wt_dag
119121
```
@@ -313,9 +315,13 @@ fit_ipw <- function(split, ...) {
313315
# calculate inverse probability weights
314316
.df <- propensity_model |>
315317
augment(type.predict = "response", data = .df) |>
316-
mutate(wts = wt_ate(.fitted, qsmk))
318+
mutate(wts = wt_ate(
319+
.fitted,
320+
qsmk,
321+
exposure_type = "binary"
322+
))
317323
318-
# fit correctly bootsrapped ipw model
324+
# fit correctly bootstrapped ipw model
319325
lm(wt82_71 ~ qsmk, data = .df, weights = wts) |>
320326
tidy()
321327
}

slides/raw/01-causal_modeling_whole_game.qmd

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,6 @@ nhefs_complete_uc |>
9595
#| fig.width: 9
9696
library(ggdag)
9797
# set up DAG
98-
coords <- time_ordered_coords(
99-
list(
100-
c("active", "age", "education", "exercise", "race", "sex", "smokeintensity",
101-
"smokeyrs", "wt71"),
102-
"qsmk",
103-
"wt82_71"
104-
)
105-
)
10698
smk_wt_dag <- dagify(
10799
# specify causes of quitting smoking and weight gain:
108100
qsmk ~ sex + race + age + education +
@@ -112,7 +104,7 @@ smk_wt_dag <- dagify(
112104
# specify causal question:
113105
exposure = "qsmk",
114106
outcome = "wt82_71",
115-
coords = coords,
107+
coords = time_ordered_coords(),
116108
# set up labels:
117109
# here, I'll use the same variable names as the data set, but I'll label them
118110
# with clearer names

0 commit comments

Comments
 (0)