Skip to main content

PyMARE: Python Meta-Analysis & Regression Engine

Project description

PyMARE: Python Meta-Analysis & Regression Engine

A Python library for mixed-effects meta-regression (including meta-analysis).

Latest Version PyPI - Python Version License CircleCI Documentation Status Codecov

PyMARE is alpha software under heavy development; we reserve the right to make major changes to the API.

Quickstart

Install PyMARE from PyPI:

pip install pymare

Or for the bleeding-edge GitHub version:

pip install git+https://github.com/neurostuff/pymare.git

Suppose we have parameter estimates from 8 studies, along with corresponding variances, and a single (fixed) covariate:

y = np.array([-1, 0.5, 0.5, 0.5, 1, 1, 2, 10]) # study-level estimates
v = np.array([1, 1, 2.4, 0.5, 1, 1, 1.2, 1.5]) # study-level variances
X = np.array([1, 1, 2, 2, 4, 4, 2.8, 2.8]) # a fixed study-level covariate

We can conduct a mixed-effects meta-regression using restricted maximum-likelihood (ReML)estimation in PyMARE using the high-level meta_regression function:

from pymare import meta_regression

result = meta_regression(y, v, X, names=['my_cov'], add_intercept=True,
                         method='REML')
print(result.to_df())

This produces the following output:

         name   estimate        se   z-score     p-val  ci_0.025   ci_0.975
0  intercept  -0.106579  2.993715 -0.035601  0.971600 -5.974153   5.760994
1     my_cov   0.769961  1.113344  0.691575  0.489204 -1.412153   2.952075

Alternatively, we can achieve the same outcome using PyMARE's object-oriented API (which the meta_regression function wraps):

from pymare import Dataset
from pymare.estimators import VarianceBasedLikelihoodEstimator

# A handy container we can pass to any estimator
dataset = Dataset(y, v, X)
# Estimator class for likelihood-based methods when variances are known
estimator = VarianceBasedLikelihoodEstimator(method='REML')
# All estimators expose a fit_dataset() method that takes a `Dataset`
# instance as the first (and usually only) argument.
estimator.fit_dataset(dataset)
# Post-fitting we can obtain a MetaRegressionResults instance via .summary()
results = estimator.summary()
# Print summary of results as a pandas DataFrame
print(result.to_df())

And if we want to be even more explicit, we can avoid the Dataset abstraction entirely (though we'll lose some convenient validation checks):

estimator = VarianceBasedLikelihoodEstimator(method='REML')

# X must be 2-d; this is one of the things the Dataset implicitly handles.
X = X[:, None]

estimator.fit(y, v, X)

results = estimator.summary()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyMARE-0.0.2.tar.gz (26.2 kB view details)

Uploaded Source

Built Distribution

PyMARE-0.0.2-py3-none-any.whl (31.7 kB view details)

Uploaded Python 3

File details

Details for the file PyMARE-0.0.2.tar.gz.

File metadata

  • Download URL: PyMARE-0.0.2.tar.gz
  • Upload date:
  • Size: 26.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.22.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for PyMARE-0.0.2.tar.gz
Algorithm Hash digest
SHA256 1b147180059bcca7b93d224328779be101b93a3f708449b7a021d8688861e1bf
MD5 a8d742c7fa80e36e6795922a14b7c771
BLAKE2b-256 4ae7bf2e95a4ea5bc10e9fc3cbfe6ff6a2e2b80747d84f0c1d17afb60c9026c9

See more details on using hashes here.

File details

Details for the file PyMARE-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: PyMARE-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 31.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.22.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for PyMARE-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 815d450a7867e4631dc6979f6f7247e3e3ec74d0f5c58771392dcc241b1d341a
MD5 c8d5845ad7390cb410b5b59a71a9fce5
BLAKE2b-256 11fdcd0d2cfe995565d2a8f820c718e46cbf47146464c62b06e8b32bbecd1030

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page