pymare.effectsize.compute_measure

compute_measure(measure, data=None, comparison='infer', return_type='tuple', m=None, sd=None, n=None, r=None, m1=None, m2=None, sd1=None, sd2=None, n1=None, n2=None, **dataset_kwargs)[source]

Auto-detect and apply the right converter class.

Parameters:
  • measure ({"RM", "SM", "R", "ZR", "RMD", "SMD", "D"}) –

    The desired output effect size measure. Valid values are listed below, with the required named inputs in parentheses:

    • ’RM’ (m, sd, n): Raw mean of the group.

    • ’SM’ (m, sd, n): Standardized mean. This is often called Hedges g. (one-sample), or equivalently, Cohen’s one-sample d with a bias correction applied.

    • ’R’ (r, n): Raw correlation coefficient.

    • ’ZR’ (r, n): Fisher z-transformed correlation coefficient.

    • ’RMD’ (m1, m2, sd1, sd2, n1, n2): Raw mean difference between groups.

    • ’SMD’ (m1, m2, sd1, sd2, n1, n2): Standardized mean difference between groups. This is often called Hedges g, or equivalently, Cohen’s d with a bias correction applied.

    • ’D’ (m, sd, n, or m1, m2, sd1, sd2, n1, n2): Cohen’s d. No bias correction is applied (for that, use ‘SM’ or ‘SMD’ instead). Note that ‘D’ can be either one-sample or two-sample. This is specified in type, or (if type==’infer’), inferred from the passed arguments.

  • data (None or pandas.DataFrame, optional) – A pandas DataFrame to extract variables from. Column names must match the names of other args (‘m’, ‘sd’, ‘n2’, etc.). If both a DataFrame and keyword arguments are provided, the two will be merged, with variables passed as separate arguments taking precedence over DataFrame columns in the event of a clash.

  • comparison ({"infer", 1, 2}, optional) –

    The type of originating comparison. This is currently unnecessary, as the type can be deterministically inferred from the input arguments and measure, but may become necessary in future, and provides a way of imposing constraints on code embedded in larger pipelines. Valid values:

    • ’infer’ (default): Infer the type of comparison from the input arguments.

    • 1: One-group comparison. Must be accompanied by some/all of the following named variables: m, sd, n, r.

    • 2: Two-group comparison. Independent samples are assumed. Must be accompanied by some/all of the following named variables: m1, m2, sd1, sd2, n1, n2.

  • return_type ({"tuple", "dict", "dataset", "converter"}, optional) –

    Controls what gets returned. Valid values:

    • ’tuple’: A 2-tuple, where the first element is a 1-d array containing the computed estimates (i.e., y), and the second element is a 1-d array containing the associated sampling variances.

    • ’dict’: A dictionary with keys ‘y’ and ‘v’ that map to the arrays described for ‘tuple’.

    • ’dataset’: A pymare Dataset instance, with y and v attributes set to the corresponding arrays. Note that additional keyword arguments can be passed onto the Dataset init via kwargs.

    • ’converter’: The EffectSizeConverter class internally initialized to handle the desired computation. The target measures will have already been computed (and hence, cached), and can be retrieved via get_(‘{measure}’) and get_(‘v_{measure}’)

  • m (None or numpy.ndarray, optional) – Means or other estimates in single-group case

  • sd (None or numpy.ndarray, optional) – Standard deviations in single-group case

  • n (None or numpy.ndarray, optional) – Sample sizes in single-group case

  • r (None or numpy.ndarray, optional) – Correlation coefficients

  • m1 (None or numpy.ndarray, optional) – Means for group 1

  • m2 (None or numpy.ndarray, optional) – Means for group 2

  • sd1 (None or numpy.ndarray, optional) – Standard deviations for group 1

  • sd2 (None or numpy.ndarray, optional) – Standard deviations for group 2

  • n1 (None or numpy.ndarray, optional) – Sample sizes for group 1

  • n2 (None or numpy.ndarray, optional) – Sample sizes for group 2

  • **dataset_kwargs – Optional keyword arguments passed on to the Dataset initializer. Ignored unless return_type == ‘dataset’.

Return type:

tuple or dict or Dataset, depending on return_type.