Question about bandit4arm2_kalman_filter input

27 views
Skip to first unread message

Marius Golubickis

unread,
Apr 16, 2026, 7:57:32 AMApr 16
to hbayesdm-users

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:

  • subjID
  • choice (coded 1–4)
  • outcome (coded as 1 for reward and -1 for loss)

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

Jeongyeon Shin

unread,
Apr 16, 2026, 9:14:58 PMApr 16
to hbayesdm-users
Dear 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

2026년 4월 16일 목요일 오후 8시 57분 32초 UTC+9에 golub...@gmail.com님이 작성:

Marius Golubickis

unread,
Apr 17, 2026, 2:45:22 AMApr 17
to hbayesdm-users

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

wooyou...@gmail.com

unread,
Apr 17, 2026, 2:48:05 AMApr 17
to hbayesdm-users
Hi Marius,

In most cases, I think it doesn't matter whether outcomes are binary or continuous. Not sure which task you used, but you can check bandit4arm_• models?


Best,
Young
Reply all
Reply to author
Forward
0 new messages