https://github.com/ejolly/pymer4
All the convenience of lme4 in python
https://github.com/ejolly/pymer4
lme4 mixed-models python
Last synced: about 1 month ago
JSON representation
All the convenience of lme4 in python
- Host: GitHub
- URL: https://github.com/ejolly/pymer4
- Owner: ejolly
- License: mit
- Created: 2017-05-08T07:27:02.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2025-04-02T00:49:38.000Z (2 months ago)
- Last Synced: 2025-04-22T08:43:07.500Z (about 2 months ago)
- Topics: lme4, mixed-models, python
- Language: Python
- Homepage: http://eshinjolly.com/pymer4
- Size: 7.86 MB
- Stars: 199
- Watchers: 5
- Forks: 26
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- Contributing: docs/contributing.rst
- License: LICENSE.txt
- Codemeta: codemeta.json
Awesome Lists containing this project
README
[](https://github.com/ejolly/pymer4/actions/workflows/Tests.yml)
[](https://github.com/ejolly/pymer4/actions/workflows/Build.yml)
[](https://badge.fury.io/py/pymer4)
[](https://anaconda.org/ejolly/pymer4)
[](https://anaconda.org/ejolly/pymer4)
[](https://pepy.tech/project/pymer4)
[](https://doi.org/10.21105/joss.00862)
[](https://zenodo.org/record/1523205)

[](https://github.com/ejolly/pymer4/issues)# Pymer4
❗️⚠️ **[Contributors wanted](https://github.com/ejolly/pymer4/issues/61)** ⚠️❗️
Pymer4 is a statistics library for estimating various regression and multi-level models in Python. Love [lme4](https://cran.r-project.org/web/packages/lme4/index.html) in R, but prefer to work in the scientific Python ecosystem? 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. In other words, you can work completely in Python, never having to deal with R, but get (most) of lme4’s goodness. This is accomplished using [rpy2](hhttps://rpy2.github.io/doc/latest/html/index.html/) to interface between langauges.
Additionally `pymer4` can fit various additional regression models with some bells, such as robust standard errors, and two-stage regression (summary statistics) models. See the features page for more information.
**TL;DR** this package is your new simple Pythonic drop-in replacement for `lm()` or `glmer()` in R.
For example:
```python
# Assuming you have a pandas dataframe in tidy/long format
# with DV and IV columns for dependent/outcome vars and
# independent/predictor varsmodel = Lmer('DV ~ IV1 + IV2 + (IV+IV2|Group)', data=dataframe)
# Fit and print an R/statsmodels style summary
# with t/z-tests, CIs, and p-values
model.fit()# Access model attributes
model.BIC
model.residuals# Get fitted parameters
model.coef # population parameters
model.fixef # group/cluster estimates (BLUPs)
model.ranef # group/cluster deviates
```## Documentation
Check out the [documentation site](http://eshinjolly.com/pymer4/) for detailed tutorial examples, API documentation, and installation instructions!
## Installation
Installing via [Anaconda](https://www.anacnda.com/products/individual) is the preferred installation method. Follow the directions [here](https://eshinjolly.com/pymer4/installation.html).
## Local build
```
conda create -n build python=3.8 pip conda-build
conda activate build
conda-build ./conda --python=3.8 -c https://conda.anaconda.org/conda-forge --output-folder ./conda/build --output ./conda/build
tarball=$(conda-build ./conda --python=3.8 --output | tail -1)
conda convert -p linux-64 -p win-64 $tarball -o ./conda/build
```## Local upload
```
# after
# conda install anaconda-client
# anaconda login# pre-release
anaconda upload ./conda/build/**/pymer4*.tar.bz2 -l "pre-release"# main
anaconda upload ./conda/build/**/pymer4*.tar.bz2 -l "main"
```## Contributing
Contributions are *always welcome*!
If you are interested in contributing feel free to check out the [open issues](https://github.com/ejolly/pymer4/issues), [development roadmap on Trello](https://trello.com/b/gGKmeAJ4), or submit pull requests for additional features or bug fixes. If you do make a pull request, please do so by forking the [development branch](https://github.com/ejolly/pymer4/tree/dev) and taking note of the [contribution guidelines](https://eshinjolly.com/pymer4/contributing.html).## Contributors
[](https://github.com/turbach)
[](https://github.com/Shotgunosine)![]()