I'm trying to conduct a paired samples t-test in Python (statsmodels package), but I don't see a function for it in their documentation. The closest I can find is ttost_paired, but I don't think its correct as their null hypothesis is that the mean difference is > or < some boundary value, whereas for my desired test the null is x1 - x2 = 0

A few questions:

  1. Is there a way to do a paired samples t-test in statsmodels that I'm missing?
  2. Is there a way to use ttost_paired to do what I want?
  3. They do also have an independent samples ttest. What could go wrong if I use an independent ttest on paired data?

I know I can do a paired t-test using scipy but I'm wondering specifically about statsmodels

  • 2
    $\begingroup$ A paired sample t-test is just a one sample t-test on the difference of the two samples, i.e. t_test(x1 - x2, ...). $\endgroup$
    – Josef
    Oct 10, 2018 at 0:49

3 Answers 3


the function ttost is not a t-test and therefore is not suitable for your purposes. The TTOST is a test of non-equivalence. It employes two one-sided t-tests in order to verify if both samples are equivalent or not. Please, have a look at the function documentation.

There exists the ttest_mean function on the statsmodels package. However, it does not indicate if the test is conducted with paired samples or not. Thus, I recommend you to use the scipy.stats t-test.

And about your last question:

They do also have an independent samples ttest. What could go wrong if I use an independent ttest on paired data?

The paired t-test reduces intersubject variability. Thus, it is theoretically more powerful than the unpaired t-test.


You can use the ttest_rel function in scipy.stats:

Calculate the t-test on TWO RELATED samples of scores, a and b. This is a two-sided test for the null hypothesis that 2 related or repeated samples have identical average (expected) values.


Standard paired t-test for two samples y1 and y2 is just the one sample t-test applied on the difference d = y1 - y2.
The same applies when using a normal distribution in a z-test.

(That and the availability of paired t-test in scipy.stats are the reasons why statsmodels currently does not implement a separate paired t-test.)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.