pymare.estimators
.WeightedLeastSquares
- class WeightedLeastSquares(tau2=0.0)[source]
Bases:
BaseEstimator
Weighted least-squares meta-regression.
Provides the weighted least-squares estimate of the fixed effects given known/assumed between-study variance tau^2, as described in Brockwell and Gordon[1]. When tau^2 = 0 (default), the model is the standard inverse-weighted fixed-effects meta-regression.
- Parameters:
tau2 (
float
ornumpy.ndarray
of shape (d), optional) – Assumed/known value of tau^2. Must be >= 0. If an array, must haved
elements, whered
refers to the number of datasets. Default = 0.
Notes
This estimator accepts 2-D inputs for
y
andv
–i.e., it can produce estimates simultaneously for multiple independent sets ofy
/v
values (use the 2nd dimension for the parallel iterates). TheX
matrix must be identical for all iterates. If nov
argument is passed tofit()
, unit weights will be used, resulting in the ordinary least-squares (OLS) solution.References
- fit(y, X, v=None)[source]
Fit the estimator to data.
- Parameters:
y (
numpy.ndarray
of shape (n, d)) – The dependent variable(s) (y).X (
numpy.ndarray
of shape (n, p)) – The independent variable(s) (X).v (
numpy.ndarray
of shape (n, d), optional) – Sampling variances. If not provided, unit weights will be used.
- 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.
Examples using pymare.estimators.WeightedLeastSquares
The Basics of Running a Meta-Analysis
Run Estimators on a simulated dataset