Prev: t-Test (independent samples) | Next: One sample t-test
Examples:
- In educational research: suppose we have a group of students and we want to advance their understanding in a particularly demanding topic implementing an innovative instructional method. Before the intervention we administer a knowledge test to assess their prior knowledge on the topic. After the intervention we also conduct an appropriate knowledge test. We can apply a paired t-test to compare the performance of students before and after the didactical intervention, to investigate whether the instructional method had an impact.
- In business: suppose we measure the clients' satisfaction of a business services with an appropriate instrument. Based on their feedback we make improvements and after some time we ask the same people to rate again the services. Afterwards we can use paired t-test to investigate whether the mean value of clients' satisfaction after the improvement intervention is significantly higher than before.
For a deeper analysis and to see how the t-statistic is computed read the "Dependent t-test for paired samples" section @wikipedia
import pandas as pd
import scipy.stats as stats
data = pd.read_excel('../../data/researchdata.xlsx', sheetname="ttest-paired")
print('Data have NaN values')
print(data.head())
print('\n..........\n')
print(data.tail())
# Drop NaN data
dtdrop = data.dropna() # Note that NaN values are dropped in both columns
print('\n\nData without NaN values')
print(dtdrop.head())
print('\n..........\n')
print(dtdrop.tail())
stats.shapiro(dtdrop.Baseline), stats.shapiro(dtdrop.Retest),\
stats.levene(dtdrop.Baseline, dtdrop.Retest)
t, p = stats.ttest_rel(dtdrop.Baseline, dtdrop.Retest)
t, p
t, p = stats.wilcoxon(dtdrop.Baseline, dtdrop.Retest)
. Free learning material
. See full copyright and disclaimer notice