Skip to content
Python port of "Common statistical tests are linear models" by Jonas Kristoffer Lindeløv.
HTML Jupyter Notebook Python Other
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Common statistical tests are linear models: Python port

Build Status Binder

A Python port of Jonas Kristoffer Lindeløv's post Common statistical tests are linear models (or: how to teach stats), which originally had accompanying code in R.

Notes on Python port

The original post used R's built-in functions to verify that the linear models were indeed equivalent to the statistical tests (by showing that the p-values, t-values, and other such statistics, were the same in either case). In this Python port, we instead verify that scipy.stats functions and smf.ols output agree.

The original R post had four appendices, each of which demonstrated (through numerical simulation) that a common statistical test was well-approximated by a linear model. These simulations have not been ported to Python (yet!). This is an outstanding issue. In the meantime, please refer to the original appendices upstream for the simulations.

Finally, certain statistical functions and tests are supported by neither statsmodels or scipy, the two statistical Python libraries used in this port. R code with no simple Python equivalent (mainly in sections 6 and 7, "Three or more means" and "Proportions: Chi-square is a log-linear model") has not been ported. Such code has been noted in yellow warning boxes.


Please refer to the contributing guide for project structure information and development instructions.


This work is licensed under a Creative Commons Attribution 4.0 International License. Please refer to LICENSE.txt for more details.

You can’t perform that action at this time.