Paired T-test

tags: #statistics/inferential/ttest/paired

What is a paired t-test?

How can you tell if the data is paired or not?

The data is described as unpaired or independent when the sets of data arise from separate individuals or paired when it arises from the same individual at different points in time, e.g.,you might have before-and-after measurements for a group of people.

Need to recognize paired data when you have it because two-sampled t-tests are not valid unless they are independent. Paired data ARE NOT independent.

The paired sample t-test is also called dependent sample t-test, used when we are interested in the difference between two measures for the same subject (i.e., sample) separated by time[1].

Shares the same assumption as {Test} Two-Sample (Independent) T-tests, including:

Assumptions

To apply the paired t-test to test for differences between paired measurements, the following assumptions need to hold:

  1. Subjects are independent i.e., outcome of one subject does not influence the outcome of another

  2. Each of the paired measurements must be obtained from the same subject.

  3. The DV for each samples are normally distributed (e.g., before and after)

If assumptions are violated (e.g., not normally distributed) an appropriate alternative to use would be the Wilcoxon signed-rank Test.


Hypothesis Model

In a paired t-test, you are testing whether the mean differences are statistically different from 0 or not:

H0:μdifference=0HA:μdifference0

The test statistic is calculated as:

t=d¯SE(d), where the SE is: sdn, and d¯ is the average of the pairwise difference

With a degree of freedom of df=n1


Running Paired T-tests in Python

To conduct the paired sample t-test, we can use the stats.ttest_rel() function from SciPy:

from scripy.stats import ttest_rel

# conduct paried t test
ttest_rel(a, b, alternative="two-sided", alpha=0.05)

# a, b - array-like observations of the sample (before and after)
# alternative - type of hypothesis testing (two-tailed, greater, or less)

This returns a tuple of:

(statistic, p-value)


  1. https://sphweb.bumc.bu.edu/otlt/mph-modules/bs/sas/sas4-onesamplettest/SAS4-OneSampleTtest7.html ↩︎

Powered by Forestry.md