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

WIP: Ratcliff Diffusion Model pdf and simulators #29

Closed
wants to merge 56 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
cd364ee
pdf for Ratcliff DDM first pass
kiante-fernandez Jun 21, 2023
342f6bb
added rand simulators for Ratcliff Diffusion Model
kiante-fernandez Jun 22, 2023
2a33d5f
Merge branch 'master' into ssmDev
kiante-fernandez Jul 1, 2023
217bc6e
Merge branch 'itsdfish:master' into ssmDev
kiante-fernandez Jul 1, 2023
b8f998f
Merge branch 'ssmDev' of https://github.com/kiante-fernandez/Sequenti…
kiante-fernandez Jul 1, 2023
9339d77
Merge branch 'itsdfish:master' into ssmDev
kiante-fernandez Jul 3, 2023
b5cca7d
changes to Ratcliff to for SSM format
kiante-fernandez Jul 3, 2023
244a24d
cdf fast dm implementation
kiante-fernandez Jul 3, 2023
0bb7df6
Merge branch 'itsdfish:master' into ssmDev
kiante-fernandez Jul 3, 2023
8014ab0
_pdf change
kiante-fernandez Jul 3, 2023
c8f1c9d
cdf code must be redone. Wrong in a few ways
kiante-fernandez Jul 3, 2023
dcccdf6
added non license breaking implementation of cdf
kiante-fernandez Jul 4, 2023
1560760
bugs
kiante-fernandez Jul 4, 2023
1e7669c
minor bugs
kiante-fernandez Jul 4, 2023
dc8cc16
rm vscode settings
kiante-fernandez Jul 4, 2023
6aa64a2
settings change
kiante-fernandez Jul 4, 2023
1e6f316
rm vscode settings
kiante-fernandez Jul 4, 2023
0d96d73
change vscode settings
kiante-fernandez Jul 4, 2023
b894210
Merge branch 'master' into ssmDev
kiante-fernandez Jul 5, 2023
50d3acb
adding Ratcliff DDM
kiante-fernandez Jul 5, 2023
7fd93cd
Merge branch 'master' into ssmDev
kiante-fernandez Jul 12, 2023
ef7bcf9
Merge branch 'master' into ssmDev
kiante-fernandez Jul 14, 2023
f8de141
Merge ratcliff and DDM
kiante-fernandez Jul 17, 2023
14006ca
bugs in integration
kiante-fernandez Jul 17, 2023
b30eb73
Merge branch 'master' into ssmDev
kiante-fernandez Jul 17, 2023
9ba7ade
slights changes for merge
kiante-fernandez Jul 17, 2023
43697e0
merged Ratcliff docs
kiante-fernandez Jul 17, 2023
5cf0ae3
make simulate use across trial parameters
kiante-fernandez Jul 17, 2023
aa245d5
working on test changes
kiante-fernandez Jul 17, 2023
ae91523
Merge branch 'master' into ssmDev
kiante-fernandez Jul 20, 2023
45e0319
Merge branch 'master' into ssmDev
kiante-fernandez Oct 22, 2023
9f9500e
pdf for Ratcliff DDM first pass
kiante-fernandez Jun 21, 2023
11eff78
added rand simulators for Ratcliff Diffusion Model
kiante-fernandez Jun 22, 2023
4c37f71
changes to Ratcliff to for SSM format
kiante-fernandez Jul 3, 2023
6373957
cdf fast dm implementation
kiante-fernandez Jul 3, 2023
fabd699
_pdf change
kiante-fernandez Jul 3, 2023
d91c218
cdf code must be redone. Wrong in a few ways
kiante-fernandez Jul 3, 2023
e2bc8f4
added non license breaking implementation of cdf
kiante-fernandez Jul 4, 2023
f53378c
bugs
kiante-fernandez Jul 4, 2023
b3b5687
minor bugs
kiante-fernandez Jul 4, 2023
d9f85ed
settings change
kiante-fernandez Jul 4, 2023
44ef7c2
rm vscode settings
kiante-fernandez Jul 4, 2023
2e58140
change vscode settings
kiante-fernandez Jul 4, 2023
83ca377
adding Ratcliff DDM
kiante-fernandez Jul 5, 2023
7925430
Merge ratcliff and DDM
kiante-fernandez Jul 17, 2023
efadc35
bugs in integration
kiante-fernandez Jul 17, 2023
e86074c
slights changes for merge
kiante-fernandez Jul 17, 2023
f7f29ad
merged Ratcliff docs
kiante-fernandez Jul 17, 2023
a025829
make simulate use across trial parameters
kiante-fernandez Jul 17, 2023
538dbad
working on test changes
kiante-fernandez Jul 17, 2023
b09c9ef
Merge branch 'ssmDev' of https://github.com/kiante-fernandez/Sequenti…
kiante-fernandez Oct 22, 2023
57d48b7
Merge remote-tracking branch 'upstream/master' into ssmDev
kiante-fernandez Dec 25, 2023
c530353
Add random number generator to DDM simulation
kiante-fernandez Dec 25, 2023
bd36ea8
Add AbstractDDM and remove/port RatcliffDDM
kiante-fernandez Dec 27, 2023
b74b0a1
Remove .vscode directory
kiante-fernandez Dec 28, 2023
8515612
Refactor DDM tests and debug/ID bug
kiante-fernandez Jan 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
Manifest.toml
/temp
/benchmark/*.json
/benchmark/*.md
/.vscode
3 changes: 2 additions & 1 deletion docs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
build/
site/
docs/build/
Manifest.toml
Manifest.toml
settings.json
23 changes: 21 additions & 2 deletions docs/src/DDM.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Diffusion Decision Model

The Diffusion Decision Model (DDM; Ratcliff et al., 2016) is a model of speeded decision-making in two-choice tasks. The DDM assumes that evidence accumulates over time, starting from a certain position, until it crosses one of two boundaries and triggers the corresponding response (Ratcliff & McKoon, 2008; Ratcliff & Rouder, 1998; Ratcliff & Smith, 2004). Like other Sequential Sampling Models, the DDM comprises psychologically interpretable parameters that collectively form a generative model for reaction time distributions of both responses.
The Diffusion Decision Model (DDM; Ratcliff et al., 2016) is a model of speeded decision-making in two-choice tasks. The DDM assumes that evidence accumulates over time, starting from a certain position, until it crosses one of two boundaries and triggers the corresponding response (Ratcliff & McKoon, 2008; Ratcliff & Rouder, 1998; Ratcliff & Smith, 2004). Like other Sequential Sampling Models, the DDM comprises psychologically interpretable parameters that collectively form a generative model for reaction time distributions of both responses.

The drift rate (ν) determines the rate at which the accumulation process approaches a decision boundary, representing the relative evidence for or against a specific response. The distance between the two decision boundaries (referred to as the evidence threshold, α) influences the amount of evidence required before executing a response. Non-decision-related components, including perceptual encoding, movement initiation, and execution, are accounted for in the DDM and reflected in the τ parameter. Lastly, the model incorporates a bias in the evidence accumulation process through the parameter z, affecting the starting point of the drift process in relation to the two boundaries. The z parameter in DDM is relative to a (i.e. it ranges from 0 to 1).

However, in the Ratcliff Diffusion Decision Model, we also include across-trial variability parameters. These parameters were developed to explain specific discrepancies between the DDM and experimental data (Anderson, 1960; Laming, 1968; Blurton et al., 2017). The data exhibited a difference in mean RT between correct and error responses that could not be captured by the DDM. As a result, two parameters for across-trial variability were introduced to explain this difference: across-trial variability in the starting point (sz) to explain fast errors (Laming, 1968), and across-trial variability in drift rate (η) to explain slow errors (Ratcliff, 1978; Ratcliff and Rouder, 1998). Additionally, the DDM also showed a sharper rise in the leading edge of the response time distribution than observed in the data. To capture this leading edge effect, across-trial variability in non-decision time (st) was introduced.

Previous work has validated predictions of these across-trial variability parameters (Wagenmakers et al., 2009). When compared to the DDM, the Ratcliff DDM improves the fit to the data. Researchers now often assume that the core parameters of sequential sampling models, such as drift rates, non-decision times, and starting points vary between trials.

One last parameter is the within-trial variability in drift rate (σ), or the diffusion coefficient. The diffusion coefficient is the standard deviation of the evidence accumulation process within one trial. It is a scaling parameter and by convention it is kept fixed. Following Navarro & Fuss, (2009), we use the σ = 1 version.

# Example
Expand Down Expand Up @@ -33,8 +37,11 @@ In the code below, we will define parameters for the DDM and create a model obje

The average slope of the information accumulation process. The drift gives information about the speed and direction of the accumulation of information. Typical range: -5 < ν < 5

Across-trial-variability of drift rate. Standard deviation of a normal distribution with mean v describing the distribution of actual drift rates from specific trials. Values different from 0 can predict slow errors. Typical range: 0 < η < 2. Default is 0.
Copy link
Owner

@itsdfish itsdfish Jul 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order for the code to run correctly across @example blocks, you need to add an @setup block to define global variables. For example, in the LBA docs, we have:

using SequentialSamplingModels
using SSMPlots 
using Random

Please add the @setup block and test the docs locally with the following procedure:

  1. in shell mode, cd to .julia/dev/SequentialSamplingModels
  2. in package mode run activate ./docs
  3. In REPL mode, run using LiveServer; servedocs()
  4. Using ctrl + click, on the hyperlink http://localhost:8000/ ... which can be found at the end of the output

This will allow you to verify that the docs render correctly.


```@example DDM
ν=1.0
η = 0.16
```

### Boundary Separation
Expand All @@ -49,24 +56,30 @@ The amount of information that is considered for a decision. Large values indica

The duration for a non-decisional processes (encoding and response execution). Typical range: 0.1 < τ < 0.5

Across-trial-variability of non-decisional components. Range of a uniform distribution with mean τ + st/2 describing the distribution of actual τ values across trials. Accounts for response times below t0. Reduces skew of predicted RT distributions. Typical range: 0 < τ < 0.2. Default is 0.

```@example DDM
τ = 0.30
st = 0.10
```

### Starting Point

An indicator of an an initial bias towards a decision. The z parameter is relative to a (i.e. it ranges from 0 to 1).

Across-trial-variability of starting point. Range of a uniform distribution with mean z describing the distribution of actual starting points from specific trials. Values different from 0 can predict fast errors. Typical range: 0 < sz < 0.5. Default is 0.

```@example DDM
z = 0.50
sz = 0.05
```

### DDM Constructor

Now that values have been assigned to the parameters, we will pass them to `DDM` to generate the model object.

```@example DDM
dist = DDM(ν, α, τ, z)
dist = DDM(ν, α, τ, z, η, sz, st, σ)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I run the code locally, it returns an error saying that sigma is not defined. One way to fix it is to use keyword arguments:

dist = DDM(;ν, α, τ, z, η, sz, st)

Unfortunately, pdf returns several NaN values:

julia> pdf.(dist, choices, rts)
10000-element Vector{Float64}:
   0.6644609799858928
   2.397578625897862
 NaN
   1.626677791256147
   3.2414299482802313
 NaN
   1.1213269218174562
   0.9325796659500193
   3.4708089396028527
   ⋮
   1.0632326904379477
   1.5706034041806405
   2.189991933805072
 NaN
   1.6308676194613154
 NaN
   3.589251216241856
   1.2956226038321284
   3.4853551106721863

logpdf returns a Domain error:

logpdf.(dist, choices, rts)
ERROR: DomainError with -0.005629379044919607:
log will only return a complex result if called with a complex argument. Try log(Complex(x)).

```

## Simulate Model
Expand Down Expand Up @@ -108,6 +121,10 @@ plot!(dist; t_range=range(.301, 1, length=100))

# References

Blurton, S. P., Kesselmeier, M., & Gondan, M. (2017). The first-passage time distribution for the diffusion model with variable drift. Journal of Mathematical Psychology, 76, 7–12. https://doi.org/10.1016/j.jmp.2016.11.003

Laming, D. R. J. (1968). Information theory of choice-reaction times. Academic Press.

Navarro, D., & Fuss, I. (2009). Fast and accurate calculations for first-passage times in Wiener diffusion models. https://doi.org/10.1016/J.JMP.2009.02.003

Ratcliff, R., & McKoon, G. (2008). The Diffusion Decision Model: Theory and Data for Two-Choice Decision Tasks. Neural Computation, 20(4), 873–922. https://doi.org/10.1162/neco.2008.12-06-420
Expand All @@ -117,3 +134,5 @@ Ratcliff, R., & Rouder, J. N. (1998). Modeling Response Times for Two-Choice Dec
Ratcliff, R., & Smith, P. L. (2004). A comparison of sequential sampling models for two-choice reaction time. Psychological Review, 111 2, 333–367. https://doi.org/10.1037/0033-295X.111.2.333

Ratcliff, R., Smith, P. L., Brown, S. D., & McKoon, G. (2016). Diffusion Decision Model: Current Issues and History. Trends in Cognitive Sciences, 20(4), 260–281. https://doi.org/10.1016/j.tics.2016.01.007

Wagenmakers, E.-J. (2009). Methodological and empirical developments for the Ratcliff diffusion model of response times and accuracy. European Journal of Cognitive Psychology, 21(5), 641-671.
141 changes: 0 additions & 141 deletions docs/src/Ratcliff_DDM.md

This file was deleted.

Loading
Loading