pymare.estimators.WeightedLeastSquares
- class WeightedLeastSquares(tau2=0.0)[source]
Bases:
BaseEstimatorWeighted 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 (
floatornumpy.ndarrayof shape (d), optional) – Assumed/known value of tau^2. Must be >= 0. If an array, must havedelements, wheredrefers to the number of datasets. Default = 0.
Notes
This estimator accepts 2-D inputs for
yandv–i.e., it can produce estimates simultaneously for multiple independent sets ofy/vvalues (use the 2nd dimension for the parallel iterates). TheXmatrix must be identical for all iterates. If novargument 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.ndarrayof shape (n, d)) – The dependent variable(s) (y).X (
numpy.ndarrayof shape (n, p)) – The independent variable(s) (X).v (
numpy.ndarrayof 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.vwhen variances are present, but affords a way of estimating v from sample size (n) for any estimator that implicitly estimates a sigma^2 parameter.