math
math copied to clipboard
Adding 5-Parameter Drift Diffusion Model (DDM) PDF and CDF to Stan Math
Description
Ratcliff's Diffusion Decision Model (DDM) is a popular model for jointly modelling binary responses and their associated response times. The DDM exists in several parameterizations, and currently Stan Math contains the PDF of the 4-parameter variant (i.e., the parameters for threshold separation, non-decision time, relative starting point of the diffusion process, and drift rate of the diffusion process) via the function wiener_lpdf()
. This issue proposes to add the 5-parameter variant of the DDM (i.e., including the parameter for inter-trial variability in the drift rate) to Stan Math by adding the new functions ddm_lpdf()
and ddm_lcdf()
.
I am submitting a pull request to add these two new functions (ddm_lpdf()
and ddm_lcdf()
). Both functions accept the following parameters: response time, response, threshold separation, drift rate, non-decision time, relative starting point, inter-trial variability in the drift rate. This pull request has been discussed in this Discourse thread.
Example
An example call to the (logged) PDF is ddm_lpdf(1, 1, 1, -1, 0, 0.5, 0.1)
and would return the log of the PDF.
An example call to the (logged) CDF is ddm_lcdf(1, 1, 1, -1, 0, 0.5, 0.1)
and would return the log of the CDF.
Expected Output
We should expect the example call to ddm_lpdf(1, 1, 1, -1, 0, 0.5, 0.1)
to return 0.02250968
.
We should expect the example call to ddm_lcdf(1, 1, 1, -1, 0, 0.5, 0.1)
to return 0.7264627
.
Current Version:
v4.1.0
Sorry for the late response. I see the PR associated with this and I'll make comments.
First question: is this the right name to call it?
- I see that within the drift diffusion model literature, it is referred to as DDM. But for someone finding this, it's not clear what
ddm_lpdf
is: I did a google search and it didn't go so well. - Is the lpdf really a "drift diffusion model" log probability distribution function? Or is it more accurately a "drift diffusion" log probability distribution? (I'm asking... I've only taken a preliminary look at the literature.) This may seem pedantic, but naming matters for long-term readability and intent. Note: we do have
normal_id_glm_lpdf
, so it's not unprecedented.
I'll review the code in earnest now.
Second question: can you write down the distribution here in math or link to papers?