Skip to content

Commit b77159d

Browse files
authored
suggested edits due to infer package 1.0.0 update (#263)
1 parent a2b1d95 commit b77159d

File tree

3 files changed

+27
-16
lines changed

3 files changed

+27
-16
lines changed

04-foundations/02-lesson/04-02-lesson.Rmd

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,59 +1144,65 @@ This function has three arguments (inputs):
11441144
2. the observed statistic (`obs_stat`)
11451145
3. the direction of the alternative hypothesis ("greater", "less", or "two-sided")
11461146

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!
11491149

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.
11521152

11531153
- You can test out the different methods for calculating the p-value by trying out: `direction = "greater"`, `direction = "two_sided"`, and `direction = "less"`.
11541154

11551155
```{r pvalue, exercise=TRUE}
11561156
# Visualize and calculate the p-value for the original dataset
11571157
gender_discrimination_perm |>
1158+
visualize() +
11581159
___(obs_stat = ___, direction = "___")
11591160
11601161
gender_discrimination_perm |>
11611162
___(___, ___)
11621163
11631164
# Visualize and calculate the p-value for the small dataset
11641165
___ |>
1166+
visualize() +
11651167
___(___, ___)
11661168
11671169
___ |>
11681170
___(___, ___)
11691171
11701172
# Visualize and calculate the p-value for the big dataset
11711173
___ |>
1174+
visualize() +
11721175
___(___, ___)
11731176
11741177
___ |>
11751178
___(___, ___)
11761179
```
11771180

11781181
```{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!
11801183
```
11811184

11821185
```{r pvalue-solution}
11831186
# Visualize and calculate the p-value for the original dataset
11841187
gender_discrimination_perm |>
1185-
visualize(obs_stat = diff_orig, direction = "greater")
1188+
visualize() +
1189+
shade_p_value(obs_stat = diff_orig, direction = "greater")
11861190
11871191
gender_discrimination_perm |>
11881192
get_p_value(obs_stat = diff_orig, direction = "greater")
11891193
11901194
# Visualize and calculate the p-value for the small dataset
11911195
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")
11931198
11941199
gender_discrimination_small_perm |>
11951200
get_p_value(obs_stat = diff_orig_small, direction = "greater")
11961201
11971202
# Visualize and calculate the p-value for the big dataset
11981203
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")
12001206
12011207
gender_discrimination_big_perm |>
12021208
get_p_value(obs_stat = diff_orig_big, direction = "greater")

04-foundations/03-lesson/04-03-lesson.Rmd

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,16 +428,17 @@ Now that you've created the randomization distribution, you'll use it to assess
428428

429429
The permuted dataset and the original observed statistic are available in your workspace as `opp_perm` and `diff_obs` respectively.
430430

431-
`visualize()` 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.
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.
432432

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()`.
434434
- Then `get_p_value()` is calculated as the proportion of permuted statistics which are `direction = "less"` than `obs_stat = diff_obs`.
435435
- 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`).
436436
- 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()`.
437437

438438
```{r summarizing_opportunity_cost, exercise=TRUE}
439439
# Visualize the statistic
440440
opp_perm |>
441+
___() +
441442
___(___, ___)
442443
443444
# Calculate the p-value using `get_p_value()`
@@ -451,7 +452,8 @@ opp_perm |>
451452

452453
```{r summarizing_opportunity_cost-hint-1}
453454
opp_perm |>
454-
visualize(obs_stat = diff_obs, direction = "less")
455+
visualize() +
456+
shade_p_value(obs_stat = diff_obs, direction = "less")
455457
```
456458

457459
```{r summarizing_opportunity_cost-hint-2}
@@ -462,7 +464,8 @@ opp_perm |>
462464
```{r summarizing_opportunity_cost-solution}
463465
# Visualize the statistic
464466
opp_perm |>
465-
visualize(obs_stat = diff_obs, direction = "less")
467+
visualize() +
468+
shade_p_value(obs_stat = diff_obs, direction = "less")
466469
467470
# Calculate the p-value using `get_p_value()`
468471
opp_perm |>

04-foundations/04-lesson/04-04-lesson.Rmd

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ percentile_ci
943943
(3)
944944

945945

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.
947947
- Set the `endpoints` argument to be `percentile_ci`.
948948
- Set the `direction` of the shading to `"between"`, to highlight in-between those endpoints.
949949

@@ -955,11 +955,12 @@ percentile_ci <- one_poll_boot |>
955955
956956
one_poll_boot |>
957957
# Visualize in-between the endpoints given by percentile_ci
958-
___
958+
___() +
959+
___(endpoints = ___, direction = ___)
959960
```
960961

961962
```{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"`.
963964
```
964965

965966
```{r bootstrap_percentile_3-solution}
@@ -969,7 +970,8 @@ percentile_ci <- one_poll_boot |>
969970
970971
one_poll_boot |>
971972
# 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")
973975
```
974976

975977
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

Comments
 (0)