Tutorials#
Author: Micah G. Allen
Working with Heart Rate Discrimination data, from opening the files the task wrote through to hierarchical models of psychophysical choices and confidence.
Read them in order if the whole workflow is new to you. They build on each other: each one assumes the data preparation from the one before.
Tutorial |
What it covers |
|---|---|
Reading task files and checking a session’s stimuli, choices, timing, confidence, heart rate, and Psi posterior. In Python and R. |
|
What threshold, slope and lapse rate are, and fitting one participant. |
|
Fitting psychometric functions for everyone at once, and testing covariates and group effects. |
|
Fitting a hierarchical ordered beta model of confidence bias and metacognitive calibration. |
What you need#
Data inspection works in either Python or R. Model fitting is done in R, with brms and a Stan backend, using the Hierarchical Interoception toolbox.
The modelling tutorials assume you have met brms before: that a formula like
y ~ x + (x | subject) means something to you, and that you know roughly what a
posterior is. If that is new, the
brms vignettes and
Bürkner (2017) are the place to start,
and you will get much more out of these pages afterwards.
Nothing here assumes you know psychophysics.
These pages do not fit models#
The models take hours to sample. A page you are reading cannot wait for that, so the tutorials show the code and then load results that were fitted in advance.
The scripts that produced those results live in
tutorials/
in the repository, and they run on an ordinary machine. If you want to reproduce
a fit rather than read about it, start there. Every number quoted in these pages
came out of those scripts.
The example data#
The figures come from a study of 512 participants, each completing the HRD in two conditions, with age, gender and BMI recorded. That is a larger sample than most studies will have, which is deliberate: it makes the group-level structure visible. The methods apply unchanged to a sample of thirty.
Citing#
Cite Courtin et al. (2026) for the models and the priors, and Cardioception for the data collection. See the cite page for the full references.