question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

This is either a “implement such a test” or a “document it better”:

I’m currently looking for the statsmodel equivalent of (from http://statistic-on-air.blogspot.de/2009/07/paired-students-t-test.html)

a = c(12.9, 13.5, 12.8, 15.6, 17.2, 19.2, 12.6, 15.3, 14.4, 11.3)
b = c(12.7, 13.6, 12.0, 15.2, 16.8, 20.0, 12.0, 15.9, 16.0, 11.1)

t.test(a,b, paired=TRUE)

    Paired t-test

data: a and b
t = -0.2133, df = 9, p-value = 0.8358
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
    -0.5802549 0.4802549
sample estimates:
mean of the differences
    -0.05

I googled for “statsmodels t-test paired” and only found a ttost_paired. Is there simply no paired t-test or am I just not good enough in statistics to find the right test? In the latter case, for the sake of people like me: it would be nice if then the documentation could be adjusted 😃

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:1
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
josef-pktcommented, Dec 7, 2015

Yes, as @dengemann pointed out it’s just a one sample t-test on the difference

>>> a = np.array([12.9, 13.5, 12.8, 15.6, 17.2, 19.2, 12.6, 15.3, 14.4, 11.3])
>>> b = np.array([12.7, 13.6, 12.0, 15.2, 16.8, 20.0, 12.0, 15.9, 16.0, 11.1])
>>> stats.ttest_1samp(a - b, popmean=0)
(-0.21330847512739051, 0.83584000571392769)
>>> stats.ttest_rel(a, b)
(-0.21330847512739051, 0.83584000571392769)

>>> from statsmodels.stats import weightstats as sms
>>> d = sms.DescrStatsW(a - b)
>>> d.ttest_mean()
(-0.21330847512739051, 0.83584000571392769, 9.0)
>>> d.tconfint_mean()
(-0.58025487182119562, 0.48025487182119597)

edit stats is scipy.stats, added ttest_rel also

1reaction
jankatinscommented, Dec 7, 2015

first of all: thanks for the fast help!

I can’t be the first person to google “paired t-test statsmodels” and felt lost. Especially when I see the results of “paired t-test R”.

It would also be nice if statsmodels would wrap the scipy functions to return a nice printable object which is similar to the regression output (or Rs output) and not only the plain numbers. A function like https://stat.ethz.ch/R-manual/R-devel/library/stats/html/t.test.html would be nice…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Paired t-Test | Introduction to Statistics - JMP
The paired t-test is a method used to test whether the mean difference between pairs of measurements is zero or not. When can...
Read more >
Paired t-test - SPH - Boston University
A paired t-test is used when we are interested in the difference between two variables for the same subject. Often the two variables...
Read more >
Paired Sample T-Test - Statistics Solutions
Paired sample t-test is a statistical technique that is used to compare two population means in the case of two samples that are...
Read more >
SPSS Tutorials: Paired Samples t Test - LibGuides
Paired t tests are used to test if the means of two paired measurements, such as pretest/posttest scores, are significantly different.
Read more >
Paired T Test: Definition & When to Use It - Statistics By Jim
Paired t tests are also known as a paired sample t-test or a dependent samples t test. These names reflect the fact that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found