In practice most statisticians will rely on already existing functions to perform tests and/or confidence intervals. However, there are cases when a function doesn’t exist, or the existing function does something slightly different from what you want.

In this lab, you’ll see some of the functions mentioned in class for conducting the procedures we’ve seen over the last week or two, as well as a few cases where no function exists in the the base or stats packages (those installed by default). In most cases you’ll also see the explicit calculation of the test statistic. Why? It’s useful to calculate the test statistic explicitly to:

Check your understanding and practice for exam situations.

Serve as a check before using a base/stats R function, or one from a contributed package.

Wilcoxon Rank Sum

Recall a Wilcoxon Rank Sum test tests null hypotheses about the mean/median under an assumption that the population is symmetric:

We saw you could either use the CLT to build an approximate test or compute an exact reference distribution. To illustrate the approximate test, we first need to standardize by the mean and variance of the test statistic, which depend only on \(n\):