Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding 5-Parameter Drift Diffusion Model (DDM) PDF and CDF to Stan Math #2584

Open
kendalfoster opened this issue Sep 20, 2021 · 1 comment

Comments

@kendalfoster
Copy link

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

@syclik
Copy link
Member

syclik commented May 19, 2023

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants