EstimatorMetaD#

class EstimatorMetaD(data=None, bins=None, cl=None, parallel=False, libraries=['numpy', 'pandas'], prior=False, display=False, ppt_identifier=None, ignore_invalid=False, **kwargs)[source]#

Bases: object

Class to estimate metacognitive parameters using the meta-d model proposed by Maniscalco and Lau (2012).

Parameters:
datapd.DataFrame, pd.DataFrameGroupBy

DataFrame containing the data to be analyzed. See Note below.

binsint

Number of bins to use for binning the confidence ratings.

clint, optional

Number of cores to use for parallel processing. If None, all available cores will be used.

parallelbool, default False

If True, parallel processing will be used.

librarieslist of str, default [“numpy”, “pandas”]

List of libraries to use for parallel processing in Jupyter. Default is [“numpy”, “pandas”].

priorbool, default False

If True, the log likelihoods will incorporate prior density of parameters.

displayint, default 0

Level of algorithm’s verbosity:

  • 0 (default) : work silently.

  • 1 : display a termination report.

  • 2 : display progress during iterations.

  • 3 : display progress during iterations (more complete report).

ppt_identifierstr, optional

The column that identifies the participants in the data. Required if data is a pandas.DataFrame. If data is grouped by a single column, such as data.groupby("ppt"), it defaults to the name of that column.

ignore_invalidbool, default False

If True, invalid confidence ratings will be ignored during binning. If False, an error will be raised if invalid ratings are found. We recommend setting this to False (Default).

**kwargsadditional keyword arguments

Additional keyword arguments to be passed to the optimization function.

Returns:
An EstimatorMetaD object.

Notes

The data DataFrame should contain the following columns:

  • ‘participant’: Identifier for each participant.

  • ‘signal’ (integer): Stimulus presented to the participant, for example, 0 for S1 and 1 for S2.

  • ‘response’ (integer): Participant’s response to the stimulus.

  • ‘confidence’ (integer, float): Participant’s confidence rating for their response.

  • ‘accuracy’ (integer): Accuracy of the participant’s response. 0 = incorrect, 1 = correct.

optimise()[source]#

Estimates the metacognitive parameters using the meta-d model. Here, we use a Trust-Region Constrained Optimization algorithm (Conn et al., 2000) to fit the model to the data. We use the trust-constr method from scipy.optimize.minimize to perform the optimization, and minimise the negative log-likelihood of the data given the model parameters. The optimization is performed for each participant in the data.

Notes

If you want to tune the behaviour of the optimization, you can do so by passing additional keyword arguments to the class constructor. See the scipy.optimize.minimize() documentation for more details on the available options. By default, the optimization will use the trust-constr method with the default options specified in the scipy.optimize.minimize documentation.

References

Conn, A. R., Gould, N. I. M., & Toint, P. L. (2000). Trust Region Methods. Society for Industrial and Applied Mathematics. https://doi.org/10.1137/1.9780898719857

export()[source]#

Exports the optimization results and fitted parameters as a pandas.DataFrame.

Returns:
pandas.DataFrame

A pandas DataFrame containing the optimization results and fitted parameters.