Skip to content

Commit e30a276

Browse files
committed
Added paper and metadata for JOSS.
1 parent ad23c42 commit e30a276

File tree

4 files changed

+179
-1
lines changed

4 files changed

+179
-1
lines changed

LICENSE.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2017 Eshin Jolly
3+
Copyright (c) 2018 Eshin Jolly
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

codemeta.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"@context": "https://raw.githubusercontent.com/codemeta/codemeta/master/codemeta.jsonld",
3+
"@type": "Code",
4+
"author": [
5+
{
6+
"@id": "",
7+
"@type": "Person",
8+
"email": "[email protected]",
9+
"name": "ejolly",
10+
"affiliation": "Dartmouth College"
11+
}
12+
],
13+
"identifier": "",
14+
"codeRepository": "https://github.com/ejolly/pymer4",
15+
"datePublished": "2018-07-27",
16+
"dateModified": "2018-07-27",
17+
"dateCreated": "2018-07-27",
18+
"description": "A package for estimating multi-level models in Python.",
19+
"keywords": "multi-level modeling, statistics, python, lme4, rpy2, data analysis",
20+
"license": "MIT",
21+
"title": "Pymer4",
22+
"version": "0.5.0"
23+
}

paper.bib

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
@article{Bates:2014,
2+
title={lme4: Linear mixed-effects models using Eigen and S4},
3+
author={Bates, Douglas and Maechler, Martin and Bolker, Ben and Walker, Steven and others},
4+
journal={R package version},
5+
volume={1},
6+
number={7},
7+
pages={1--23},
8+
year={2014}
9+
}
10+
11+
@inproceedings{Seabold:2010,
12+
title={Statsmodels: Econometric and statistical modeling with python},
13+
author={Seabold, Skipper and Perktold, Josef},
14+
booktitle={Proceedings of the 9th Python in Science Conference},
15+
volume={57},
16+
pages={61},
17+
year={2010},
18+
organization={SciPy society Austin}
19+
}
20+
21+
@article{Yarkoni:2016,
22+
title={Bambi: A simple interface for fitting Bayesian mixed effects models},
23+
author={Yarkoni, Tal and Westfall, Jake},
24+
year={2016},
25+
publisher={Open Science Framework}
26+
}
27+
28+
@book{McKinney:2012,
29+
title={Python for data analysis: Data wrangling with Pandas, NumPy, and IPython},
30+
author={McKinney, Wes},
31+
year={2012},
32+
publisher={" O'Reilly Media, Inc."}
33+
}
34+
35+
@article{Gautier:2008,
36+
title={rpy2: A Simple and Efficient Access to R from Python},
37+
author={Gautier, L},
38+
journal={URL http://rpy. sourceforge. net/rpy2. html},
39+
year={2008}
40+
}
41+
42+
@article{Hunter:2007,
43+
title={Matplotlib: A 2D graphics environment},
44+
author={Hunter, John D},
45+
journal={Computing in science \& engineering},
46+
volume={9},
47+
number={3},
48+
pages={90--95},
49+
year={2007},
50+
publisher={IEEE}
51+
}
52+
53+
@article{Waskom:2014,
54+
title={Seaborn: statistical data visualization},
55+
author={Waskom, Michael and Botvinnik, O and Hobson, P and Warmenhoven, J and Cole, JB and Halchenko, Y and Vanderplas, J and Hoyer, S and Villalba, S and Quintero, E and others},
56+
journal={URL: https://seaborn. pydata. org/(visited on 2017-05-15)},
57+
year={2014}
58+
}
59+
60+
@article{Kuznetsova:2017,
61+
title={lmerTest package: tests in linear mixed effects models},
62+
author={Kuznetsova, Alexandra and Brockhoff, Per B and Christensen, Rune Haubo Bojesen},
63+
journal={Journal of Statistical Software},
64+
volume={82},
65+
number={13},
66+
year={2017},
67+
publisher={The Foundation for Open Access Statistics}
68+
}
69+
70+
@article{Lenth:2016,
71+
title={Least-squares means: the R package lsmeans},
72+
author={Lenth, Russell V and others},
73+
journal={Journal of statistical software},
74+
volume={69},
75+
number={1},
76+
pages={1--33},
77+
year={2016}
78+
}
79+
80+
@inproceedings{Huber:1967,
81+
title={The behavior of maximum likelihood estimates under nonstandard conditions},
82+
author={Huber, Peter J and others},
83+
booktitle={Proceedings of the fifth Berkeley symposium on mathematical statistics and probability},
84+
volume={1},
85+
number={1},
86+
pages={221--233},
87+
year={1967},
88+
organization={University of California Press}
89+
}

paper.md

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
title: 'Pymer4: Connecting R and Python for Linear Mixed Modeling'
3+
tags:
4+
- Python
5+
- statistics
6+
- multilevel models
7+
- R
8+
- lme4
9+
authors:
10+
- name: Eshin Jolly
11+
affiliation: "1"
12+
affiliations:
13+
- name: Dartmouth College
14+
index: 1
15+
date: 27 July 2018
16+
bibliography: paper.bib
17+
---
18+
19+
# Summary
20+
21+
In the social sciences the prevalence of clustered, correlated, and/or repeatedly measured data is very common. Modeling such data have classically involved the use of techniques such as the repeated measured analysis of variance (ANOVA) with correction factors applied to account for violations of model assumptions. More recently multi-level or hierarchical linear models have been brought to bear on modeling these kind of data given their flexibility. One of the most popular packages used for this purpose is the powerful `lme4` package in the R statistical programming langauge [@Bates:2014]. While this package is highly favored by individuals that utilize R, to date there exist few comparable packages in the scientific Python community. While some solutions do exist they are often more complicated to use and sometimes less flexible (e.g. `statsmodels` [@Seabold:2010] or require users to adopt a different statistical framework (e.g. Bayesian modeling, `bambi` [@Yarkoni:2016]). This leaves Python users in want for a tool that: a) is highly compatible with existing scientific python tools (e.g. pandas, `numpy`, `matplotlib`, `seaborn` [@McKinney:2012]), b) has an API that is easy to use but not unfamiliar to those who use to `lme4` , c) offers additional functionality that anticipates users' needs when analyzing real data (e.g. significance testing, simulating data, post-hoc analyses, etc).
22+
23+
For these reasons `pymer4` was developed to offer users a way to work with multilevel models within the scientific Python ecosystem. To accomplish this `pymer4` leverages the existing prowess of `lme4`, through the use of the `rpy2` [@Gautier:2008] cross-langauge compatibility library. This offers analysts a tool at the level of abstraction they expect, without needing to worry about writing code specific to interfacing between languages (i.e. custom `rpy2` scripts, functions, etc). Beyond making `lme4` functionality available in python, `pymer4` makes working with multilevel models feel native to working in scientific Python and offers several key features users are most likely to utilize. This includes tight integration with `pandas` and `numpy` for data representation and manipulation, as well as `matplotlib` [@Hunter:2007] and `seaborn` [@Waskom:2014] for data visualization. A key contribution of `pymer4` is its role in providing a unified interface to tasks that are spread over several *different* R-packages. For example, p-value computation lacking in `lme4` is instead provided using the `lmerTest` [@Kuznetsova:2017] library, while post-hoc subgroup comparisons are provided using the `lsmeans` [@Lenth:2016] package. This obviates the need for users to move between libraries, remember idiosyncratic commands, and allows them to instead focus on the analysis at hand.
24+
25+
Additionally, `pymer4` offers several extra features implemented at a high-level of abstraction that would otherwise require users to write custom functions and scripts. These include: simulating various types of data, visualizing model estimates, changing statistical inference procedures (e.g. parametric to non-parametric), automatically storing model fits and residuals, and estimating ordinary-least-squares regression models with various types of robust standard error estimators [@Huber:1967]. Overall, the key contribution of `pymer4` is the development of a consistent and intuitive API by which users can accomplish analytic tasks in a simple and style familiar to users of the scientific Python. We hope this reduces the development "switch-cost" many users experience when moving between tools to accomplish a single goal.
26+
27+
# Examples
28+
29+
Documentation for `pymer4` includes numerous example analyses that demonstrate various functionality. Below we demonstrate how easily `pymer4` integrates into a scientific Python analysis workflow:
30+
31+
```
32+
# imports
33+
import os
34+
import pandas as pd
35+
import seaborn as sns
36+
from pymer4.models import Lmer
37+
38+
# Load included example data with pandas
39+
df = pd.read_csv(os.path.join(get_resource_path(),'sample_data.csv'))
40+
41+
# Fit a multi-level model with 1 categorical predictor using dummy-codes with '1.0' as the reference level
42+
model = Lmer('DV ~ IV3 + (IV3|Group)',data=df
43+
model.fit(factors={'IV3':['1.0','0.5','1.5']})
44+
45+
# Perform post-hoc comparisons on the fitted model
46+
model.post_hoc(marginal_vars='IV3')
47+
48+
# Plot model coefficients
49+
model.plot_summary()
50+
51+
# Plot random effect estimates
52+
model.plot('IV2')
53+
54+
# Visualize residuals with seaborn; residuals are conveniently stored in the model object along with data as a new column
55+
sns.regplot(x= 'IV2',
56+
y= 'residuals',
57+
data= model.data,
58+
fit_reg= False
59+
)
60+
```
61+
62+
# Acknowledgements
63+
64+
The author thanks Luke J. Chang, Jin Hyun Cheong, and Pin-hao Chen for testing and feedback. The author also thanks Jeroen Van Baar for assistance in testing installations on different platforms.
65+
66+
# References

0 commit comments

Comments
 (0)