choiceRT_ddm_single: Choice Reaction Time Task

Description Usage Arguments Details Value References See Also Examples


Individual Bayesian Modeling of the Choice Reaction Time Task with the following parameters: "alpha" (boundary separation), "beta" (bias), "delta" (drift rate), "tau" (non-decision time).

MODEL: Drift Diffusion Model (Ratcliff, 1978, Psychological Review)
*Note that this implementation is not the full Drift Diffusion Model as described in Ratcliff (1978). This implementation estimates the drift rate, boundary separation, starting point, and non-decision time; but not the between- and within-trial variances in these parameters.

Code for this model is based on codes/comments by Guido Biele, Joseph Burling, Andrew Ellis, and potential others @ Stan mailing

Parameters of the DDM (parameter names in Ratcliff), from
- alpha (a): Boundary separation or Speed-accuracy trade-off (high alpha means high accuracy). 0 < alpha
- beta (b): Initial bias, for either response (beta > 0.5 means bias towards "upper" response 'A'). 0 < beta < 1
- delta (v): Drift rate; Quality of the stimulus (delta close to 0 means ambiguous stimulus or weak ability). 0 < delta
- tau (ter): Non-decision time + Motor response time + encoding time (high means slow encoding, execution). 0 < tau (in seconds)


choiceRT_ddm_single(data = "choose", niter = 4000, nwarmup = 1000,
  nchain = 4, ncore = 1, nthin = 1, inits = "random",
  indPars = "mean", modelRegressor = FALSE, vb = FALSE,
  inc_postpred = FALSE, adapt_delta = 0.95, stepsize = 1,
  max_treedepth = 10, ...)



A .txt file containing the data to be modeled. Data columns should be labeled as: "subjID", "choice", "RT". See Details below for more information.


Number of iterations, including warm-up. Defaults to 4000.


Number of iterations used for warm-up only. Defaults to 1000.


Number of Markov chains to run. Defaults to 4.


Number of CPUs to be used for running. Defaults to 1.


Every i == nthin sample will be used to generate the posterior distribution. Defaults to 1. A higher number can be used when auto-correlation within the MCMC sampling is high.


Character value specifying how the initial values should be generated. Options are "fixed" or "random", or your own initial values.


Character value specifying how to summarize individual parameters. Current options are: "mean", "median", or "mode".


Export model-based regressors? TRUE or FALSE. Currently not available for this model.


Use variational inference to approximately draw from a posterior distribution. Defaults to FALSE.


(Currently not available.) Include trial-level posterior predictive simulations in model output (may greatly increase file size). Defaults to FALSE.


Floating point value representing the target acceptance probability of a new sample in the MCMC chain. Must be between 0 and 1. See Details below.


Integer value specifying the size of each leapfrog step that the MCMC sampler can take on each new iteration. See Details below.


Integer value specifying how many leapfrog steps the MCMC sampler can take on each new iteration. See Details below.


For this model, it's possible to set the following model-specific argument to a value that you may prefer.
RTbound: Floating point value representing the lower bound (i.e., minimum allowed) reaction time. Defaults to 0.1 (100 milliseconds).


This section describes some of the function arguments in greater detail.

data should be assigned a character value specifying the full path and name (including extension information, e.g. ".txt") of the file that contains the behavioral data-set of all subjects of interest for the current analysis. The file should be a tab-delimited text file, whose rows represent trial-by-trial observations and columns represent variables.
For the Choice Reaction Time Task, there should be 3 columns of data with the labels "subjID", "choice", "RT". It is not necessary for the columns to be in this particular order, however it is necessary that they be labeled correctly and contain the information below:


A unique identifier for each subject in the data-set.


Choice made for the current trial, coded as 1/2 to indicate lower/upper boundary or left/right choices (e.g., 1 1 1 2 1 2).


Choice reaction time for the current trial, in seconds (e.g., 0.435 0.383 0.314 0.309, etc.).

*Note: The file may contain other columns of data (e.g. "ReactionTime", "trial_number", etc.), but only the data within the column names listed above will be used during the modeling. As long as the necessary columns mentioned above are present and labeled correctly, there is no need to remove other miscellaneous data columns.

nwarmup is a numerical value that specifies how many MCMC samples should not be stored upon the beginning of each chain. For those familiar with Bayesian methods, this is equivalent to burn-in samples. Due to the nature of the MCMC algorithm, initial values (i.e. where the sampling chains begin) can have a heavy influence on the generated posterior distributions. The nwarmup argument can be set to a high number in order to curb the effects that initial values have on the resulting posteriors.

nchain is a numerical value that specifies how many chains (i.e. independent sampling sequences) should be used to draw samples from the posterior distribution. Since the posteriors are generated from a sampling process, it is good practice to run multiple chains to ensure that a reasonably representative posterior is attained. When the sampling is complete, it is possible to check the multiple chains for convergence by running the following line of code: plot(output, type = "trace"). The trace-plot should resemble a "furry caterpillar".

nthin is a numerical value that specifies the "skipping" behavior of the MCMC sampler, using only every i == nthin samples to generate posterior distributions. By default, nthin is equal to 1, meaning that every sample is used to generate the posterior.

Control Parameters: adapt_delta, stepsize, and max_treedepth are advanced options that give the user more control over Stan's MCMC sampler. It is recommended that only advanced users change the default values, as alterations can profoundly change the sampler's behavior. Refer to 'The No-U-Turn Sampler: Adaptively Setting Path Lengths in Hamiltonian Monte Carlo (Hoffman & Gelman, 2014, Journal of Machine Learning Research)' for more information on the sampler control parameters. One can also refer to 'Section 34.2. HMC Algorithm Parameters' of the Stan User's Guide and Reference Manual, or to the help page for stan for a less technical description of these arguments.


A class "hBayesDM" object modelData with the following components:


Character value that is the name of the model ("choiceRT_ddm_single").


Data.frame containing the summarized parameter values (as specified by indPars) for each subject.


List object containing the posterior samples over different parameters.


A class stanfit object that contains the fitted Stan model.


Data.frame containing the raw data used to fit the model, as specified by the user.


Ratcliff, R. (1978). A theory of memory retrieval. Psychological Review, 85(2), 59-108.

See Also

We refer users to our in-depth tutorial for an example of using hBayesDM:


## Not run: 
# Run the model and store results in "output"
output <- choiceRT_ddm_single("example", niter = 2000, nwarmup = 1000, nchain = 4, ncore = 4)

# Visually check convergence of the sampling chains (should look like 'hairy caterpillars')
plot(output, type = "trace")

# Check Rhat values (all Rhat values should be less than or equal to 1.1)

# Plot the posterior distributions of the hyper-parameters (distributions should be unimodal)

# Show the WAIC and LOOIC model fit estimates

## End(Not run)

hBayesDM documentation built on Jan. 21, 2019, 5:04 p.m.