Skip to contents

Fit a drift diffusion model for a single subject using maximum likelihood estimation.

Usage

td_ddm(
  data,
  discount_function,
  v_par_starts = c(0.01, 0.1, 1),
  beta_par_starts = c(0.25, 0.5, 0.75),
  alpha_par_starts = c(0.5, 1, 10),
  tau_par_starts = c(0.2, 0.8),
  drift_transform = c("none", "sigmoid", "bias-correct"),
  silent = T,
  optim_args = list()
)

Arguments

data

A data frame with columns val_imm and val_del for the values of the immediate and delayed rewards, del for the delays, imm_chosen (Boolean) for whether the immediate rewards were chosen, and rt for the reaction times (in seconds). Other columns can also be present but will be ignored.

discount_function

A string specifying the name of the discount functions to use, or an object of class td_fn (used for creating custom discount functions), or a list of objects of class td_fn.

v_par_starts

A vector of starting values to try for the "v" parameter (drift rate multiplier) during optimization.

beta_par_starts

A vector of starting values to try for the "beta" parameter (bias) during optimization.

alpha_par_starts

A vector of starting values to try for the "alpha" parameter (boundary separation) during optimization.

tau_par_starts

A vector of starting values to try for the "tau" parameter (non-decision time) during optimization.

drift_transform

A transform to apply to drift rates. Either "none" (no transform), "sigmoid" (sigmoidal transform described by Peters & D'Esposito, 2020, doi:10.1371/journal.pcbi.1007615 , and Fontanesi et al., 2019, doi:10.3758/s13423-018-1554-2 ), or "bias-correct" (experimental; see note below).

silent

Boolean (true by default). The call to optim() occurs within a try() wrapper. The value of silent is passed along to try().

optim_args

Additional arguments to pass to optim(). Default is list(silent = T).

Value

An object of class td_bcnm with components data (containing the data used for fitting), config (containing the internal configuration of the model, including the discount_function), and optim (the output of optim()).

Note

Drift rates are computed based on the difference in subjective values between the immediate and delayed rewards. In theory, when they are equally valued, they should have equal probability of being chosen. However, this is only true when the bias parameter of the drift diffusion model (beta) is 0.5 (i.e., no bias). To make sure the immediate and delayed reward have equal probability of being chosen when they are equally valued, we can set drift_transform = "bias-correct" to add a bias correction factor to the drift rate. However, this feature is experimental and its effects on model fit etc. have not been tested.

See also

Other drift diffusion model functions: coef.td_ddm(), deviance.td_ddm(), fitted.td_ddm(), logLik.td_ddm(), predict.td_ddm()

Examples

if (FALSE) { # \dontrun{
data("td_bc_single_ptpt")
mod <- td_ddm(td_bc_single_ptpt, discount_function = "hyperbolic")
} # }