pymare.effectsize
.TwoSampleEffectSizeConverter
- class TwoSampleEffectSizeConverter(data=None, m1=None, m2=None, sd1=None, sd2=None, n1=None, n2=None, **kwargs)[source]
Bases:
EffectSizeConverter
Effect size converter for two-sample comparisons.
- Parameters:
data (None or
pandas.DataFrame
, optional) – Optional pandas DataFrame to extract variables from. Column names must match the controlled names listed below for kwargs. If additional kwargs are provided, they will take precedence over the values in the data frame.m1 (None or
numpy.ndarray
, optional) – Means for group 1m2 (None or
numpy.ndarray
, optional) – Means for group 2sd1 (None or
numpy.ndarray
, optional) – Standard deviations for group 1sd2 (None or
numpy.ndarray
, optional) – Standard deviations for group 2n1 (None or
numpy.ndarray
, optional) – Sample sizes for group 1n2 (None or
numpy.ndarray
, optional) – Sample sizes for group 2**kwargs – Optional keyword arguments providing additional inputs. All values must be floats, 1d ndarrays, or any iterable that can be converted to an ndarray.
Notes
All input variables are assumed to reflect study- or analysis-level summaries, and are _not_ individual data points. E.g., do not pass in a vector of point estimates as m1 and a scalar for the SDs sd1. The lengths of all inputs must match. All variables must be passed in as pairs (e.g., if m1 is provided, m2 must also be provided).
When using the TwoSampleEffectSizeConverter, it is assumed that the variable pairs are from independent samples. Paired-sampled comparisons are not currently supported.
- get(stat, error=True)[source]
Compute and return values for the specified statistic, if possible.
- Parameters:
- Returns:
A float or ndarray containing the requested parameter values, if successfully computed.
- Return type:
Notes
All values computed via get() are internally cached. Do not try to update the instance’s known values directly; any change to input data require either initialization of a new instance, or a call to update_data().
- to_dataset(measure='SMD', **kwargs)[source]
Get a Pymare Dataset with y and v mapped to the specified measure.
- Parameters:
measure ({"SMD", "RMD", "D"}, optional) –
The measure to map to the Dataset’s y and v attributes (where y is the desired measure, and v is its variance). Valid values include:
’SMD’: Standardized mean difference between groups. This is often called Hedges g, or equivalently, Cohen’s d with a bias correction applied. This is the default.
’RMD’: Raw mean difference between groups.
’D’: Cohen’s d. Note that no bias correction is applied (use ‘SMD’ instead).
**kwargs – Optional keyword arguments to pass onto the Dataset initializer. Provides a way of supplementing the generated y and v arrays with additional arguments (e.g., X, X_names, n). See pymare.Dataset docs for details.
- Return type:
Notes
All measures require that m1, m2, sd1, sd2, n1, and n2 be passed in as inputs (or be solvable from the passed inputs).
- update_data(incremental=False, **kwargs)[source]
Update instance data.
- Parameters:
incremental (
bool
, optional) – If True, updates data incrementally (i.e., existing data will be preserved unless they’re overwritten by incoming keys). If False, all existing data is dropped first. Default = False.**kwargs – Data values or arrays; keys are the names of the quantities. All inputs to
__init__
are valid.