A fast engine for computing hierarchical Bayesian model implemented in the Dynamic Model of Choice.
ggdmc implements hierarchical Bayesian, evidence accumulation model (HB-EAM). This release includes drift-diffusion model (Ratcliff, 1978). Based on Voss, Rothermund, and Voss's (2004) fast-dm 30.2 density.c, the DDM in ggdmc implements the equations in their paper as C++ routines plus a new parallel integration function to handle high precision requirement.
ggdmc is derived from Andrew Heathcote's Dynamiuc Model of Choice (DMC), which has also implemented other numerous EAMs. Identical to DMC, ggdmc uses differential evolution Markov Chain Monte Carlo sampler to search optimal theta and phi that maximise posterior likelihood.
Here is a simple example extracted from Andrew Heathcote's DMC workshop materials. For further details, please see R help pages in this package.
require(ggdmc)## Use a 6-parameter drift-diffusion model## The only experimental factor is Stimulus typem1 <- model.dmc(p.map = list(a="1", v="1", z="1", d="1", sz="1", sv="1", t0="1",st0="1"),constants = c(st0=0, d=0), ## Fixed st0 and d at 0match.map = list(M = list(s1 = "r1", s2 = "r2")),factors = list(S=c("s1", "s2")), ## Two stimulus typesresponses = c("r1","r2"), ## Two response typestype = "rd") ## rd stands for Ratcliff's diffusion## Set up a prior probability distribution settingp.prior <- prior.p.dmc(dists = rep("tnorm", 6),p1 = c(a=2, v=2.5, z=.5, sz=.3, sv=1, t0=.3),p2 = c(a=.5, v=.5, z=.1, sz=.1, sv=.3, t0=.05),lower = c(0,-5, 0, 0, 0, 0),upper = c(5, 7, 2, 2, 2, 2))## Assume a true DDM parameter vectorp.vector <- c(a=1, v=1, z=.5, sz=.25, sv=0.2,t0=.15)## Use simulate function to simulate choice-RT data## One usually would like to fit his/her own empirical data.dat1 <- simulate(m1, nsim=1e2, p.vector=p.vector)## Set up a data model instace. This binds the empirical/simulated data with## the model set-upmdi1 <- data.model.dmc(dat1, m1)## Initialise a small sample## (1) iteration number == 250## (2) thinning length == 1## (3) prior distributions are listed in p.prior## (4) data == mdi1, an assumed model and a simulated/empirical data framesamples0 <- samples.dmc(nmc=250, p.prior=p.prior, data=mdi1, thin=1)## Fit the Bayesian modelsamples0 <- run.dmc(samples0)## Check if model converged, etc.gelman.diag.dmc(samples0)## Potential scale reduction factors:#### Point est. Upper C.I.## a 1.16 1.29## v 1.20 1.36## z 1.18 1.33## sz 1.12 1.21## sv 1.24 1.48## t0 1.16 1.34plot(samples0) ## Check traceplot to see if chains converged## Further details and more arguments, please see?gelman.diag.dmc?samples.dmc?run.dmc?plot.dmc## For hierarchical Bayesian model?h.run.dmc?h.samples.dmc?plot.dmc.list?plot.hyper
Successful cases for Windows environment:
Unsuccseeful cases for Windows environments:
From CRAN: install.packages("ggdmc")From source: install.packages("ggdmc_0.1.3.5.tar.gz", repos = NULL, type="source")### Other supporting packages for DMC (not necessary for ggdmc)install.packages("coda_0.18-1.3.tar.gz", repos = NULL, type="source")install.packages("tnorm_0.1.0.0.tar.gz", repos = NULL, type="source")
The ggdmc C++ codes are developed by Yi-Shin Lin.
The R codes mainly are incorporated from DMC developed by Andrew Heathcote.
If there is any bug been introduced inadvertently into DMC R codes, they are probably errors brought in by the first author. Please report any bugs you may find to the first author.
GPL-2. Please see License.md/LICENSE for details.
0.1.3.5 Yi-Shin Lin email@example.com
- First release to the public
0.1.3.4 Yi-Shin Lin firstname.lastname@example.org
- improve ddmc.Rd, dmc.Rd, dprior.Rd. - add dmc.R to generate ggdmc-package.Rd - merge DMC's and ggdmc's plot.prior and rename drawPrior as plot.priors - now ggdmc has its own classes dmc, dmc.list and hyper - ggdmc now uses S3 class to dispatch different summary and plot functions. - Finally, LBA model now is in ggdmc. likelihood.dmc and transform.dmc branch out to e.g., logLik.ddm, logLik.lba_B, becasue two new classes, ddm and lba_B are added. - New modules ggdmc_class.R and ggdmc_eam.R are added. The former defines DMC classes and the latter collects evidence accumulator models. - Add more help pages. - profile.dmc merge with stats's profile - roxygen2 now is also in charge of NAMESPACE
0.1.3.0 Yi-Shin Lin email@example.com
- plot.dmc add function to superimpose prior distribution on top of posterior distribution (ggplot2). - DMC needs to call modified coda to use this function (base).