text: 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())
  Data have NaN values Baseline Retest 0 60 62 1 65 67 2 70 NaN 3 75 74 4 70 72 .......... Baseline Retest 35 55 62 36 60 NaN 37 65 77 38 NaN 72 39 NaN 82 Data without NaN values Baseline Retest 0 60 62 1 65 67 3 75 74 4 70 72 5 65 72 .......... Baseline Retest 31 85 82 33 45 62 34 50 52 35 55 62 37 65 77
  stats.shapiro(dtdrop.Baseline), stats.shapiro(dtdrop.Retest),\ stats.levene(dtdrop.Baseline, dtdrop.Retest)
  ((0.9725646376609802, 0.5921071767807007), (0.934281587600708, 0.057403478771448135), LeveneResult(statistic=0.39299891735835496, pvalue=0.53310546068363462))
  t, p = stats.ttest_rel(dtdrop.Baseline, dtdrop.Retest) t, p
  (-2.509376268415453, 0.01772471118658394)
  t, p = stats.wilcoxon(dtdrop.Baseline, dtdrop.Retest)