Climate change

Application exercise

In this application exercise, we’ll do inference for a comparing two paired means and many means.

Packages

We’ll use the tidyverse, tidymodels, openintro, and ggthemes packages.

library(tidyverse)
library(tidymodels)
library(openintro)

Paired means

Throughout this application exercise, we’ll make use of the climate70 dataset supplied by the openintro package.

# add code here

The question we want to answer is: Do these data provide convincing evidence that the number of days above 90 degrees between 2018 and 1948?

First, let’s set the hypotheses.

Add response here.

To carry out inference on paired data, we pre-compute the difference between paired values at the beginning of the analysis, and use those differences as our values of interest.

# add code here

And then visualize these differences:

# add code here

We calculate the observed statistic in the paired setting in the same way that we would outside of the paired setting. Using specify() and calculate():

# add code here

Now, we want to compare this statistic to a null distribution, generated under the assumption that the true difference was actually zero, to get a sense of how likely it would be for us to see this observed difference or something more extreme.

Tests for paired data are carried out via the null = "paired independence" argument to hypothesize().

# add code here

For each replicate, generate() carries out type = "permute" with null = "paired independence" by:

  • Randomly sampling a vector of signs (i.e., -1 or 1), probability 0.5 for either, with length equal to the input data, and
  • Multiplying the response variable by the vector of signs, “flipping” the observed values for a random subset of value in each replicate

To get a sense for what this distribution looks like, and where our observed statistic falls, we can use visualize():

# add code here

Then, we calculate the p-value:

# add code here

Finally, the conclusion of the hypothesis test is…

Add response here.