CommencerCommencer gratuitement

When the null is true: decision

In the last exercise, the observed difference in proportions is comfortably in the middle of the null distribution. In this exercise, you'll come to a formal decision on if you should reject the null hypothesis, but instead of using p-values, you'll use the notion of a rejection region.

The rejection region is the range of values of the statistic that would lead you to reject the null hypothesis. In a two-tailed test, there are two rejection regions. You know that the upper region should contain the largest 2.5% of the null statistics (when alpha = .05), so you can extract the cutoff value by finding the .975 quantile(). Similarly, the lower region contains the smallest 2.5% of the null statistics, which can also be found using quantile().

Here's a quick look at how the quantile() function works for this simple dataset x.

x <- c(0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20)
quantile(x, probs = .5)
quantile(x, probs = .8)

Once you have the rejection region defined by the upper and lower cutoffs, you can make your decision regarding the null by checking if your observed statistic falls between those cutoffs (in which case you will fail to reject) or outside of them (in which case you will reject).

Cet exercice fait partie du cours

Inference for Categorical Data in R

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Set alpha
___

# Find cutoffs
lower <- null %>%
  summarize(l = quantile(___, probs = ___)) %>%
  pull()
upper <- null %>%
  summarize(u = quantile(___, probs = ___)) %>%
  pull()

# Is d_hat inside cutoffs?
d_hat %>%
  between(___, ___)
Modifier et exécuter le code