CCS-Lab / hBayesDM

Hierarchical Bayesian modeling of RLDM tasks, using R & Python
https://ccs-lab.github.io/hBayesDM
GNU General Public License v3.0
222 stars 113 forks source link

Removing NA values causes error in choiceRT_ddm? #142

Closed antonija-kolobaric closed 2 years ago

antonija-kolobaric commented 2 years ago

Hi y'all,

I get an error when trying to run choiceRT_ddm:

Error in RTl[i, 1:Nl[i]] <- subj_data$rt[subj_data$choice == 1] : number of items to replace is not a multiple of replacement length

Notably, this appears after I remove NA rows (I simply removed any rows where participants didn't answer). It seems like other people have ran into this issue as well, and it might be due to uneven number of rows between participants? See: https://stackoverflow.com/questions/69086313/why-is-there-an-error-in-rtui-1nui-in-my-choicert-ddm-function-in-r

Looking over the original paper (https://cpsyjournal.org/article/10.1162/CPSY_a_00002/), it seems like the package should be able to handle this: Across all the models implemented in hBayesDM, the number of trials within the data file is allowed to vary across subjects, but the file should contain no missing (N/A) data. If some trials do contain N/A data (e.g., outcome=NA), remove these trials before continuing. If trials containing N/A data are not removed prior to the model fitting, they will be removed automatically and the user will receive a warning message.

Has anyone else experiences this problem? What was your solution? I have ran choiceRT_ddm_single on my participants and that works fine. Is it truly a matter of uneven number of trials?

antonija-kolobaric commented 2 years ago

Never mind -- apparently, the code doesn't work unless subject IDs are sorted from smallest to largest. Might be useful to make this more obvious in the documentation! Closing since I solved it!