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: 04-foundations/02-lesson/04-02-lesson.Rmd
+14-8Lines changed: 14 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -1144,59 +1144,65 @@ This function has three arguments (inputs):
1144
1144
2. the observed statistic (`obs_stat`)
1145
1145
3. the direction of the alternative hypothesis ("greater", "less", or "two-sided")
1146
1146
1147
-
We can also use the `visualize()`function to visualize where the observed statistic falls in the distribution of permuted statistics, and shade the direction that the p-value was calculated from.
1148
-
The `visualize()` function has many inputs (find out more by typing `?visualize` in your console), but the most important ones are the __same__ as the `get_p_value()` function!
1147
+
We can also use the `visualize()`and `shade_p_value()` functions to visualize where the observed statistic falls in the distribution of permuted statistics, and shade the direction that the p-value was calculated from.
1148
+
The `shade_p_value()` function has many inputs (find out more by typing `?shade_p_value` in your console), but the most important ones are the __same__ as the `get_p_value()` function!
1149
1149
1150
-
Now, use the `visualize()` and `get_p_value()` functions for the original, small, and big datasets.
1151
-
First `visualize()` where the p-value lies on the distibution, and then calculate the p-value.
1150
+
Now, use the `visualize()`, `shade_p_value()`, and `get_p_value()` functions for the original, small, and big datasets.
1151
+
First use `shade_p_value()`to see where the p-value lies on the distribution, and then calculate the p-value.
1152
1152
1153
1153
- You can test out the different methods for calculating the p-value by trying out: `direction = "greater"`, `direction = "two_sided"`, and `direction = "less"`.
1154
1154
1155
1155
```{r pvalue, exercise=TRUE}
1156
1156
# Visualize and calculate the p-value for the original dataset
1157
1157
gender_discrimination_perm |>
1158
+
visualize() +
1158
1159
___(obs_stat = ___, direction = "___")
1159
1160
1160
1161
gender_discrimination_perm |>
1161
1162
___(___, ___)
1162
1163
1163
1164
# Visualize and calculate the p-value for the small dataset
1164
1165
___ |>
1166
+
visualize() +
1165
1167
___(___, ___)
1166
1168
1167
1169
___ |>
1168
1170
___(___, ___)
1169
1171
1170
1172
# Visualize and calculate the p-value for the big dataset
1171
1173
___ |>
1174
+
visualize() +
1172
1175
___(___, ___)
1173
1176
1174
1177
___ |>
1175
1178
___(___, ___)
1176
1179
```
1177
1180
1178
1181
```{r pvalue-hint}
1179
-
Argument of the both functions should be `obs_stat = diff_orig, direction = "greater"`, but remember to use the correct dataset!
1182
+
Arguments of both `shade_p_value()` and `get_p_value()` functions should be `obs_stat = diff_orig, direction = "greater"`, but remember to use the correct dataset!
1180
1183
```
1181
1184
1182
1185
```{r pvalue-solution}
1183
1186
# Visualize and calculate the p-value for the original dataset
1184
1187
gender_discrimination_perm |>
1185
-
visualize(obs_stat = diff_orig, direction = "greater")
1188
+
visualize() +
1189
+
shade_p_value(obs_stat = diff_orig, direction = "greater")
1186
1190
1187
1191
gender_discrimination_perm |>
1188
1192
get_p_value(obs_stat = diff_orig, direction = "greater")
1189
1193
1190
1194
# Visualize and calculate the p-value for the small dataset
1191
1195
gender_discrimination_small_perm |>
1192
-
visualize(obs_stat = diff_orig_small, direction = "greater")
1196
+
visualize() +
1197
+
shade_p_value(obs_stat = diff_orig_small, direction = "greater")
1193
1198
1194
1199
gender_discrimination_small_perm |>
1195
1200
get_p_value(obs_stat = diff_orig_small, direction = "greater")
1196
1201
1197
1202
# Visualize and calculate the p-value for the big dataset
1198
1203
gender_discrimination_big_perm |>
1199
-
visualize(obs_stat = diff_orig_big, direction = "greater")
1204
+
visualize() +
1205
+
shade_p_value(obs_stat = diff_orig_big, direction = "greater")
1200
1206
1201
1207
gender_discrimination_big_perm |>
1202
1208
get_p_value(obs_stat = diff_orig_big, direction = "greater")
Copy file name to clipboardExpand all lines: 04-foundations/03-lesson/04-03-lesson.Rmd
+7-4Lines changed: 7 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -428,16 +428,17 @@ Now that you've created the randomization distribution, you'll use it to assess
428
428
429
429
The permuted dataset and the original observed statistic are available in your workspace as `opp_perm` and `diff_obs` respectively.
430
430
431
-
`visualize()`and `get_p_value()` using the builtin infer functions. Remember that the null statistics are above the original difference, so the p-value (which represents how often a null value is more *extreme*) is calculated by counting the number of null values which are `less` than the original difference.
431
+
`visualize()`, `shade_p_value()`, and `get_p_value()` using the built-in infer functions. Remember that the null statistics are above the original difference, so the p-value (which represents how often a null value is more *extreme*) is calculated by counting the number of null values which are `less` than the original difference.
432
432
433
-
- First `visualize()` the sampling distribution of the permuted statistics indicating the place where `obs_stat = diff_obs`, and coloring in values below with the command `direction = "less"`.
433
+
- First `visualize()` the sampling distribution of the permuted statistics indicating the place where `obs_stat = diff_obs`, and coloring in values below with the command `direction = "less"` using `shade_p_value()`.
434
434
- Then `get_p_value()` is calculated as the proportion of permuted statistics which are `direction = "less"` than `obs_stat = diff_obs`.
435
435
- As an alternative way to calculate the p-value, use `summarize()` and `mean()` to find the proportion of times the permuted differences in `opp_perm` (called `stat`) are less than or equal to the observed difference (called `diff_obs`).
436
436
- You can test your knowledge by trying out: `direction = "greater"`, `direction = "two_sided"`, and `direction = "less"` before submitting your answer to both `visualize()` and `get_p_value()`.
Copy file name to clipboardExpand all lines: 04-foundations/04-lesson/04-04-lesson.Rmd
+6-4Lines changed: 6 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -943,7 +943,7 @@ percentile_ci
943
943
(3)
944
944
945
945
946
-
- Finally, use the `visualize()` function to plot the distribution of bootstrapped proportions with the middle 95 percent highlighted.
946
+
- Finally, use the `visualize()` function together with `shade_confidence_interval()`to plot the distribution of bootstrapped proportions with the middle 95 percent highlighted.
947
947
- Set the `endpoints` argument to be `percentile_ci`.
948
948
- Set the `direction` of the shading to `"between"`, to highlight in-between those endpoints.
# Visualize in-between the endpoints given by percentile_ci
958
-
___
958
+
___() +
959
+
___(endpoints = ___, direction = ___)
959
960
```
960
961
961
962
```{r bootstrap_percentile_3-hint}
962
-
After the pipe, visualize the interval by calling `visualize()`, setting `endpoints` to `percentile_ci` and `direction` to `"between"`.
963
+
After the pipe, visualize the distribution by calling `visualize()` and the interval using `shade_confidence_interval()`, setting `endpoints` to `percentile_ci` and `direction` to `"between"`.
# Visualize in-between the endpoints given by percentile_ci
972
-
visualize(endpoints = percentile_ci, direction = "between")
973
+
visualize() +
974
+
shade_confidence_interval(endpoints = percentile_ci, direction = "between")
973
975
```
974
976
975
977
Excellent! Again, the same caveat applies: because the two intervals were created using different methods, the intervals are expected to be a bit different as well. In the long run, however, the intervals should provide the same information.
0 commit comments