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 (positive, evidence accumulation rate).

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.81829

# 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.81829 -39.41976

# 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.34668

# 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.6052179 0.06050207      95      100
#> 2   0.6254183 0.05563988      96      100
#> 3   0.6980983 0.06228497      89      100
#> 4   0.6111334 0.05344788      98      100
#> 5   0.6342018 0.06654405      98      100
#> 6   0.6472026 0.06436166      94      100
#> 7   0.6184780 0.06344055      93      100
#> 8   0.6445478 0.05849705      96      100
#> 9   0.6258324 0.06742749      97      100
#> 10  0.6238227 0.06413316      98      100
#> 11  0.6781039 0.07351276      92      100
#> 12  0.6663506 0.05548701      92      100
#> 13  0.6091022 0.06164208      97      100
#> 14  0.6519874 0.07127367      95      100
#> 15  0.6107959 0.06618435      94      100
#> 16  0.6436366 0.05972240      96      100
#> 17  0.6409623 0.05643593      96      100
#> 18  0.6509810 0.05976457      94      100
#> 19  0.5970325 0.06306146      97      100
#> 20  0.6490920 0.06712302      94      100
#> 21  0.6489317 0.05774927      96      100
#> 22  0.6572365 0.04789838      97      100
#> 23  0.6433667 0.04871161      97      100
#> 24  0.6749454 0.05210940      94      100
#> 25  0.6791458 0.05591924      98      100
#> 26  0.6171466 0.04644418      93      100
#> 27  0.6542550 0.05155062      97      100
#> 28  0.6209785 0.07399368      95      100
#> 29  0.6438131 0.05926333      94      100
#> 30  0.6035100 0.04896390      92      100
#> 31  0.6396154 0.05401807      93      100
#> 32  0.7014167 0.06365506      97      100
#> 33  0.6476300 0.04953622      98      100
#> 34  0.6445773 0.04800872      93      100
#> 35  0.6406064 0.07377317      95      100
#> 36  0.6681105 0.04915244      93      100
#> 37  0.6621595 0.05108533      95      100
#> 38  0.6114874 0.05414572      98      100
#> 39  0.6025502 0.05883868      95      100
#> 40  0.6489919 0.06324619      98      100
#> 41  0.5942928 0.04972676      96      100
#> 42  0.6281111 0.05134011      94      100
#> 43  0.6613315 0.05530200      93      100
#> 44  0.6625984 0.05216417      94      100
#> 45  0.6638746 0.07744094      95      100
#> 46  0.6249537 0.06471903      96      100
#> 47  0.6497752 0.04674280      95      100
#> 48  0.6357006 0.05035930      95      100
#> 49  0.6722934 0.06993272      99      100
#> 50  0.6606856 0.07079888      97      100
#> 51  0.6300447 0.07485502      94      100
#> 52  0.6469153 0.07189078      97      100
#> 53  0.6029423 0.06650394      96      100
#> 54  0.6387738 0.05694117      93      100
#> 55  0.6690939 0.05254938      96      100
#> 56  0.6309338 0.04829231      98      100
#> 57  0.6854628 0.06324118      98      100
#> 58  0.5794162 0.08984538      97      100
#> 59  0.6536222 0.05298167      99      100
#> 60  0.5875901 0.06057551      97      100
#> 61  0.6214681 0.06209804      91      100
#> 62  0.6468571 0.06776517      96      100
#> 63  0.6481228 0.05878523      96      100
#> 64  0.6365232 0.04994417      97      100
#> 65  0.6358022 0.04496080      95      100
#> 66  0.6246808 0.04296971      96      100
#> 67  0.6411993 0.05358469      97      100
#> 68  0.6785620 0.05693912      90      100
#> 69  0.6461103 0.07417500      93      100
#> 70  0.6429481 0.05953882      97      100
#> 71  0.6406730 0.05909655      95      100
#> 72  0.6538638 0.05653600      99      100
#> 73  0.6586971 0.05190858      93      100
#> 74  0.6304437 0.04088859      97      100
#> 75  0.6421131 0.05756569      95      100
#> 76  0.6297958 0.05522054      93      100
#> 77  0.6508363 0.04957483      95      100
#> 78  0.6517144 0.05310660      97      100
#> 79  0.6746506 0.06238419      97      100
#> 80  0.6265239 0.07335301      97      100
#> 81  0.6839742 0.05887133      93      100
#> 82  0.6280588 0.03909572      95      100
#> 83  0.6047993 0.06138010      95      100
#> 84  0.6256696 0.05844426      93      100
#> 85  0.6845577 0.06272885      96      100
#> 86  0.6562022 0.05141454      94      100
#> 87  0.6182736 0.07102396      94      100
#> 88  0.6612252 0.07002556      90      100
#> 89  0.6590743 0.05809592      97      100
#> 90  0.6360479 0.04845979      95      100
#> 91  0.6250707 0.06098853      94      100
#> 92  0.6195319 0.05805368      95      100
#> 93  0.5935628 0.06454075      94      100
#> 94  0.6380651 0.06365892      94      100
#> 95  0.6626896 0.07446620      99      100
#> 96  0.6113765 0.05565502      97      100
#> 97  0.5813777 0.05200712      93      100
#> 98  0.5854616 0.05035923      92      100
#> 99  0.6584005 0.06810745      93      100
#> 100 0.6651854 0.05783690      94      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.6502511     0.7649559   0.04989655 0.0566983804      95      100
#> 2       0.5885282            NA   0.07202299           NA      99      100
#> 3       0.5661361     0.7601864   0.06791018 0.0178861595      98      100
#> 4       0.5988479            NA   0.06136743           NA     100      100
#> 5       0.6650872     0.5876834   0.07303294 0.0361821900      97      100
#> 6       0.5934796            NA   0.05259932           NA      99      100
#> 7       0.6136431            NA   0.04519916           NA      99      100
#> 8       0.6078325            NA   0.05180133           NA      99      100
#> 9       0.6436044            NA   0.04781537           NA     100      100
#> 10      0.5879990     0.7411341   0.05455867 0.0492931339      96      100
#> 11      0.5898870     0.5701947   0.05068076 0.0175300817      96      100
#> 12      0.5975441     0.6987746   0.04965899 0.0006577261      98      100
#> 13      0.6074822     0.6684668   0.05773212 0.0162000056      97      100
#> 14      0.5941104     0.5207589   0.05287414 0.0615187804      95      100
#> 15      0.5967974     0.6289906   0.04844397 0.0178301824      97      100
#> 16      0.6464962     0.7071709   0.04560899 0.1019294204      97      100
#> 17      0.6711845     0.7453830   0.06244705 0.0592707432      96      100
#> 18      0.6393857     0.7939970   0.06400634 0.0687673939      95      100
#> 19      0.6441257     0.7588128   0.06055501 0.0110337500      94      100
#> 20      0.6097072     0.5430035   0.05157123 0.1042595383      96      100
#> 21      0.5880901     0.5604545   0.06843787 0.0192550108      98      100
#> 22      0.6119675     0.9670759   0.05459167 0.0618571499      98      100
#> 23      0.5880676            NA   0.05729573           NA      99      100
#> 24      0.5891970     0.7147013   0.06241311 0.0312805778      98      100
#> 25      0.6193063     0.6097477   0.06388925 0.0206531266      96      100
#> 26      0.5860630     0.7883369   0.04846007 0.0477973937      94      100
#> 27      0.5788661     0.3984580   0.05635381 0.0719746029      95      100
#> 28      0.6089412     0.6662716   0.04937643 0.0758691671      96      100
#> 29      0.5983654     0.8210196   0.06579482 0.1199972451      95      100
#> 30      0.6194269     0.6892982   0.06511848 0.0104190400      96      100
#> 31      0.6351105     0.4870586   0.05532864 0.0262685720      94      100
#> 32      0.6386732     0.7409576   0.06392190 0.0334840543      95      100
#> 33      0.5542522     0.7087651   0.04955178 0.0222317307      94      100
#> 34      0.6058988     0.6517884   0.04307826 0.0047805714      97      100
#> 35      0.5898270     0.6329341   0.06226155 0.0558343281      93      100
#> 36      0.5913624            NA   0.05749672           NA      99      100
#> 37      0.6197150     0.6894210   0.06513621 0.0037066232      98      100
#> 38      0.5923942     0.7621588   0.05190030 0.0342465501      96      100
#> 39      0.6162915     0.6684157   0.06784264 0.0059436739      96      100
#> 40      0.5854641     0.9358323   0.05739004 0.0649269577      96      100
#> 41      0.6373105     0.4309415   0.05339503 0.0843122914      98      100
#> 42      0.5894361     0.3687429   0.06714432 0.0531072177      98      100
#> 43      0.6386572     0.6545556   0.05994743 0.0233428060      95      100
#> 44      0.6445549     0.5961913   0.05775674 0.0526948705      98      100
#> 45      0.6379854     0.6164503   0.05240530 0.0720440336      96      100
#> 46      0.6421695     0.7224946   0.05480577 0.1168618796      95      100
#> 47      0.6513483     0.7100595   0.06083781 0.0371535815      95      100
#> 48      0.6086234     0.6608077   0.04542720 0.0199195948      96      100
#> 49      0.6154137     0.9753739   0.06454822 0.0484148033      97      100
#> 50      0.5940066     0.5962897   0.05927818 0.0880821475      96      100
#> 51      0.5936590     0.5761910   0.04909567 0.0294379339      97      100
#> 52      0.6322256     0.6109041   0.05072763 0.0272219765      96      100
#> 53      0.6084217     0.7008212   0.05292776 0.0324502753      95      100
#> 54      0.5640575     0.4305302   0.06215920 0.1042389484      97      100
#> 55      0.5888341     0.4441832   0.04880785 0.0520642157      96      100
#> 56      0.6157849            NA   0.03688014           NA      99      100
#> 57      0.6292686     0.7412298   0.05063281 0.0755898668      98      100
#> 58      0.6055325     0.5107231   0.05989304 0.0707868658      97      100
#> 59      0.6351687     0.6726005   0.04514480 0.0125345601      96      100
#> 60      0.6136025     0.5933774   0.05856345 0.0763960161      96      100
#> 61      0.6619773     0.4864303   0.07463913 0.0826458142      96      100
#> 62      0.5658197     0.6232584   0.05686281 0.0982514800      97      100
#> 63      0.5925006     0.4509459   0.05297950 0.0308991127      96      100
#> 64      0.6282330            NA   0.06070118           NA     100      100
#> 65      0.5973281     0.7117089   0.03607314 0.0440500718      98      100
#> 66      0.6281872     0.5874707   0.04779714 0.0096981018      98      100
#> 67      0.6656722            NA   0.05569766           NA     100      100
#> 68      0.6327527     0.7296523   0.04923677 0.0425230735      98      100
#> 69      0.6413402     0.6847073   0.05284246 0.0005693311      98      100
#> 70      0.5727004     0.6391576   0.05167510 0.0602124879      95      100
#> 71      0.6216509     0.6610914   0.04279558 0.0098159957      96      100
#> 72      0.5870782     0.6723137   0.04062062 0.0621615312      96      100
#> 73      0.6372833            NA   0.05249562           NA      99      100
#> 74      0.6148388     0.8798555   0.04790742 0.2230895276      98      100
#> 75      0.6242288     0.7936442   0.06513523 0.2211701707      97      100
#> 76      0.6232099     0.6671429   0.05250682 0.1707600700      98      100
#> 77      0.6093080     0.4400994   0.05327112 0.1146225998      95      100
#> 78      0.5965755     0.6912063   0.05060187 0.0473521824      93      100
#> 79      0.6144070     0.6808274   0.06130882 0.0646025957      94      100
#> 80      0.6185848     0.6624157   0.04723519 0.0007469715      98      100
#> 81      0.5516827     0.7661256   0.04898964 0.0764927619      95      100
#> 82      0.6152020     0.9666840   0.04893381 0.0612704692      98      100
#> 83      0.6201223     0.8300093   0.05389726 0.1202119850      98      100
#> 84      0.5865748     0.7254114   0.05576797 0.0314577898      98      100
#> 85      0.6117304     0.6038887   0.05546558 0.0621342152      97      100
#> 86      0.5631120     0.6500472   0.05527303 0.0168799620      95      100
#> 87      0.6379170     0.7102212   0.04730706 0.0118317114      96      100
#> 88      0.6260746     0.5494706   0.05920880 0.0774671028      96      100
#> 89      0.5704335     0.8525632   0.05775482 0.0631036836      94      100
#> 90      0.6459393     0.8691286   0.05470662 0.0406217110      97      100
#> 91      0.6137296     0.5882533   0.05583998 0.0894212880      96      100
#> 92      0.6207608     0.8247125   0.06283831 0.0136249756      98      100
#> 93      0.6496656     0.7042346   0.05973638 0.0012830829      98      100
#> 94      0.6204379     1.1354141   0.05652376 0.2383413666      98      100
#> 95      0.6267790     0.5910407   0.03783508 0.0771920198      97      100
#> 96      0.6221307     0.8589899   0.05960141 0.0717127501      95      100
#> 97      0.6329551     0.7022623   0.06000839 0.0318497299      97      100
#> 98      0.5966331            NA   0.04373281           NA     100      100
#> 99      0.6288519     0.5726042   0.06549926 0.1276221992      98      100
#> 100     0.6356014     0.5513523   0.06818854 0.0383397174      96      100