Paired tests"

  collapse = TRUE,
  comment = "#>",
  message = FALSE,
  warning = FALSE

This vignette will make most sense if you are familiar with one sample and two sample tests. If these are new to you, have a look at vignette("one-sample-z-test") and vignette("two-sample-z-test").

Problem setup

Suppose we're interested in people's happiness before and after discovering the #rstats Twitter community. We survey them get before and after happiness scores, using a happiness survey that goes from 0 to 100.

The data looks like this


before <- round(rnorm(10, 50, 20))
after <- round(before + 5 + rnorm(10, 0, 10))

knitr::kable(data.frame(person = 1:10, before, after))

Working with the differences

Crucially, since the before measurement and the after measurement are on the same person, we can subtract the before measurement from the after measurement and do a one sample test on these differences.

before <- c(88, 73, 35, 21, 28, 56, 50, 73, 93, 55)
after <- c(80, 78, 56, 28, 26, 50, 39, 67, 98, 63) 

diff <- after - before

Paired tests versus two sample tests

One key question is: when should we use paired instead of two sample tests? Students typically struggle with this, and it's worth spending some time thinking about this. In abstract terms, we should use paired tests when we have two observations on the same experimental unit and two sample tests when we have two observations on different experimental units.

The difficulty here is that it takes some time to become comfortable with experimental units. I recommend memorizing

Some examples where paired tests are appropriate:

Some examples where you should use a two sample test:

Also note that we

twosample tests, and when should we use

why pair - power pair if you can memorize and analogize

Paired Z-test

Paired T-test

Paired sign-test

Try the distributions3 package in your browser

Any scripts or data that you put into this service are public.

distributions3 documentation built on Sept. 3, 2019, 5:06 p.m.