|
19 | 19 | class Dataset: |
20 | 20 | """Container for input data and arguments to estimators. |
21 | 21 |
|
22 | | - Args: |
23 | | - y (array-like, str): 1d array of study-level estimates with length K, |
24 | | - or the name of the column in data containing the y values. |
25 | | - v (array-like, str, optional): 1d array of study-level variances with |
26 | | - length K, or the name of the column in data containing v values. |
27 | | - X (array-like, list, optional): 1d or 2d array containing study-level |
28 | | - predictors (dimensions K x P), or a list of strings giving the |
29 | | - names of the columns in data containing the X values. |
30 | | - n (array-like, str, optional): 1d array of study-level sample sizes |
31 | | - (length K), or the name of the corresponding column in data. |
32 | | - data (pandas.DataFrame, optional): A pandas DataFrame containing y, v, |
33 | | - X, and/or n values. By default, columns are expected to have the |
34 | | - same names as arguments (e.g., the y values will be expected in the |
35 | | - 'y' column). This can be modified by passing strings giving column |
36 | | - names to any of the y, v, X, or n arguments. |
37 | | - X_names ([str], optional): List of length P containing the names of the |
38 | | - predictors. Ignored if data is provided (use X to specify columns). |
39 | | - add_intercept (bool, optional): If True, an intercept column is |
40 | | - automatically added to the predictor matrix. If False, the |
41 | | - predictors matrix is passed as-is to estimators. |
| 22 | + Parameters |
| 23 | + ---------- |
| 24 | + y : None or :obj:`numpy.ndarray` of shape (K,) or :obj:`str`, optional |
| 25 | + 1d array of study-level estimates with length K, or the name of the column in data |
| 26 | + containing the y values. |
| 27 | + Default is None. |
| 28 | + v : None or :obj:`numpy.ndarray` of shape (K,) or :obj:`str`, optional |
| 29 | + 1d array of study-level variances with length K, or the name of the column in data |
| 30 | + containing v values. |
| 31 | + Default is None. |
| 32 | + X : None or :obj:`numpy.ndarray` of shape (K,[P]) or :obj:`list` of :obj:`str`, optional |
| 33 | + 1d or 2d array containing study-level predictors (dimensions K x P), |
| 34 | + or a list of strings giving the names of the columns in data containing the X values. |
| 35 | + Default is None. |
| 36 | + n : None or :obj:`numpy.ndarray` of shape (K,) or :obj:`str`, optional |
| 37 | + 1d array of study-level sample sizes (length K), or the name of the corresponding column |
| 38 | + in ``data``. |
| 39 | + Default is None. |
| 40 | + data : None or :obj:`pandas.DataFrame`, optional |
| 41 | + A pandas DataFrame containing y, v, X, and/or n values. |
| 42 | + By default, columns are expected to have the same names as arguments |
| 43 | + (e.g., the y values will be expected in the 'y' column). |
| 44 | + This can be modified by passing strings giving column names to any of the ``y``, ``v``, |
| 45 | + ``X``, or ``n`` arguments. |
| 46 | + Default is None. |
| 47 | + X_names : None or :obj:`list` of :obj:`str`, optional |
| 48 | + List of length P containing the names of the predictors. |
| 49 | + Ignored if ``data`` is provided (use ``X`` to specify columns). |
| 50 | + Default is None. |
| 51 | + add_intercept : :obj:`bool`, optional |
| 52 | + If True, an intercept column is automatically added to the predictor matrix. |
| 53 | + If False, the predictors matrix is passed as-is to estimators. |
| 54 | + Default is True. |
42 | 55 | """ |
43 | 56 |
|
44 | 57 | def __init__( |
@@ -94,47 +107,65 @@ def meta_regression( |
94 | 107 | alpha=0.05, |
95 | 108 | **kwargs, |
96 | 109 | ): |
97 | | - """Fits the standard meta-regression/meta-analysis model to provided data. |
98 | | -
|
99 | | - Args: |
100 | | - y (array-like, str): 1d array of study-level estimates with length K, |
101 | | - or the name of the column in data containing the y values. |
102 | | - v (array-like, str, optional): 1d array of study-level variances with |
103 | | - length K, or the name of the column in data containing v values. |
104 | | - X (array-like, list, optional): 1d or 2d array containing study-level |
105 | | - predictors (dimensions K x P), or a list of strings giving the |
106 | | - names of the columns in data containing the X values. |
107 | | - n (array-like, str, optional): 1d array of study-level sample sizes |
108 | | - (length K), or the name of the corresponding column in data. |
109 | | - data (pandas.DataFrame, pymare.Dataset, optional): If a Dataset |
110 | | - instance is passed, the y, v, X, n and associated arguments are |
111 | | - ignored, and data is passed directly to the selected estimator. |
112 | | - If a pandas DataFrame, y, v, X and/or n values are taken from the |
113 | | - DF columns. By default, columns are expected to have the same names |
114 | | - as arguments (e.g., the y values will be expected in the 'y' |
115 | | - column). This can be modified by passing strings giving column |
116 | | - names to any of the y, v, X, or n arguments. |
117 | | - X_names ([str], optional): List of length P containing the names of the |
118 | | - predictors. Ignored if data is provided (use X to specify columns). |
119 | | - add_intercept (bool, optional): If True, an intercept column is |
120 | | - automatically added to the predictor matrix. If False, the |
121 | | - predictors matrix is passed as-is to estimators. |
122 | | - method (str, optional): Name of estimation method. Defaults to 'ML'. |
123 | | - Supported estimators include: |
124 | | - * 'ML': Maximum-likelihood estimator |
125 | | - * 'REML': Restricted maximum-likelihood estimator |
126 | | - * 'DL': DerSimonian-Laird estimator |
127 | | - * 'HE': Hedges estimator |
128 | | - * 'WLS' or 'FE': Weighted least squares (fixed effects only) |
129 | | - * 'Stan': Full Bayesian MCMC estimation via Stan |
130 | | - ci_method (str, optional): Estimation method to use when computing |
131 | | - uncertainty estimates. Currently only 'QP' is supported. Defaults |
132 | | - to 'QP'. Ignored if method == 'Stan'. |
133 | | - alpha (float, optional): Desired alpha level (CIs will have 1 - alpha |
134 | | - coverage). Defaults to 0.05. |
135 | | - kwargs: Optional keyword arguments to pass onto the chosen estimator. |
136 | | -
|
137 | | - Returns: |
| 110 | + """Fit the standard meta-regression/meta-analysis model to provided data. |
| 111 | +
|
| 112 | + Parameters |
| 113 | + ---------- |
| 114 | + y : None or :obj:`numpy.ndarray` of shape (K,) or :obj:`str`, optional |
| 115 | + 1d array of study-level estimates with length K, or the name of the column in data |
| 116 | + containing the y values. |
| 117 | + Default is None. |
| 118 | + v : None or :obj:`numpy.ndarray` of shape (K,) or :obj:`str`, optional |
| 119 | + 1d array of study-level variances with length K, or the name of the column in data |
| 120 | + containing v values. |
| 121 | + Default is None. |
| 122 | + X : None or :obj:`numpy.ndarray` of shape (K,[P]) or :obj:`list` of :obj:`str`, optional |
| 123 | + 1d or 2d array containing study-level predictors (dimensions K x P), |
| 124 | + or a list of strings giving the names of the columns in data containing the X values. |
| 125 | + Default is None. |
| 126 | + n : None or :obj:`numpy.ndarray` of shape (K,) or :obj:`str`, optional |
| 127 | + 1d array of study-level sample sizes (length K), or the name of the corresponding column |
| 128 | + in ``data``. |
| 129 | + Default is None. |
| 130 | + data : None or :obj:`pandas.DataFrame` or :obj:`~pymare.core.Dataset`, optional |
| 131 | + If a Dataset instance is passed, the y, v, X, n and associated arguments are ignored, |
| 132 | + and data is passed directly to the selected estimator. |
| 133 | + If a pandas DataFrame, y, v, X and/or n values are taken from the DF columns. |
| 134 | + By default, columns are expected to have the same names as arguments |
| 135 | + (e.g., the y values will be expected in the 'y' column). |
| 136 | + This can be modified by passing strings giving column names to any of the y, v, X, or n |
| 137 | + arguments. |
| 138 | + X_names : None or :obj:`list` of :obj:`str`, optional |
| 139 | + List of length P containing the names of the predictors. |
| 140 | + Ignored if ``data`` is provided (use ``X`` to specify columns). |
| 141 | + Default is None. |
| 142 | + add_intercept : :obj:`bool`, optional |
| 143 | + If True, an intercept column is automatically added to the predictor matrix. |
| 144 | + If False, the predictors matrix is passed as-is to estimators. |
| 145 | + Default is True. |
| 146 | + method : {"ML", "REML", "DL", "HE", "WLS", "FE", "Stan"}, optional |
| 147 | + Name of estimation method. Default is 'ML'. |
| 148 | + Supported estimators include: |
| 149 | +
|
| 150 | + - 'ML': Maximum-likelihood estimator |
| 151 | + - 'REML': Restricted maximum-likelihood estimator |
| 152 | + - 'DL': DerSimonian-Laird estimator |
| 153 | + - 'HE': Hedges estimator |
| 154 | + - 'WLS' or 'FE': Weighted least squares (fixed effects only) |
| 155 | + - 'Stan': Full Bayesian MCMC estimation via Stan |
| 156 | + ci_method : {"QP"}, optional |
| 157 | + Estimation method to use when computing uncertainty estimates. |
| 158 | + Currently only 'QP' is supported. Default is 'QP'. |
| 159 | + Ignored if ``method == 'Stan'``. |
| 160 | + alpha : :obj:`float`, optional |
| 161 | + Desired alpha level (CIs will have 1 - alpha coverage). Default is 0.05. |
| 162 | + **kwargs |
| 163 | + Optional keyword arguments to pass onto the chosen estimator. |
| 164 | +
|
| 165 | + Returns |
| 166 | + ------- |
| 167 | + :obj:`~pymare.results.MetaRegressionResults` or \ |
| 168 | + :obj:`~pymare.results.BayesianMetaRegressionResults` |
138 | 169 | A MetaRegressionResults or BayesianMetaRegressionResults instance, |
139 | 170 | depending on the specified method ('Stan' will return the latter; all |
140 | 171 | other methods return the former). |
|
0 commit comments