You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: exercises/06-pscores-weighting-exercises.qmd
+33-30Lines changed: 33 additions & 30 deletions
Original file line number
Diff line number
Diff line change
@@ -4,10 +4,11 @@ format: html
4
4
---
5
5
6
6
7
-
```{r}
7
+
```{r setup}
8
8
library(tidyverse)
9
9
library(broom)
10
10
library(touringplans)
11
+
library(propensity)
11
12
```
12
13
13
14
We are interested in examining the relationship between whether there were "Extra Magic Hours" in the morning (the **exposure**) and the average wait time for the Seven Dwarfs Mine Train the same day between 9am and 10am (the **outcome**).
@@ -25,7 +26,7 @@ propensity_model <- glm(
25
26
family = binomial()
26
27
)
27
28
28
-
df <- propensity_model |>
29
+
seven_dwarfs_prop <- propensity_model |>
29
30
augment(type.predict = "response", data = seven_dwarfs)
30
31
```
31
32
@@ -38,65 +39,67 @@ Create at "matched" data set using the same propensity score model as above and
38
39
```{r}
39
40
#| eval: false
40
41
library(MatchIt)
41
-
m <- matchit(___,
42
-
data = seven_dwarfs,
43
-
___,
44
-
___
45
-
)
46
-
matched_df <- ___(m)
42
+
matched_dwarfs <- matchit(
43
+
___,
44
+
data = seven_dwarfs,
45
+
___,
46
+
___
47
+
)
48
+
49
+
matched_df <- ___(matched_dwarfs)
47
50
```
48
51
49
52
## Your Turn 2 (Weighting)
50
53
51
54
_After updating the code chunks below, change `eval = TRUE` before knitting._
52
55
53
-
Add the ATE weights to the data frame, `df`
56
+
Add the ATE weights to the data frame, `seven_dwarfs_prop`
54
57
55
58
```{r}
56
59
#| eval: false
57
-
df <- df |>
60
+
seven_dwarfs_prop <- seven_dwarfs_prop |>
58
61
mutate(w_ate = ___)
59
62
```
60
63
61
64
62
65
Stretch Goal 1:
63
66
64
-
Add ATM weights to the data frame, `df`
67
+
Add ATM weights to the data frame, `seven_dwarfs_prop`
65
68
66
69
```{r}
67
70
#| eval: false
68
-
df <- df |>
71
+
seven_dwarfs_prop <- seven_dwarfs_prop |>
69
72
mutate(w_atm = ___)
70
73
```
71
74
72
75
Stretch Goal 2:
73
76
74
-
Update the code below to examine the distribution of the weighted sample. **HINT** the part that needs to be updated is the `weight` parameter in two of the `geom_histogram()`calls.
77
+
Update the code below to examine the distribution of the weighted sample. **HINT** the part that needs to be updated is the `weight` parameter in two of the `geom_mirror_histogram()`call.
0 commit comments