RL functions using blackbox likelihoods in HSSM #464
-
Dear all, i have a question regarding a decision-making task and the HSSM toolbox. It would be important that the model does learn different types of values in all trials, and that we can implement our own functions of how these values map on the different DDM parameters when decisions come up every 6 to 10 trials. Further the task has different conditions and days of participation which we all want to put in one hierarchical model. I want something like: #Decision only in some trials What would be the key steps to implement such a model in HSSM? That would be great help. Bests, Postdoc |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hi, A couple of points to implement this --
The function should take as inputs, all the required data columns (participant id, trial number, response, feedback, etc.) as well as the parameter columns to compute the likelihood. This function will encapsulate all the necessary likelihood logic. This function returns an array of computed logp values.
Here is a template to define the HSSM model with a custom likelihood function -
Hope this helps, let me know if you have any questions. |
Beta Was this translation helpful? Give feedback.
-
Hi Krishn, Thank you very much for the further detailed explanations. I will try to get it work via the custom likelihood function! Thank you for now and best wishes, |
Beta Was this translation helpful? Give feedback.
Hi,
A couple of points to implement this --
At a high level, you can implement this black box likelihood in Cython or JAX/PyTensor. While JAX/PyTensor implementation will allow the use of gradient-based samplers like NUTS, you will have to rely on Slice sampling if you have a Cython function. While you can also implement a Python function, it will be very inefficient in practice.
Black box likelihood function. Let's say we want to have a Cython implementation. The function signature should look like this --