Skip to content

Commit 84472f9

Browse files
clean up 7
1 parent 2488bf5 commit 84472f9

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

exercises/07-pscores-diagnostics-exercises.qmd

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ format: html
77
```{r}
88
library(tidyverse)
99
library(broom)
10-
library(tidysmd)
1110
library(touringplans)
12-
library(ggecdf)
11+
library(halfmoon)
1312
```
1413

1514
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**).
@@ -27,7 +26,7 @@ propensity_model <- glm(
2726
family = binomial()
2827
)
2928
30-
df <- propensity_model |>
29+
seven_dwarfs_ps <- propensity_model |>
3130
augment(type.predict = "response", data = seven_dwarfs) |>
3231
mutate(w_ate = 1 / ifelse(extra_magic_morning == 0, 1 - .fitted, .fitted))
3332
```
@@ -40,7 +39,7 @@ Calculate the standardized mean differences with and without weights
4039

4140
```{r}
4241
#| eval: false
43-
smds <- df |>
42+
smds <- seven_dwarfs_ps |>
4443
mutate(close = as.numeric(close)) |>
4544
tidy_smd(
4645
.vars = ____,
@@ -49,44 +48,45 @@ smds <- df |>
4948
)
5049
```
5150

52-
Create the Love Plot using ggplot
51+
Create the Love Plot using ggplot and halfmoon
5352

5453
```{r}
5554
#| eval: false
5655
ggplot(
5756
data = ____,
5857
aes(x = abs(____), y = ____, group = ____, color = ____)
5958
) +
60-
geom_line(orientation = "y") +
61-
geom_point() +
62-
geom_vline(xintercept = 0.1, color = "black", size = 0.1)
59+
geom_love()
6360
```
6461

65-
66-
6762
## Your Turn 2
6863

6964
Create an unweighted ECDF for `weather_wdwhigh` by whether or not the day had Extra Magic Hours.
7065

7166
```{r}
7267
#| eval: false
73-
ggplot(df, aes(x = ____, group = ____, color = factor(____))) +
68+
ggplot(seven_dwarfs_ps, aes(x = ____, group = ____, color = factor(____))) +
7469
____() +
75-
scale_color_manual("Extra Magic Hours", values = c("#5154B8", "#5DB854"),
76-
labels = c("Yes", "No")) +
70+
scale_color_manual(
71+
"Extra Magic Hours",
72+
values = c("#5154B8", "#5DB854"),
73+
labels = c("Yes", "No")
74+
) +
7775
xlab(____) +
7876
ylab("Proportion <= x")
7977
```
8078

81-
8279
Create an weighted ECDF for `weather_wdwhigh` by whether or not the day had Extra Magic Hours.
8380

8481
```{r}
8582
#| eval: false
86-
ggplot(df, aes(x = ____, color = factor(____))) +
83+
ggplot(seven_dwarfs_ps, aes(x = ____, color = factor(____))) +
8784
____(aes(weights = ____)) +
88-
scale_color_manual("Extra Magic Hours", values = c("#5154B8", "#5DB854"),
89-
labels = c("Yes", "No")) +
85+
scale_color_manual(
86+
"Extra Magic Hours",
87+
values = c("#5154B8", "#5DB854"),
88+
labels = c("Yes", "No")
89+
) +
9090
xlab(____) +
9191
ylab("Proportion <= x (Weighted)")
9292
```

0 commit comments

Comments
 (0)