Hi all,
I am currently working with the bandit4arm2_kalman_filter model and had a couple of questions regarding data input requirements, as I am encountering errors during model fitting.
My dataset contains:
According to the documentation, this outcome coding should be valid. However, during model fitting, I receive an error indicating that invalid values (e.g., -1) are present, which suggests that the model may be expecting outcomes on a different scale.
Error : Exception: model50e455451292__namespace::model50e455451292_: choice[1][355] is -1, but must be greater than or equal to 1.000000 (in 'string', line 20, column 2 to column 35)
Could this be because I removed trials due to fast responses or time-out, as such all participants need to have the same maximum number of trials?
Kind regards,
Marius
Thank you for your question.
The error message choice[1][355] is -1 indicates that the -1 padding values in the choice array are triggering a constraint violation in Stan's data block (int<lower=1, upper=4> choice[N, T]). This occurs because hBayesDM initializes the choice array with -1 for all entries, and only fills in actual data up to each subject's trial count. When trial counts differ across subjects, the remaining entries stay as -1 and cause this error. To resolve this, please ensure all subjects have the same number of trials before fitting the model.
Alternatively, you may modify the Stan code directly from the GitHub repository (https://github.com/CCS-Lab/hBayesDM/blob/develop/commons/stan_files/bandit4arm2_kalman_filter.stan) and run the model with the updated code.
We also noticed that your outcome is coded as 1 and -1. We apologize for any confusion — there appears to be an error in our documentation. The Stan model actually expects continuous outcome values between 1 and 100 (real<lower=1, upper=100>), which reflects the original task design in Daw et al. (2006). Could you clarify what the outcome values in your task represent? Depending on your task design, a different model may be more appropriate.
We are aware of these issues and plan to address them in a future update. We will let you know once they are resolved.
Best regards,
Jeongyeon
Dear Jeongyeon,
Thank you very much for your quick and detailed response — I really appreciate it.
Your explanation confirms what I suspected might be causing the issue, that clarifies things a lot.
Yes, I wanted to ask whether there is an hBayesDM model you would recommend for a 4-armed bandit task with binary outcomes (i.e., wins vs losses)? By looking at descriptions on the website, I noticed they are mostly with continuous gains and losses on a trial-by-trial basis.
Thanks again for your help, and I look forward to your advice.
Best regards,
Marius