# Is there an R implementation of the linear ballistic accumulator model or Ratcliff's diffusion model for measuring response time and accuracy?

I am looking for an implementation of the linear ballistic accumulator model or Ratcliff's diffusion model (e.g. in R, MATLAB, or Python).

Here are a few options. I have not tried them yet personally.

As mentioned below, the rtdists package in R is able to fit both LBA and diffusion models.

# Other Options

### LBA

Scott Brown has a copy of Donkin et al (2009) on his web page with some code in R, Excel, and WinBUGS for fitting the LBA model:

There's also the glba package on CRAN by Ingmar Visser.

### Diffusion model

The Diffussion model is available as a matlab toolbox called (DMAT).

### References

• Donkin, C., Averell, L., Brown, S.D., & Heathcote, A. (2009) Getting more from accuracy and response time data: Methods for fitting the Linear Ballistic Accumulator model. Behavior Research Methods, 41, 1095-1110. PDF
• Vandekerckhove, J., & Tuerlinckx, F. (2008). Diffusion model analysis with MATLAB: A DMAT primer. Behavior Research Methods, 40, 61-72. doi:10.3758/BRM.40.1.61 PDF

For the diffusion model, there is also Eric-Jan Wagenmakers' "EZ-diffusion model", which you can find here.

This paper compares three different pieces of software for estimation of diffusion model parameters:

von Ravenzwaaij D., & Oberauer, K. (2009). How to use the diffusion model: Parameter recovery of three methods: EZ, fast-dm, and DMAT. Journal of Mathematical Psychology, 53 (6), 463–473. [PDF]

The R package diffIRT (http://www.dylanmolenaar.nl/jss1265.pdf) estimates both the Q and the D diffusion models (see his website for the van der Maas et al. paper discussing the differences between these models). R code for the EZ2 approach, which is much faster if that is important for your applications, is http://raoul.socsci.uva.nl/EZ2/.

In the subheading you also mention that you're interested in matlab / python implementations:

I've personally used DMAT in matlab at that's a nice package. However, the python based HDDM package may be one of the best around at the moment (in my opinion) and it has a good user guide.

http://ski.clps.brown.edu/hddm_docs/abstract.html

and the paper associated with the package:

Wieki et al (2013): http://journal.frontiersin.org/article/10.3389/fninf.2013.00014/full

### References

The R package rtdists is another great option:

Provides response time distributions (density/PDF, distribution function/CDF, quantile function, and random generation): (a) Ratcliff diffusion model based on C code by Andreas and Jochen Voss and (b) linear ballistic accumulator (LBA) with different distributions underlying the drift rate.