Skip to content

Commit 85b2616

Browse files
committed
fix 14
1 parent d7893b8 commit 85b2616

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

exercises/14-bonus-continuous-pscores-exercises.qmd

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ library(propensity)
1313

1414
For this set of exercises, we'll use propensity scores for continuous exposures.
1515

16-
In the touringplans data set, we have information about the posted waiting times for rides. We also have a limited amount of data on the observed, actual times. The question that we will consider is this: Do posted wait times (`avg_spostmin`) for the Seven Dwarves Mine Train at 8 am affect actual wait times (`avg_sactmin`) at 9 am? Here’s our DAG:
16+
In the touringplans data set, we have information about the posted waiting times for rides. We also have a limited amount of data on the observed, actual times. The question that we will consider is this: Do posted wait times (`wait_minutes_posted_avg`) for the Seven Dwarves Mine Train at 8 am affect actual wait times (`wait_minutes_actual_avg`) at 9 am? Here’s our DAG:
1717

1818
```{r}
1919
#| echo: false
@@ -83,31 +83,31 @@ dagify(
8383
)
8484
```
8585

86-
First, let’s wrangle our data to address our question: do posted wait times at 8 affect actual weight times at 9? We’ll join the baseline data (all covariates and posted wait time at 8) with the outcome (average actual time). We also have a lot of missingness for `avg_sactmin`, so we’ll drop unobserved values for now.
86+
First, let’s wrangle our data to address our question: do posted wait times at 8 affect actual weight times at 9? We’ll join the baseline data (all covariates and posted wait time at 8) with the outcome (average actual time). We also have a lot of missingness for `wait_minutes_actual_avg`, so we’ll drop unobserved values for now.
8787

8888
You don't need to update any code here, so just run this.
8989

9090
```{r}
9191
eight <- seven_dwarfs_train_2018 |>
92-
filter(hour == 8) |>
93-
select(-avg_sactmin)
92+
filter(wait_hour == 8) |>
93+
select(-wait_minutes_actual_avg)
9494
9595
nine <- seven_dwarfs_train_2018 |>
96-
filter(hour == 9) |>
97-
select(date, avg_sactmin)
96+
filter(wait_hour == 9) |>
97+
select(date, wait_minutes_actual_avg)
9898
9999
wait_times <- eight |>
100100
left_join(nine, by = "date") |>
101-
drop_na(avg_sactmin)
101+
drop_na(wait_minutes_actual_avg)
102102
```
103103

104104
# Your Turn 1
105105

106-
First, let’s calculate the propensity score model, which will be the denominator in our stabilized weights (more to come on that soon). We’ll fit a model using `lm()` for `avg_spostmin` with our covariates, then use the fitted predictions of `avg_spostmin` (`.fitted`, `.sigma`) to calculate the density using `dnorm()`.
106+
First, let’s calculate the propensity score model, which will be the denominator in our stabilized weights (more to come on that soon). We’ll fit a model using `lm()` for `wait_minutes_posted_avg` with our covariates, then use the fitted predictions of `wait_minutes_posted_avg` (`.fitted`, `.sigma`) to calculate the density using `dnorm()`.
107107

108-
1. Fit a model using `lm()` with `avg_spostmin` as the outcome and the confounders identified in the DAG.
108+
1. Fit a model using `lm()` with `wait_minutes_posted_avg` as the outcome and the confounders identified in the DAG.
109109
2. Use `augment()` to add model predictions to the data frame.
110-
3. In `wt_ate()`, calculate the weights using `avg_postmin`, `.fitted`, and `.sigma`.
110+
3. In `wt_ate()`, calculate the weights using `wait_minutes_posted_avg`, `.fitted`, and `.sigma`.
111111

112112
```{r}
113113
post_time_model <- lm(
@@ -169,7 +169,7 @@ Now, let's fit the outcome model!
169169
```{r}
170170
lm(___ ~ ___, weights = ___, data = wait_times_swts) |>
171171
tidy() |>
172-
filter(term == "avg_spostmin") |>
172+
filter(term == "wait_minutes_posted_avg") |>
173173
mutate(estimate = estimate * 10)
174174
```
175175

0 commit comments

Comments
 (0)