pymare.estimators.VarianceBasedLikelihoodEstimator

class VarianceBasedLikelihoodEstimator(method='ml', **kwargs)[source]

Bases: BaseEstimator

Likelihood-based estimator for estimates with known variances.

Initially estimates the between-subject variance tau^2 and fixed effect coefficients using DerSimonian and Laird[1] method-of-moments approach, and then iteratively estimates them using the specified likelihood-based estimator (ML or REML) [2].

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

The ML and REML solutions are obtained via SciPy’s scalar function minimizer (scipy.optimize.minimize()). Parameters to minimize() can be passed in as keyword arguments.

References

fit(y, v, X)[source]

Fit the estimator to data.

Parameters:
  • y (numpy.ndarray of shape (n, d)) – The dependent variable(s) (y).

  • v (numpy.ndarray of shape (n, d)) – Sampling variances.

  • X (numpy.ndarray of shape (n, p)) – The independent variable(s) (X).

Return type:

VarianceBasedLikelihoodEstimator

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:

numpy.ndarray

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.

summary()[source]

Generate a MetaRegressionResults object for the fitted estimator.

Return type:

MetaRegressionResults

Examples using pymare.estimators.VarianceBasedLikelihoodEstimator

Run Estimators on a simulated dataset

Run Estimators on a simulated dataset