Skip to main content

Pymer4: Generalized Linear & Multi-level Models in Python

image image image
image image image

pymer4 is a statistics library for estimating various regression models, multi-level models, and generalized-linear-mixed models in Python. Jealous of R's lovely model syntax by prefer to work in the scientific Python ecoysystem? This package has got you covered! pymer4 provides a clean interface that hides the back-and-forth code required when moving between R and Python. This is accomplished using rpy2 to interface between langauges.

Check out the documentation here

from pymer4.models import lm, lmer
from pymer4 import load_dataset('sleep')

sleep = load_dataset('sleep')

# Linear regression
ols = lm('Reaction ~ Days', data=sleep)
ols.fit()

# Multi-level model
lmm = lmer('Reaction ~ Days + (Days | Subject)', data=sleep)
lmm.fit()

Why?

The scientific Python ecosystem has tons of fantastic libraries for data-analysis and statistical modeling such as statsmodels, pingouin, scikit-learn, and bambi for bayesian models to name a few. However, Python still sorely lacks a unified formula-based modeling interface that rivals what's available in R (and the tidyverse) for frequentist statistics. This makes it frustrating for beginners and advanced Python analysts-alike to jump between different tools in order to accomplish a single task. So, rather than completely reinvent the wheel, pymer4 aims to bring the best R's robust modeling capabilities to Python for the most common General(ized)-Linear-(Mixed)-Modeling (GLMMs) needs in the social and behavioral sciences.

At the same time, pymer4 includes numerous quality-of-life features for common tasks you're likely to do when working with models (e.g. automatically calculated fit statistics, residuals, p-values for mixed-models, bootstrapped confidence-intervals, random-effects deviances, etc). By bringing together functionality spread across several popular R tools, we've aimed for intuitive-usability. pymer4 also notably builds on top of the polars Dataframe library rather than pandas. This keeps code simple, fast, and efficient, while opening the door for enhanced future functionality.

Citing

If you use pymer4 in your own work, please cite:

Jolly, (2018). Pymer4: Connecting R and Python for Linear Mixed Modeling. Journal of Open Source Software, 3(31), 862, https://doi.org/10.21105/joss.00862

Contributing

Contributions are always welcome!
If you are interested in contributing feel free to check out the open issues and check out the contribution guidelines.

Metadata

Release files for pymer4 0.9.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pymer4 0.9.2
File Size Uploaded
pymer4-0.9.2.tar.gz 2.4 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for pymer4 0.9.2
File Interpreter ABI Platform
pymer4-0.9.2-py3-none-any.whl Python 3 none any Details

Total release size: 4.7 MB

Release files / pymer4-0.9.2.tar.gz

Download URL pymer4-0.9.2.tar.gz
Size 2.4 MB
Tags Source
SHA-256 checksum
How to use checksums
85715b642affd02fac4e26031aa5c31eafaa1ce72baab4bb67bb9c712b0b4ccf
BLAKE2b-256 checksum
How to use checksums
01e5be115cff3d8e6575c3aed446a27fd786ed696f9bba11652a5f32982d20e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / pymer4-0.9.2-py3-none-any.whl

Download URL pymer4-0.9.2-py3-none-any.whl
Size 2.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
e1e2eb0bdb06610b8e7ff0f4caacac881d945a374ad9f70b5c102710bb5b31df
BLAKE2b-256 checksum
How to use checksums
a50fef5bfc3951ba9f04ddcab48da9902f4f2f7c0dad89d714b176136a2d9c3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release history Release notifications | RSS feed

This release

0.9.2 This release

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.8

2 release files

0.7.7

2 release files

0.7.6

2 release files

0.7.5

2 release files

0.7.4

1 release file

0.7.3

1 release file

0.7.2

1 release file

0.7.1

1 release file

0.7.0

2 release files

0.6.0

2 release files

0.5.0

3 release files

0.4.0

2 release files

0.3.2

2 release files

0.2.2

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page