PyMARE 0.0.10__tar.gz → 0.0.11__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. {PyMARE-0.0.10 → pymare-0.0.11}/MANIFEST.in +1 -0
  2. pymare-0.0.11/PKG-INFO +99 -0
  3. pymare-0.0.11/PyMARE.egg-info/PKG-INFO +99 -0
  4. pymare-0.0.11/PyMARE.egg-info/SOURCES.txt +52 -0
  5. {PyMARE-0.0.10 → pymare-0.0.11}/PyMARE.egg-info/requires.txt +12 -17
  6. {PyMARE-0.0.10 → pymare-0.0.11}/README.md +2 -0
  7. {PyMARE-0.0.10 → pymare-0.0.11}/pymare/_version.py +3 -3
  8. {PyMARE-0.0.10 → pymare-0.0.11}/pymare/core.py +70 -21
  9. pymare-0.0.11/pymare/estimators/combination.py +720 -0
  10. pymare-0.0.11/pymare/estimators/estimators.py +2289 -0
  11. pymare-0.0.11/pymare/estimators/stan/meta_regression.stan +45 -0
  12. pymare-0.0.11/pymare/results.py +1161 -0
  13. pymare-0.0.11/pymare/stats.py +2478 -0
  14. pymare-0.0.11/pymare/tests/__init__.py +1 -0
  15. pymare-0.0.11/pymare/tests/conftest.py +508 -0
  16. pymare-0.0.11/pymare/tests/data/metafor_reference.json +1450 -0
  17. pymare-0.0.11/pymare/tests/data/metafor_small_sample.csv +41 -0
  18. pymare-0.0.11/pymare/tests/data/robumeta_correlated_effects.csv +28 -0
  19. pymare-0.0.11/pymare/tests/data/robumeta_reference.json +130 -0
  20. pymare-0.0.11/pymare/tests/data/stan_validation.json +431 -0
  21. pymare-0.0.11/pymare/tests/test_combination_tests.py +644 -0
  22. pymare-0.0.11/pymare/tests/test_core.py +178 -0
  23. pymare-0.0.11/pymare/tests/test_datasets.py +13 -0
  24. pymare-0.0.11/pymare/tests/test_effectsize_base.py +161 -0
  25. pymare-0.0.11/pymare/tests/test_effectsize_expressions.py +49 -0
  26. pymare-0.0.11/pymare/tests/test_estimators.py +1116 -0
  27. pymare-0.0.11/pymare/tests/test_metafor_alignment.py +189 -0
  28. pymare-0.0.11/pymare/tests/test_results.py +708 -0
  29. pymare-0.0.11/pymare/tests/test_robumeta_alignment.py +87 -0
  30. pymare-0.0.11/pymare/tests/test_stan_estimators.py +787 -0
  31. pymare-0.0.11/pymare/tests/test_stats.py +1152 -0
  32. pymare-0.0.11/pymare/tests/test_utils.py +41 -0
  33. pymare-0.0.11/pymare/tests/utils.py +173 -0
  34. pymare-0.0.11/pypi_description.md +15 -0
  35. {PyMARE-0.0.10 → pymare-0.0.11}/pyproject.toml +9 -0
  36. {PyMARE-0.0.10 → pymare-0.0.11}/setup.cfg +16 -12
  37. PyMARE-0.0.10/PKG-INFO +0 -43
  38. PyMARE-0.0.10/PyMARE.egg-info/PKG-INFO +0 -43
  39. PyMARE-0.0.10/PyMARE.egg-info/SOURCES.txt +0 -30
  40. PyMARE-0.0.10/pymare/estimators/combination.py +0 -262
  41. PyMARE-0.0.10/pymare/estimators/estimators.py +0 -684
  42. PyMARE-0.0.10/pymare/results.py +0 -605
  43. PyMARE-0.0.10/pymare/stats.py +0 -241
  44. {PyMARE-0.0.10 → pymare-0.0.11}/LICENSE +0 -0
  45. {PyMARE-0.0.10 → pymare-0.0.11}/PyMARE.egg-info/dependency_links.txt +0 -0
  46. {PyMARE-0.0.10 → pymare-0.0.11}/PyMARE.egg-info/not-zip-safe +0 -0
  47. {PyMARE-0.0.10 → pymare-0.0.11}/PyMARE.egg-info/top_level.txt +0 -0
  48. {PyMARE-0.0.10 → pymare-0.0.11}/pymare/__init__.py +0 -0
  49. {PyMARE-0.0.10 → pymare-0.0.11}/pymare/datasets/__init__.py +0 -0
  50. {PyMARE-0.0.10 → pymare-0.0.11}/pymare/datasets/metadat.py +0 -0
  51. {PyMARE-0.0.10 → pymare-0.0.11}/pymare/effectsize/__init__.py +0 -0
  52. {PyMARE-0.0.10 → pymare-0.0.11}/pymare/effectsize/base.py +0 -0
  53. {PyMARE-0.0.10 → pymare-0.0.11}/pymare/effectsize/expressions.json +0 -0
  54. {PyMARE-0.0.10 → pymare-0.0.11}/pymare/effectsize/expressions.py +0 -0
  55. {PyMARE-0.0.10 → pymare-0.0.11}/pymare/estimators/__init__.py +0 -0
  56. {PyMARE-0.0.10 → pymare-0.0.11}/pymare/resources/datasets/michael2013.json +0 -0
  57. {PyMARE-0.0.10 → pymare-0.0.11}/pymare/resources/datasets/michael2013.tsv +0 -0
  58. {PyMARE-0.0.10 → pymare-0.0.11}/pymare/utils.py +0 -0
  59. {PyMARE-0.0.10 → pymare-0.0.11}/setup.py +0 -0
  60. {PyMARE-0.0.10 → pymare-0.0.11}/versioneer.py +0 -0
@@ -1,2 +1,3 @@
1
1
  include versioneer.py
2
2
  include pymare/_version.py
3
+ recursive-include pymare *.stan
pymare-0.0.11/PKG-INFO ADDED
@@ -0,0 +1,99 @@
1
+ Metadata-Version: 2.4
2
+ Name: PyMARE
3
+ Version: 0.0.11
4
+ Summary: PyMARE: Python Meta-Analysis & Regression Engine
5
+ Home-page: https://github.com/neurostuff/PyMARE
6
+ Author: PyMARE developers
7
+ Author-email: tsalo006@fiu.edu
8
+ Maintainer: Taylor Salo
9
+ Maintainer-email: tsalo006@fiu.edu
10
+ License: MIT
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Scientific/Engineering
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: numpy>=1.8.0
26
+ Requires-Dist: pandas
27
+ Requires-Dist: scipy
28
+ Requires-Dist: sympy
29
+ Provides-Extra: doc
30
+ Requires-Dist: m2r2; extra == "doc"
31
+ Requires-Dist: matplotlib; extra == "doc"
32
+ Requires-Dist: mistune; extra == "doc"
33
+ Requires-Dist: numpydoc; extra == "doc"
34
+ Requires-Dist: pillow; extra == "doc"
35
+ Requires-Dist: recommonmark; extra == "doc"
36
+ Requires-Dist: seaborn; extra == "doc"
37
+ Requires-Dist: sphinx>=3.5; extra == "doc"
38
+ Requires-Dist: sphinx-argparse; extra == "doc"
39
+ Requires-Dist: sphinx-copybutton; extra == "doc"
40
+ Requires-Dist: sphinx_gallery; extra == "doc"
41
+ Requires-Dist: sphinx_rtd_theme; extra == "doc"
42
+ Requires-Dist: sphinxcontrib-bibtex; extra == "doc"
43
+ Requires-Dist: sphinxcontrib-mermaid; extra == "doc"
44
+ Requires-Dist: docutils<0.21,>=0.18.1; extra == "doc"
45
+ Provides-Extra: tests
46
+ Requires-Dist: coverage; extra == "tests"
47
+ Requires-Dist: flake8; extra == "tests"
48
+ Requires-Dist: flake8-black; extra == "tests"
49
+ Requires-Dist: flake8-docstrings; extra == "tests"
50
+ Requires-Dist: flake8-isort; extra == "tests"
51
+ Requires-Dist: pytest; extra == "tests"
52
+ Requires-Dist: pytest-cov; extra == "tests"
53
+ Provides-Extra: stan
54
+ Requires-Dist: cmdstanpy<2,>=1.2; extra == "stan"
55
+ Requires-Dist: arviz>=0.17; extra == "stan"
56
+ Requires-Dist: scipy<1.13; python_version < "3.10" and extra == "stan"
57
+ Provides-Extra: all
58
+ Requires-Dist: m2r2; extra == "all"
59
+ Requires-Dist: matplotlib; extra == "all"
60
+ Requires-Dist: mistune; extra == "all"
61
+ Requires-Dist: numpydoc; extra == "all"
62
+ Requires-Dist: pillow; extra == "all"
63
+ Requires-Dist: recommonmark; extra == "all"
64
+ Requires-Dist: seaborn; extra == "all"
65
+ Requires-Dist: sphinx>=3.5; extra == "all"
66
+ Requires-Dist: sphinx-argparse; extra == "all"
67
+ Requires-Dist: sphinx-copybutton; extra == "all"
68
+ Requires-Dist: sphinx_gallery; extra == "all"
69
+ Requires-Dist: sphinx_rtd_theme; extra == "all"
70
+ Requires-Dist: sphinxcontrib-bibtex; extra == "all"
71
+ Requires-Dist: sphinxcontrib-mermaid; extra == "all"
72
+ Requires-Dist: docutils<0.21,>=0.18.1; extra == "all"
73
+ Requires-Dist: coverage; extra == "all"
74
+ Requires-Dist: flake8; extra == "all"
75
+ Requires-Dist: flake8-black; extra == "all"
76
+ Requires-Dist: flake8-docstrings; extra == "all"
77
+ Requires-Dist: flake8-isort; extra == "all"
78
+ Requires-Dist: pytest; extra == "all"
79
+ Requires-Dist: pytest-cov; extra == "all"
80
+ Requires-Dist: cmdstanpy<2,>=1.2; extra == "all"
81
+ Requires-Dist: arviz>=0.17; extra == "all"
82
+ Requires-Dist: scipy<1.13; python_version < "3.10" and extra == "all"
83
+ Dynamic: license-file
84
+
85
+ # PyMARE: Python Meta-Analysis & Regression Engine
86
+
87
+ A Python library for mixed-effects meta-regression (including
88
+ meta-analysis).
89
+
90
+ # License
91
+
92
+ PYMARE is licensed under the terms of the MIT license. See
93
+ the file \'LICENSE\' for information on the history of this software,
94
+ terms & conditions for usage, and a DISCLAIMER OF ALL WARRANTIES.
95
+
96
+ All trademarks referenced herein are property of their respective
97
+ holders.
98
+
99
+ Copyright (c) 2019\--, PyMARE developers
@@ -0,0 +1,99 @@
1
+ Metadata-Version: 2.4
2
+ Name: PyMARE
3
+ Version: 0.0.11
4
+ Summary: PyMARE: Python Meta-Analysis & Regression Engine
5
+ Home-page: https://github.com/neurostuff/PyMARE
6
+ Author: PyMARE developers
7
+ Author-email: tsalo006@fiu.edu
8
+ Maintainer: Taylor Salo
9
+ Maintainer-email: tsalo006@fiu.edu
10
+ License: MIT
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Scientific/Engineering
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: numpy>=1.8.0
26
+ Requires-Dist: pandas
27
+ Requires-Dist: scipy
28
+ Requires-Dist: sympy
29
+ Provides-Extra: doc
30
+ Requires-Dist: m2r2; extra == "doc"
31
+ Requires-Dist: matplotlib; extra == "doc"
32
+ Requires-Dist: mistune; extra == "doc"
33
+ Requires-Dist: numpydoc; extra == "doc"
34
+ Requires-Dist: pillow; extra == "doc"
35
+ Requires-Dist: recommonmark; extra == "doc"
36
+ Requires-Dist: seaborn; extra == "doc"
37
+ Requires-Dist: sphinx>=3.5; extra == "doc"
38
+ Requires-Dist: sphinx-argparse; extra == "doc"
39
+ Requires-Dist: sphinx-copybutton; extra == "doc"
40
+ Requires-Dist: sphinx_gallery; extra == "doc"
41
+ Requires-Dist: sphinx_rtd_theme; extra == "doc"
42
+ Requires-Dist: sphinxcontrib-bibtex; extra == "doc"
43
+ Requires-Dist: sphinxcontrib-mermaid; extra == "doc"
44
+ Requires-Dist: docutils<0.21,>=0.18.1; extra == "doc"
45
+ Provides-Extra: tests
46
+ Requires-Dist: coverage; extra == "tests"
47
+ Requires-Dist: flake8; extra == "tests"
48
+ Requires-Dist: flake8-black; extra == "tests"
49
+ Requires-Dist: flake8-docstrings; extra == "tests"
50
+ Requires-Dist: flake8-isort; extra == "tests"
51
+ Requires-Dist: pytest; extra == "tests"
52
+ Requires-Dist: pytest-cov; extra == "tests"
53
+ Provides-Extra: stan
54
+ Requires-Dist: cmdstanpy<2,>=1.2; extra == "stan"
55
+ Requires-Dist: arviz>=0.17; extra == "stan"
56
+ Requires-Dist: scipy<1.13; python_version < "3.10" and extra == "stan"
57
+ Provides-Extra: all
58
+ Requires-Dist: m2r2; extra == "all"
59
+ Requires-Dist: matplotlib; extra == "all"
60
+ Requires-Dist: mistune; extra == "all"
61
+ Requires-Dist: numpydoc; extra == "all"
62
+ Requires-Dist: pillow; extra == "all"
63
+ Requires-Dist: recommonmark; extra == "all"
64
+ Requires-Dist: seaborn; extra == "all"
65
+ Requires-Dist: sphinx>=3.5; extra == "all"
66
+ Requires-Dist: sphinx-argparse; extra == "all"
67
+ Requires-Dist: sphinx-copybutton; extra == "all"
68
+ Requires-Dist: sphinx_gallery; extra == "all"
69
+ Requires-Dist: sphinx_rtd_theme; extra == "all"
70
+ Requires-Dist: sphinxcontrib-bibtex; extra == "all"
71
+ Requires-Dist: sphinxcontrib-mermaid; extra == "all"
72
+ Requires-Dist: docutils<0.21,>=0.18.1; extra == "all"
73
+ Requires-Dist: coverage; extra == "all"
74
+ Requires-Dist: flake8; extra == "all"
75
+ Requires-Dist: flake8-black; extra == "all"
76
+ Requires-Dist: flake8-docstrings; extra == "all"
77
+ Requires-Dist: flake8-isort; extra == "all"
78
+ Requires-Dist: pytest; extra == "all"
79
+ Requires-Dist: pytest-cov; extra == "all"
80
+ Requires-Dist: cmdstanpy<2,>=1.2; extra == "all"
81
+ Requires-Dist: arviz>=0.17; extra == "all"
82
+ Requires-Dist: scipy<1.13; python_version < "3.10" and extra == "all"
83
+ Dynamic: license-file
84
+
85
+ # PyMARE: Python Meta-Analysis & Regression Engine
86
+
87
+ A Python library for mixed-effects meta-regression (including
88
+ meta-analysis).
89
+
90
+ # License
91
+
92
+ PYMARE is licensed under the terms of the MIT license. See
93
+ the file \'LICENSE\' for information on the history of this software,
94
+ terms & conditions for usage, and a DISCLAIMER OF ALL WARRANTIES.
95
+
96
+ All trademarks referenced herein are property of their respective
97
+ holders.
98
+
99
+ Copyright (c) 2019\--, PyMARE developers
@@ -0,0 +1,52 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ pypi_description.md
5
+ pyproject.toml
6
+ setup.cfg
7
+ setup.py
8
+ versioneer.py
9
+ PyMARE.egg-info/PKG-INFO
10
+ PyMARE.egg-info/SOURCES.txt
11
+ PyMARE.egg-info/dependency_links.txt
12
+ PyMARE.egg-info/not-zip-safe
13
+ PyMARE.egg-info/requires.txt
14
+ PyMARE.egg-info/top_level.txt
15
+ pymare/__init__.py
16
+ pymare/_version.py
17
+ pymare/core.py
18
+ pymare/results.py
19
+ pymare/stats.py
20
+ pymare/utils.py
21
+ pymare/datasets/__init__.py
22
+ pymare/datasets/metadat.py
23
+ pymare/effectsize/__init__.py
24
+ pymare/effectsize/base.py
25
+ pymare/effectsize/expressions.json
26
+ pymare/effectsize/expressions.py
27
+ pymare/estimators/__init__.py
28
+ pymare/estimators/combination.py
29
+ pymare/estimators/estimators.py
30
+ pymare/estimators/stan/meta_regression.stan
31
+ pymare/resources/datasets/michael2013.json
32
+ pymare/resources/datasets/michael2013.tsv
33
+ pymare/tests/__init__.py
34
+ pymare/tests/conftest.py
35
+ pymare/tests/test_combination_tests.py
36
+ pymare/tests/test_core.py
37
+ pymare/tests/test_datasets.py
38
+ pymare/tests/test_effectsize_base.py
39
+ pymare/tests/test_effectsize_expressions.py
40
+ pymare/tests/test_estimators.py
41
+ pymare/tests/test_metafor_alignment.py
42
+ pymare/tests/test_results.py
43
+ pymare/tests/test_robumeta_alignment.py
44
+ pymare/tests/test_stan_estimators.py
45
+ pymare/tests/test_stats.py
46
+ pymare/tests/test_utils.py
47
+ pymare/tests/utils.py
48
+ pymare/tests/data/metafor_reference.json
49
+ pymare/tests/data/metafor_small_sample.csv
50
+ pymare/tests/data/robumeta_correlated_effects.csv
51
+ pymare/tests/data/robumeta_reference.json
52
+ pymare/tests/data/stan_validation.json
@@ -1,14 +1,7 @@
1
- pandas
2
- sympy
3
- wrapt
4
-
5
- [:python_version != "3.9" or extra != "stan"]
6
1
  numpy>=1.8.0
2
+ pandas
7
3
  scipy
8
-
9
- [:python_version == "3.9" and extra == "stan"]
10
- numpy<2.0,>=1.8.0
11
- scipy<1.13
4
+ sympy
12
5
 
13
6
  [all]
14
7
  m2r2
@@ -26,17 +19,18 @@ sphinx_rtd_theme
26
19
  sphinxcontrib-bibtex
27
20
  sphinxcontrib-mermaid
28
21
  docutils<0.21,>=0.18.1
29
- codecov
30
22
  coverage
31
- coveralls
32
23
  flake8
33
24
  flake8-black
34
25
  flake8-docstrings
35
26
  flake8-isort
36
27
  pytest
37
28
  pytest-cov
38
- pystan
39
- arviz
29
+ cmdstanpy<2,>=1.2
30
+ arviz>=0.17
31
+
32
+ [all:python_version < "3.10"]
33
+ scipy<1.13
40
34
 
41
35
  [doc]
42
36
  m2r2
@@ -56,13 +50,14 @@ sphinxcontrib-mermaid
56
50
  docutils<0.21,>=0.18.1
57
51
 
58
52
  [stan]
59
- pystan
60
- arviz
53
+ cmdstanpy<2,>=1.2
54
+ arviz>=0.17
55
+
56
+ [stan:python_version < "3.10"]
57
+ scipy<1.13
61
58
 
62
59
  [tests]
63
- codecov
64
60
  coverage
65
- coveralls
66
61
  flake8
67
62
  flake8-black
68
63
  flake8-docstrings
@@ -7,6 +7,8 @@ A Python library for mixed-effects meta-regression (including meta-analysis).
7
7
  [![DOI](https://zenodo.org/badge/228903736.svg)](https://zenodo.org/badge/latestdoi/228903736)
8
8
  [![Documentation Status](https://readthedocs.org/projects/pymare/badge/?version=latest)](http://pymare.readthedocs.io/en/latest/?badge=latest)
9
9
  ![GitHub CI](https://github.com/neurostuff/pymare/actions/workflows/testing.yml/badge.svg)
10
+ ![Lint](https://github.com/neurostuff/pymare/actions/workflows/linting.yml/badge.svg)
11
+ ![robumeta alignment](https://github.com/neurostuff/pymare/actions/workflows/robumeta-alignment.yml/badge.svg)
10
12
  [![Codecov](https://codecov.io/gh/neurostuff/PyMARE/branch/master/graph/badge.svg)](https://codecov.io/gh/neurostuff/pymare)
11
13
 
12
14
  **PyMARE is alpha software under heavy development; we reserve the right to make major changes to the API.**
@@ -8,11 +8,11 @@ import json
8
8
 
9
9
  version_json = '''
10
10
  {
11
- "date": "2025-04-28T12:37:45-0500",
11
+ "date": "2026-08-20T15:09:51-0500",
12
12
  "dirty": false,
13
13
  "error": null,
14
- "full-revisionid": "d79d3e37c84f969d75b0190d2110e8aea16ef852",
15
- "version": "0.0.10"
14
+ "full-revisionid": "d882dfbda4ecb4bfed59b62a9842067942575c80",
15
+ "version": "0.0.11"
16
16
  }
17
17
  ''' # END VERSION_JSON
18
18
 
@@ -24,27 +24,34 @@ class Dataset:
24
24
  Parameters
25
25
  ----------
26
26
  y : None or :obj:`numpy.ndarray` of shape (K,) or :obj:`str`, optional
27
- 1d array of study-level estimates with length K, or the name of the column in data
27
+ 1d array of observation-level estimates with length K, or the name of the column in data
28
28
  containing the y values.
29
29
  Default = None.
30
30
  v : None or :obj:`numpy.ndarray` of shape (K,) or :obj:`str`, optional
31
- 1d array of study-level variances with length K, or the name of the column in data
31
+ 1d array of observation-level variances with length K, or the name of the column in data
32
32
  containing v values.
33
33
  Default = None.
34
34
  X : None or :obj:`numpy.ndarray` of shape (K,[P]) or :obj:`list` of :obj:`str`, optional
35
- 1d or 2d array containing study-level predictors (dimensions K x P),
35
+ 1d or 2d array containing observation-level predictors (dimensions K x P),
36
36
  or a list of strings giving the names of the columns in data containing the X values.
37
37
  Default = None.
38
38
  n : None or :obj:`numpy.ndarray` of shape (K,) or :obj:`str`, optional
39
- 1d array of study-level sample sizes (length K), or the name of the corresponding column
40
- in ``data``.
39
+ 1d array of observation-level ``n`` values (length K), or the name of the
40
+ corresponding column in ``data``.
41
+ Default = None.
42
+ g : None or :obj:`numpy.ndarray` of shape (K,) or :obj:`str`, optional
43
+ 1d array of group labels with length K, or the name of the
44
+ corresponding column in ``data``. Observations sharing a label are
45
+ treated as statistically dependent.
46
+ Estimators that support dependent estimates use this to widen their inference
47
+ accordingly; estimators that do not simply ignore it.
41
48
  Default = None.
42
49
  data : None or :obj:`pandas.DataFrame`, optional
43
- A pandas DataFrame containing y, v, X, and/or n values.
50
+ A pandas DataFrame containing y, v, X, n, and/or g values.
44
51
  By default, columns are expected to have the same names as arguments
45
52
  (e.g., the y values will be expected in the 'y' column).
46
53
  This can be modified by passing strings giving column names to any of the ``y``, ``v``,
47
- ``X``, or ``n`` arguments.
54
+ ``X``, ``n``, or ``g`` arguments.
48
55
  Default = None.
49
56
  X_names : None or :obj:`list` of :obj:`str`, optional
50
57
  List of length P containing the names of the predictors.
@@ -57,7 +64,15 @@ class Dataset:
57
64
  """
58
65
 
59
66
  def __init__(
60
- self, y=None, v=None, X=None, n=None, data=None, X_names=None, add_intercept=True
67
+ self,
68
+ y=None,
69
+ v=None,
70
+ X=None,
71
+ n=None,
72
+ data=None,
73
+ X_names=None,
74
+ add_intercept=True,
75
+ g=None,
61
76
  ):
62
77
  if y is None and data is None:
63
78
  raise ValueError(
@@ -86,16 +101,36 @@ class Dataset:
86
101
  if (n is not None) or ("n" in data.columns):
87
102
  n = data.loc[:, n or "n"].values
88
103
 
104
+ # g is optional. Compare against None explicitly: `g or "g"` calls
105
+ # bool() on the value, which raises for an array of labels passed
106
+ # alongside a DataFrame.
107
+ if (g is not None) or ("g" in data.columns):
108
+ g = data.loc[:, "g" if g is None else g].values if np.ndim(g) == 0 else g
109
+
89
110
  self.y = ensure_2d(y)
90
111
  self.v = ensure_2d(v)
91
112
  self.n = ensure_2d(n)
113
+ self.g = ensure_2d(g)
92
114
  X, names = self._get_predictors(X, X_names, add_intercept)
93
115
  self.X = X
94
116
  self.X_names = names
95
117
 
96
118
  _check_inputs_shape(self.y, self.X, "y", "X", row=True)
97
119
  _check_inputs_shape(self.y, self.v, "y", "v", row=True, column=True)
98
- _check_inputs_shape(self.y, self.n, "y", "n", row=True, column=True)
120
+ _check_inputs_shape(self.y, self.n, "y", "n", row=True)
121
+ # A single column of n broadcasts across parallel datasets. The
122
+ # estimators already handle that, and per-observation quantities such
123
+ # as n or weights usually do not vary by parallel dataset.
124
+ if self.n is not None and self.n.shape[1] != 1:
125
+ _check_inputs_shape(self.y, self.n, "y", "n", column=True)
126
+ _check_inputs_shape(self.y, self.g, "y", "g", row=True)
127
+ if self.g is not None and self.g.shape[1] != 1:
128
+ # One label per observation. A (K, D) array would be silently
129
+ # reduced to its first column later, quietly discarding the rest.
130
+ raise ValueError(
131
+ "g must contain one group label per observation, with shape "
132
+ f"(K,) or (K, 1); got {self.g.shape}."
133
+ )
99
134
 
100
135
  def _get_predictors(self, X, names, add_intercept):
101
136
  if X is None and not add_intercept:
@@ -120,7 +155,7 @@ class Dataset:
120
155
  Returns
121
156
  -------
122
157
  :obj:`pandas.DataFrame`
123
- A DataFrame containing the y, v, X, and n values.
158
+ A DataFrame containing the y, v, X, n, and g values.
124
159
  """
125
160
  if self.y.shape[1] == 1:
126
161
  df = pd.DataFrame({"y": self.y[:, 0]})
@@ -131,6 +166,9 @@ class Dataset:
131
166
  if self.n is not None:
132
167
  df["n"] = self.n[:, 0]
133
168
 
169
+ if self.g is not None:
170
+ df["g"] = self.g[:, 0]
171
+
134
172
  df[self.X_names] = self.X
135
173
 
136
174
  else:
@@ -147,7 +185,12 @@ class Dataset:
147
185
  df["v"] = self.v[:, i_set]
148
186
 
149
187
  if self.n is not None:
150
- df["n"] = self.n[:, i_set]
188
+ # A single column of n applies to every parallel dataset,
189
+ # which the constructor allows and the estimators honour.
190
+ df["n"] = self.n[:, i_set if self.n.shape[1] > 1 else 0]
191
+
192
+ if self.g is not None:
193
+ df["g"] = self.g[:, 0]
151
194
 
152
195
  # X is the same across sets
153
196
  df[self.X_names] = self.X
@@ -170,6 +213,7 @@ def meta_regression(
170
213
  method="ML",
171
214
  ci_method="QP",
172
215
  alpha=0.05,
216
+ g=None,
173
217
  **kwargs,
174
218
  ):
175
219
  """Fit the standard meta-regression/meta-analysis model to provided data.
@@ -177,29 +221,29 @@ def meta_regression(
177
221
  Parameters
178
222
  ----------
179
223
  y : None or :obj:`numpy.ndarray` of shape (K,) or :obj:`str`, optional
180
- 1d array of study-level estimates with length K, or the name of the column in data
224
+ 1d array of observation-level estimates with length K, or the name of the column in data
181
225
  containing the y values.
182
226
  Default = None.
183
227
  v : None or :obj:`numpy.ndarray` of shape (K,) or :obj:`str`, optional
184
- 1d array of study-level variances with length K, or the name of the column in data
228
+ 1d array of observation-level variances with length K, or the name of the column in data
185
229
  containing v values.
186
230
  Default = None.
187
231
  X : None or :obj:`numpy.ndarray` of shape (K,[P]) or :obj:`list` of :obj:`str`, optional
188
- 1d or 2d array containing study-level predictors (dimensions K x P),
232
+ 1d or 2d array containing observation-level predictors (dimensions K x P),
189
233
  or a list of strings giving the names of the columns in data containing the X values.
190
234
  Default = None.
191
235
  n : None or :obj:`numpy.ndarray` of shape (K,) or :obj:`str`, optional
192
- 1d array of study-level sample sizes (length K), or the name of the corresponding column
193
- in ``data``.
236
+ 1d array of observation-level ``n`` values (length K), or the name of the
237
+ corresponding column in ``data``.
194
238
  Default = None.
195
239
  data : None or :obj:`pandas.DataFrame` or :obj:`~pymare.core.Dataset`, optional
196
- If a Dataset instance is passed, the y, v, X, n and associated arguments are ignored,
240
+ If a Dataset instance is passed, the y, v, X, n, g and associated arguments are ignored,
197
241
  and data is passed directly to the selected estimator.
198
- If a pandas DataFrame, y, v, X and/or n values are taken from the DF columns.
242
+ If a pandas DataFrame, y, v, X, n and/or g values are taken from the DF columns.
199
243
  By default, columns are expected to have the same names as arguments
200
244
  (e.g., the y values will be expected in the 'y' column).
201
- This can be modified by passing strings giving column names to any of the y, v, X, or n
202
- arguments.
245
+ This can be modified by passing strings giving column names to any of the y, v, X, n, or
246
+ g arguments.
203
247
  X_names : None or :obj:`list` of :obj:`str`, optional
204
248
  List of length P containing the names of the predictors.
205
249
  Ignored if ``data`` is provided (use ``X`` to specify columns).
@@ -224,6 +268,11 @@ def meta_regression(
224
268
  Ignored if ``method == 'Stan'``.
225
269
  alpha : :obj:`float`, optional
226
270
  Desired alpha level (CIs will have 1 - alpha coverage). Default = 0.05.
271
+ g : None or :obj:`numpy.ndarray` of shape (K,) or :obj:`str`, optional
272
+ Group labels marking dependent estimates, or the name of the corresponding column in
273
+ ``data``. Estimates with the same label are treated as one group by estimators that
274
+ support cluster-robust inference.
275
+ Default = None.
227
276
  **kwargs
228
277
  Optional keyword arguments to pass onto the chosen estimator.
229
278
 
@@ -237,7 +286,7 @@ def meta_regression(
237
286
  """
238
287
  # if data is None or not isinstance(data, Dataset):
239
288
  if data is None or not data.__class__.__name__ == "Dataset":
240
- data = Dataset(y, v, X, n, data, X_names, add_intercept)
289
+ data = Dataset(y, v, X, n, data, X_names, add_intercept, g=g)
241
290
 
242
291
  method = method.lower()
243
292