pymare.estimators
.SampleSizeBasedLikelihoodEstimator
- class SampleSizeBasedLikelihoodEstimator(method='ml', **kwargs)[source]
Bases:
BaseEstimator
Likelihood-based estimator for data with known sample sizes but unknown sampling variances.
Iteratively estimates the between-subject variance tau^2 and fixed effect betas using the specified likelihood-based estimator (ML or REML) [1].
- Parameters:
method ({"ML", "REML"}, optional) – The estimation method to use. Either ‘ML’ (for maximum-likelihood) or ‘REML’ (restricted maximum-likelihood). Default = ‘ML’.
**kwargs – Keyword arguments to pass to the SciPy minimizer.
Notes
Homogeneity of sigma^2 across studies is assumed.
The ML and REML solutions are obtained via SciPy’s scalar function minimizer (
scipy.optimize.minimize()
). Parameters tominimize()
can be passed in as keyword arguments.References
- fit(y, n, X)[source]
Fit the estimator to data.
- Parameters:
y (
numpy.ndarray
of shape (n, d)) – The dependent variable(s) (y).n (
numpy.ndarray
of shape (n, d)) – Sample sizes.X (
numpy.ndarray
of shape (n, p)) – The independent variable(s) (X).
- Return type:
- fit_dataset(dataset, *args, **kwargs)[source]
Apply the current estimator to the passed Dataset container.
A convenience interface that wraps fit() and automatically aligns the variables held in a Dataset with the required arguments.
- Parameters:
dataset (
Dataset
) – A PyMARE Dataset instance holding the data.*args – Optional positional arguments to pass onto the
fit()
method.**kwargs – Optional keyword arguments to pass onto the
fit()
method.
- get_v(dataset)[source]
Get the variances, or an estimate thereof, from the given Dataset.
- Parameters:
dataset (
Dataset
) – The dataset to use to retrieve/estimate v.- Returns:
2-dimensional array of variances/variance estimates.
- Return type:
Notes
This is equivalent to directly accessing
dataset.v
when variances are present, but affords a way of estimating v from sample size (n) for any estimator that implicitly estimates a sigma^2 parameter.