Practice Problems
Hypothesis Tests
All of the data sets for this lab can be found in the stats20data
package. Parts a and h require written English answers; d requires English answers and code; the other parts can be answered just with code, output, and plots.
Part I: Permutation Tests
 In order to study gender bias in promotion decisions, researchers took 48 resumes and randomly assigned them to 48 bank managers who were asked whether they would promote this candidate or not. The resumes were identical except the name: 24 of them had names generally associated with women, 24 of them had names generally associated with men. The data from this study can be found in the
promote
data frame. Use this data to determine whether gender played a role in promotion decisions.
Write the null and alternative hypothesis.
Null: Promotion decisions are independent of the gender of the name on the application. (or promotion proportions are equivalent)
Alternative: Promotion decisions are dependent on the gender of the name on the application. (or promotion proportions are not equivalent)
Compute the observed test statistic.

c. Visualize the observed data using an appropriate plot.
d. Construct a plot featuring 9 subplots, each one featuring a visualization of a data set generated under the null hypothesis. Does your visualization of the observed data from the previous part look like it be one of these plots?
The plots below show generally closer proportions than in the data, but not by too much  it's a close call.
e. Construct and save the null distribution of statistics.
f. Visualize the null distribution.
visualize(null)
g. Compute the pvalue.
get_p_value(null, obs_stat = obs_stat, direction = "both")
# A tibble: 1 × 1
p_value
<dbl>
1 0.036
h. Interpret the pvalue. What does it say about the consistency between the null hypothesis and the observed data?
With a pvalue of .056 on this seed (which is just a hair above the standard threshold of .05), its unclear whether the obsered difference in proportions can be attributed to change or not. With a different seed, it's possible this pvalue could bounce above and below the .05 threshold.
 Instead of conducting a hypothesis test concerning the difference in these proportions, form a confidence interval for your estimate (what had been your observed test statistic). Use the bootstrap to form a 95% confidence interval for this statistic. Does it contain 0? How is this related to the result from question 1?
# A tibble: 1 × 2
lower_ci upper_ci
<dbl> <dbl>
1 0.509 0.0505
This particular interval does not contain 0, but it’s close. That means 0 is not really a very plausible value of the true difference in proportions, which leads to a similar conclusion as the hypothesis test.
Part II: Tests with a Point Null

In the 2016 NBA season, it was noted that professional basketball player Steph Curry had a remarkable basketshooting performance beyond 30 feet. The
curry
data frame contains his long range shooting performance across 27 attempts. By comparison, the long range shooting percentage of NBA players that season was 7.5%. Assess whether this data is consistent with the notion that Steph Curry has a long range shooting percentage that is no different from the average NBA player. Said another way, assess just how remarkable Curry’s shooting performance was in 2016. Write the null and alternative hypothesis.
Null: Curry’s shooting rate is the same as the league average, where the probability of a basket is .075.
Alternative: Curry’s shooting rate is different from the league average of .075.
There will be some confusion/discussion here about whether this should be a onesided test.
 Compute the observed test statistic.
c. Visualize the observed data using an appropriate plot.
d. Construct a plot featuring 9 subplots, each one featuring a visualization of a data set generated under the null hypothesis. Does your visualization of the observed data from the previous part look like it be one of these plots?
These plots look dramatically different than the plot of Curry's data. The shot rate is far lower than his.
e. Construct and save the null distribution of statistics.
f. Visualize the null distribution.
visualize(null)
g. Compute the pvalue.
null %>%
get_p_value(obs_stat = obs_stat, direction = "both")
# A tibble: 1 × 1
p_value
<dbl>
1 0
h. Interpret the pvalue. What does it say about the consistency between the null hypothesis and the observed data?
A pvalue of (approximately) zero indicates that Curry's performance is (very!) inconsistent with notion that he shoots like your average NBA player. His performance this season was truly exceptional.