Common statistical tests are linear models: Python port
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
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
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
for more details.