@@ -52,6 +52,29 @@ ggplot(null, aes(x = stat)) +
52
52
null %> %
53
53
summarize(p_value = mean(stat < x_tilde ) * 2 )
54
54
55
+ # # ------------------------------------------------------------------------
56
+ p_hat <- fli_small %> %
57
+ summarize(mean(day_hour == " morning" )) %> %
58
+ pull()
59
+ null <- fli_small %> %
60
+ specify(response = day_hour , success = " morning" ) %> %
61
+ hypothesize(null = " point" , p = .5 ) %> %
62
+ generate(reps = 1000 , type = " simulate" ) %> %
63
+ calculate(stat = " prop" )
64
+ ggplot(null , aes(x = stat )) +
65
+ geom_bar() +
66
+ geom_vline(xintercept = p_hat , color = " red" )
67
+ null %> %
68
+ summarize(p_value = mean(stat < p_hat ) * 2 )
69
+
70
+ # # ------------------------------------------------------------------------
71
+ null <- fli_small %> %
72
+ mutate(day_hour_logical = (day_hour == " morning" )) %> %
73
+ specify(response = day_hour_logical , success = " TRUE" ) %> %
74
+ hypothesize(null = " point" , p = .5 ) %> %
75
+ generate(reps = 1000 , type = " simulate" ) %> %
76
+ calculate(stat = " prop" )
77
+
55
78
# # ------------------------------------------------------------------------
56
79
d_hat <- fli_small %> %
57
80
group_by(season ) %> %
@@ -166,29 +189,29 @@ ggplot(null, aes(x = stat)) +
166
189
null %> %
167
190
summarize(p_value = mean(stat > slope_hat ) * 2 )
168
191
169
- # # ----eval=FALSE ----------------------------------------------------------
170
- # x_bar <- fli_small %>%
171
- # summarize(mean(arr_delay)) %>%
172
- # pull()
173
- # boot <- fli_small %>%
174
- # specify(response = arr_delay) %>%
175
- # generate(reps = 1000, type = "bootstrap") %>%
176
- # calculate(stat = "mean") %>%
177
- # pull()
178
- # c(lower = x_bar - 2 * sd(boot),
179
- # upper = x_bar + 2 * sd(boot))
180
-
181
- # # ----eval=FALSE ----------------------------------------------------------
182
- # p_hat <- fli_small %>%
183
- # summarize(mean(day_hour == "morning")) %>%
184
- # pull()
185
- # boot <- fli_small %>%
186
- # specify(response = day_hour, success = "morning") %>%
187
- # generate(reps = 1000, type = "bootstrap") %>%
188
- # calculate(stat = "prop") %>%
189
- # pull()
190
- # c(lower = p_hat - 2 * sd(boot),
191
- # upper = p_hat + 2 * sd(boot))
192
+ # # -------------- ----------------------------------------------------------
193
+ x_bar <- fli_small %> %
194
+ summarize(mean(arr_delay )) %> %
195
+ pull()
196
+ boot <- fli_small %> %
197
+ specify(response = arr_delay ) %> %
198
+ generate(reps = 1000 , type = " bootstrap" ) %> %
199
+ calculate(stat = " mean" ) %> %
200
+ pull()
201
+ c(lower = x_bar - 2 * sd(boot ),
202
+ upper = x_bar + 2 * sd(boot ))
203
+
204
+ # # -------------- ----------------------------------------------------------
205
+ p_hat <- fli_small %> %
206
+ summarize(mean(day_hour == " morning" )) %> %
207
+ pull()
208
+ boot <- fli_small %> %
209
+ specify(response = day_hour , success = " morning" ) %> %
210
+ generate(reps = 1000 , type = " bootstrap" ) %> %
211
+ calculate(stat = " prop" ) %> %
212
+ pull()
213
+ c(lower = p_hat - 2 * sd(boot ),
214
+ upper = p_hat + 2 * sd(boot ))
192
215
193
216
# # ------------------------------------------------------------------------
194
217
d_hat <- fli_small %> %
0 commit comments