Skip to contents

Density and random generation functions for the EZ-Diffusion Model. The model operates on aggregated data: mean reaction time, variance of reaction time, and number of responses to the upper boundary.

Usage

dezdm(
  mean_rt,
  var_rt,
  n_upper,
  n_trials,
  drift,
  bound,
  ndt,
  zr = 0.5,
  s = 1,
  version = c("3par", "4par"),
  log = TRUE
)

rezdm(
  n,
  n_trials,
  drift,
  bound,
  ndt,
  zr = 0.5,
  s = 1,
  version = c("3par", "4par")
)

Arguments

mean_rt

Observed mean reaction time(s) in seconds. For version "3par", a numeric vector or single value. For version "4par", either a vector of length 2 (c(mean_rt_upper, mean_rt_lower)) for single observation, or a matrix with 2 columns for multiple observations.

var_rt

Observed variance of reaction times in seconds^2. For version "3par", a numeric vector or single value. For version "4par", either a vector of length 2 (c(var_rt_upper, var_rt_lower)) for single observation, or a matrix with 2 columns for multiple observations.

n_upper

Number of responses to the upper boundary

n_trials

Total number of trials

drift

Drift rate (evidence accumulation rate; can be positive or negative for below-chance performance).

bound

Boundary separation (distance between decision thresholds).

ndt

Non-decision time (seconds).

zr

Relative starting point (0 to 1). Only used for version "4par".

s

Diffusion constant (standard deviation of noise), default = 1.

version

Character; either "3par" (default) or "4par"

log

Logical; if TRUE, values are returned on the log scale.

n

Number of samples to generate

Value

dezdm gives the log-density of the observed summary statistics under the EZDM, and rezdm generates random summary statistics from the implied sampling distributions.

References

Wagenmakers, E.-J., Van Der Maas, H. L. J., & Grasman, R. P. P. P. (2007). An EZ-diffusion model for response time and accuracy. Psychonomic Bulletin & Review, 14(1), 3-22.

Chávez De la Peña, A. F., & Vandekerckhove, J. (2025). An EZ Bayesian hierarchical drift diffusion model for response time and accuracy. Psychonomic Bulletin & Review.

Examples

# 3-parameter version (single observation)
dezdm(
  mean_rt = 0.5, var_rt = 0.02, n_upper = 80, n_trials = 100,
  drift = 2, bound = 1.5, ndt = 0.3
)
#> [1] -46.8172

# 3-parameter version (vectorized)
dezdm(
  mean_rt = c(0.5, 0.55), var_rt = c(0.02, 0.025),
  n_upper = c(80, 75), n_trials = c(100, 100),
  drift = 2, bound = 1.5, ndt = 0.3
)
#> [1] -46.8172 -39.4188

# 4-parameter version (single observation)
dezdm(
  mean_rt = c(0.45, 0.55), var_rt = c(0.018, 0.025),
  n_upper = 80, n_trials = 100,
  drift = 2, bound = 1.5, ndt = 0.3, zr = 0.55, version = "4par"
)
#> [1] -50.34562

# generate random summary statistics
rezdm(n = 100, n_trials = 100, drift = 2, bound = 1.5, ndt = 0.3)
#>       mean_rt     var_rt n_upper n_trials
#> 1   0.6330928 0.06509706      99      100
#> 2   0.6067023 0.06068551      92      100
#> 3   0.6596245 0.05716099      96      100
#> 4   0.6479363 0.05988609      94      100
#> 5   0.6611418 0.05647038      95      100
#> 6   0.6548820 0.06455131      97      100
#> 7   0.6233123 0.07035881      99      100
#> 8   0.6439417 0.06313122      96      100
#> 9   0.5968648 0.04974145      95      100
#> 10  0.6504479 0.04801153     100      100
#> 11  0.6633062 0.06073794      94      100
#> 12  0.6215323 0.04175730      98      100
#> 13  0.5904859 0.05249843      92      100
#> 14  0.6004784 0.06541772      98      100
#> 15  0.6147015 0.04934332      95      100
#> 16  0.6723269 0.07028122      97      100
#> 17  0.6395157 0.06394442      95      100
#> 18  0.6136843 0.04325469      91      100
#> 19  0.6522689 0.05339963      94      100
#> 20  0.5884555 0.05451280      96      100
#> 21  0.6338096 0.05172390      95      100
#> 22  0.6675348 0.06379048      94      100
#> 23  0.6313025 0.05655082      96      100
#> 24  0.6710650 0.05873389      97      100
#> 25  0.6844724 0.06295105      95      100
#> 26  0.6143413 0.04614352      94      100
#> 27  0.6154903 0.04315498      94      100
#> 28  0.6186963 0.05139616      93      100
#> 29  0.6519301 0.05591479      96      100
#> 30  0.6558019 0.03844764      93      100
#> 31  0.6702752 0.06508662      96      100
#> 32  0.6694440 0.05335587      94      100
#> 33  0.6651431 0.05714546      97      100
#> 34  0.6623062 0.05926317      91      100
#> 35  0.6430432 0.04897622      97      100
#> 36  0.6159375 0.06995371      97      100
#> 37  0.6205665 0.06746362      95      100
#> 38  0.6479533 0.04375136      94      100
#> 39  0.6772545 0.05048432      92      100
#> 40  0.6804858 0.05792318      94      100
#> 41  0.5964190 0.04985665      97      100
#> 42  0.6180135 0.06592803      97      100
#> 43  0.6759123 0.06609616      96      100
#> 44  0.6115841 0.06846590      93      100
#> 45  0.6039356 0.04838173      97      100
#> 46  0.6534479 0.05463676      94      100
#> 47  0.6827265 0.06242710      93      100
#> 48  0.6838587 0.05275144      94      100
#> 49  0.6525391 0.06055379      96      100
#> 50  0.6568689 0.05873476      93      100
#> 51  0.6532560 0.06095689      95      100
#> 52  0.6390410 0.04568487      96      100
#> 53  0.5611998 0.05382874      95      100
#> 54  0.6560465 0.04772817      94      100
#> 55  0.6303716 0.05358205      97      100
#> 56  0.6612855 0.04684440      96      100
#> 57  0.6241090 0.05969555      96      100
#> 58  0.6025333 0.05094580      95      100
#> 59  0.6701058 0.06069475      96      100
#> 60  0.6435707 0.05217649      88      100
#> 61  0.7188638 0.05164959      94      100
#> 62  0.6604356 0.05264590      97      100
#> 63  0.6683303 0.07598606      98      100
#> 64  0.6569278 0.05249242      94      100
#> 65  0.6236264 0.06857890      98      100
#> 66  0.6303252 0.06038180      88      100
#> 67  0.6661014 0.06334310      94      100
#> 68  0.6632287 0.05088585      96      100
#> 69  0.6549883 0.07124614      97      100
#> 70  0.6158234 0.05724333      91      100
#> 71  0.6788709 0.05482040      97      100
#> 72  0.6050748 0.06316697      98      100
#> 73  0.6296946 0.05047677      95      100
#> 74  0.6986730 0.06492939      94      100
#> 75  0.6527223 0.06434130      96      100
#> 76  0.6595372 0.04291456      97      100
#> 77  0.6503535 0.08400249      91      100
#> 78  0.6136431 0.06702841      98      100
#> 79  0.6251914 0.05677260      95      100
#> 80  0.6435316 0.06167719      97      100
#> 81  0.5748085 0.04868985      95      100
#> 82  0.6232061 0.03659991      97      100
#> 83  0.6589920 0.06001926      93      100
#> 84  0.6321231 0.05989998      96      100
#> 85  0.6333010 0.04666608      96      100
#> 86  0.6608460 0.06067553      97      100
#> 87  0.6260458 0.06043209      95      100
#> 88  0.6560523 0.06989989      95      100
#> 89  0.6036348 0.06332708      97      100
#> 90  0.6072784 0.06859433      94      100
#> 91  0.6015950 0.05107018      99      100
#> 92  0.6413772 0.05336061      97      100
#> 93  0.6343302 0.06115454      98      100
#> 94  0.6726708 0.05315609      95      100
#> 95  0.6383762 0.06332375      95      100
#> 96  0.6767997 0.07621064      99      100
#> 97  0.6874571 0.06096442      97      100
#> 98  0.6268826 0.06529676      95      100
#> 99  0.6495241 0.06756020      94      100
#> 100 0.6190468 0.05818894      95      100
rezdm(
  n = 100, n_trials = 100, drift = 2, bound = 1.5, ndt = 0.3,
  zr = 0.55, version = "4par"
)
#>     mean_rt_upper mean_rt_lower var_rt_upper var_rt_lower n_upper n_trials
#> 1       0.6295673     0.8437794   0.07251529 6.594494e-02      95      100
#> 2       0.6320978     0.5114707   0.05050999 8.772947e-02      96      100
#> 3       0.5973184     0.6673136   0.06079219 1.404990e-04      98      100
#> 4       0.6151276     0.7629407   0.04919219 4.067938e-02      96      100
#> 5       0.6269469     0.6724622   0.05223744 8.286223e-04      98      100
#> 6       0.5769794     0.9552659   0.06613092 1.360440e-01      96      100
#> 7       0.6412830     0.9240977   0.04523218 1.451390e-01      96      100
#> 8       0.5862533     0.3736954   0.06312256 4.914088e-01      98      100
#> 9       0.6585223     0.7532250   0.06169105 7.491025e-02      97      100
#> 10      0.6116006     0.5878986   0.04948064 2.952359e-02      96      100
#> 11      0.5953911     0.6601617   0.05841401 1.273573e-03      96      100
#> 12      0.6481502     0.8012077   0.06609551 8.794254e-02      95      100
#> 13      0.6122368     0.6582434   0.05800952 1.207774e-01      97      100
#> 14      0.6496379     0.7677277   0.05427092 1.210271e-01      98      100
#> 15      0.5998191     0.7622475   0.05535902 2.570438e-02      98      100
#> 16      0.5979670     0.5571375   0.04750986 5.194862e-02      95      100
#> 17      0.6042490     0.5978987   0.05917475 4.281329e-02      97      100
#> 18      0.5811900     0.7509453   0.03992972 4.571999e-02      96      100
#> 19      0.6207346     0.6529731   0.05880500 1.139349e-01      93      100
#> 20      0.6053061     0.5714547   0.05450927 1.017138e-01      96      100
#> 21      0.5713753     0.6575810   0.05029375 5.842375e-02      97      100
#> 22      0.6232663     0.3655228   0.06297152 7.108647e-02      97      100
#> 23      0.6127105            NA   0.04976760           NA      99      100
#> 24      0.6136674     0.6094155   0.04544656 2.026951e-02      93      100
#> 25      0.6067371     0.6833750   0.06404082 2.179984e-02      98      100
#> 26      0.6040189     0.3671243   0.05657460 8.822396e-02      97      100
#> 27      0.5936968            NA   0.04667607           NA      99      100
#> 28      0.6294724     0.6667818   0.05879693 1.696963e-02      98      100
#> 29      0.6300068     0.7050965   0.06963457 8.973507e-02      98      100
#> 30      0.6355551     0.5300147   0.05710740 3.900999e-02      96      100
#> 31      0.5823655            NA   0.06665255           NA      99      100
#> 32      0.5885302     0.7730889   0.04407351 3.592315e-02      98      100
#> 33      0.6304477            NA   0.06660727           NA     100      100
#> 34      0.6324403     0.5647829   0.05122719 3.016586e-02      98      100
#> 35      0.5982677     0.6755132   0.05770518 1.102927e-02      95      100
#> 36      0.5916293            NA   0.04072482           NA     100      100
#> 37      0.6174610     0.4623220   0.06015877 1.122050e-01      95      100
#> 38      0.5819899     0.6601703   0.04833873 1.390548e-02      96      100
#> 39      0.6217734     0.8603251   0.05661979 8.924183e-02      97      100
#> 40      0.6542422     0.8217092   0.06806317 1.439070e-01      97      100
#> 41      0.5596505     0.4642255   0.05803406 1.400501e-01      98      100
#> 42      0.5939036     0.7901467   0.05931170 1.026820e-01      95      100
#> 43      0.6242977     1.0753507   0.04172722 7.093010e-02      98      100
#> 44      0.6432080     0.6652863   0.04920139 5.232873e-04      98      100
#> 45      0.6050643     0.8076987   0.04028089 5.379542e-02      96      100
#> 46      0.6115253     0.7366095   0.05727642 3.362359e-02      97      100
#> 47      0.6179933     0.6462888   0.06023504 3.251443e-02      96      100
#> 48      0.6368056     0.8382029   0.04460444 5.028376e-02      97      100
#> 49      0.6315243     0.4227948   0.05997528 4.178054e-02      96      100
#> 50      0.6012017     0.6580344   0.07255769 2.824223e-02      96      100
#> 51      0.5990354     0.9037728   0.06913628 1.024403e-01      97      100
#> 52      0.6161395     0.7721187   0.05687585 4.116261e-02      98      100
#> 53      0.5902118     0.7365785   0.05422370 3.609071e-02      96      100
#> 54      0.5664137     0.8747776   0.04823711 8.478922e-02      95      100
#> 55      0.5979981     0.6877169   0.04848923 1.471167e-01      96      100
#> 56      0.6159703     0.7497508   0.05364703 7.955427e-02      97      100
#> 57      0.6132035     0.7232543   0.05438193 2.199048e-02      96      100
#> 58      0.6068912     0.5883691   0.06100047 6.395670e-02      93      100
#> 59      0.5655012     0.7680331   0.07866987 8.015246e-02      96      100
#> 60      0.6125556     0.7565666   0.05671351 7.895931e-02      91      100
#> 61      0.6170409     0.6450699   0.07207494 1.059696e-02      93      100
#> 62      0.6595397     0.5026429   0.05743236 8.925177e-02      95      100
#> 63      0.5446846     0.6583564   0.07116811 3.564531e-03      98      100
#> 64      0.5853013     0.6741303   0.05570803 5.108503e-02      98      100
#> 65      0.6187329     0.5844177   0.07079873 1.007807e-01      94      100
#> 66      0.5790558     0.6494662   0.05819022 1.066147e-03      97      100
#> 67      0.6520117     0.7826483   0.05308372 8.720798e-02      97      100
#> 68      0.6388185     0.4267374   0.05236357 1.382534e-01      98      100
#> 69      0.6192317     0.6853107   0.05083846 1.156912e-02      97      100
#> 70      0.5932924     0.7126934   0.05373026 9.538665e-02      94      100
#> 71      0.6139888     0.7666147   0.05547828 2.370053e-02      97      100
#> 72      0.6117948     0.6664951   0.05682791 5.652457e-02      94      100
#> 73      0.6265021     0.3199878   0.05307565 8.876615e-02      97      100
#> 74      0.5989946     0.6762536   0.04200344 3.929702e-04      98      100
#> 75      0.6061053            NA   0.05899444           NA     100      100
#> 76      0.6201900     0.6491733   0.07102137 7.996064e-02      97      100
#> 77      0.6225243     1.0478376   0.04679312 1.704768e-01      97      100
#> 78      0.6026407     0.6686098   0.05838654 7.001612e-06      98      100
#> 79      0.5978713     0.3269993   0.05453544 1.267717e-01      97      100
#> 80      0.6314863     0.6794807   0.05312758 6.779086e-02      95      100
#> 81      0.6080299            NA   0.04890462           NA      99      100
#> 82      0.5871164     0.5229742   0.04363782 7.526974e-02      96      100
#> 83      0.5766547     0.5176090   0.05395927 2.132737e-02      96      100
#> 84      0.6311633     0.7354626   0.05273845 4.036989e-02      94      100
#> 85      0.6162625     0.3771659   0.04131055 4.475147e-02      98      100
#> 86      0.6181450            NA   0.06147180           NA      99      100
#> 87      0.6409817     0.8714495   0.06197870 9.396728e-02      94      100
#> 88      0.6435363     0.6177579   0.06175863 7.583563e-02      96      100
#> 89      0.6266914     0.6058099   0.05699086 3.882891e-02      96      100
#> 90      0.5620041     0.5206220   0.06772931 5.180630e-02      98      100
#> 91      0.6004314     1.1957896   0.04858873 1.235315e-01      98      100
#> 92      0.5656618     0.7274934   0.05800482 1.032673e-01      95      100
#> 93      0.6393932     0.6152189   0.06469085 3.746275e-03      96      100
#> 94      0.5917474     0.6847741   0.06400469 1.727901e-02      94      100
#> 95      0.5567018     0.5119306   0.04674984 8.988167e-02      96      100
#> 96      0.6041630     0.6956468   0.05798619 5.768874e-03      98      100
#> 97      0.5979620     0.7048022   0.05847856 1.246851e-02      95      100
#> 98      0.6318311     0.6927899   0.06266443 4.659150e-02      96      100
#> 99      0.5990506     0.4804478   0.06311816 2.490870e-02      97      100
#> 100     0.6483768     0.5589593   0.03766166 1.065355e-02      98      100