Randomizing opportunity cost
As in Chapter 2 Exercise 5, you will permute the data to generate a distribution of differences as if the null hypothesis were true.
In the study, the number of individuals in each of the control and treatment groups is fixed. Additionally, when you assume that the null hypothesis is true—that is, the experiment had no effect on the outcome of buying a DVD—it is reasonable to infer that the number of individuals who would buy a DVD is also fixed. That is, 97 people were going to buy a DVD regardless of which treatment group they were in.
Using the new data and the methods from the previous chapter, create a randomization distribution of the difference in proportions calculated on permuted data.
This exercise is part of the course
Foundations of Inference in R
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Calculate the observed difference in purchase rate
diff_obs <- opportunity %>%
# Group by group
___(___) %>%
# Calculate proportion deciding to buy a DVD
___(prop_buy = ___(___)) %>%
# Calculate difference between groups
___(stat = ___) %>%
pull()