Comparing parameters within subjects


I am running an experiment in which each participant completes a task that has two conditions (within subject). I am fitting a hierarchical model that fits a parameter to each condition, beta1 for condition 1 and beta2 for condition 2. I would like to make a within-subject comparison between the betas for the two conditions. Is there a way to achieve this in stan? I can take the posterior draws for beta1 and beta2 for each participant, subtract them, and generate the HDI for the difference for each participant, but Iā€™m not sure how to proceed from there if I want a pairwise comparison in the sample with all participants.


Check out the video/code from this lecture:

The subsequent lectures might be useful too, esp March 6 where I show how to do it when the data are in long format and possibly missing data.

And if your data is truly hierarchical, with multiple observations per subject and condition, hierarchical models start on March 8.

1 Like

Thank you very much, I will check it out!