Movatterモバイル変換


[0]ホーム

URL:


Type:Package
Title:Fast Implementation of the Diffusion Decision Model
Version:1.0-2
Description:Provides the probability density function (PDF), cumulative distribution function (CDF), the first-order and second-order partial derivatives of the PDF, and a fitting function for the diffusion decision model (DDM; e.g., Ratcliff & McKoon, 2008, <doi:10.1162/neco.2008.12-06-420>) with across-trial variability in the drift rate. Because the PDF, its partial derivatives, and the CDF of the DDM both contain an infinite sum, they need to be approximated. 'fddm' implements all published approximations (Navarro & Fuss, 2009, <doi:10.1016/j.jmp.2009.02.003>; Gondan, Blurton, & Kesselmeier, 2014, <doi:10.1016/j.jmp.2014.05.002>; Blurton, Kesselmeier, & Gondan, 2017, <doi:10.1016/j.jmp.2016.11.003>; Hartmann & Klauer, 2021, <doi:10.1016/j.jmp.2021.102550>) plus new approximations. All approximations are implemented purely in 'C++' providing faster speed than existing packages.
License:GPL-2 |GPL-3 [expanded from: GPL (≥ 2)]
Imports:Rcpp (≥ 1.0.1), stats, methods, Formula
LinkingTo:Rcpp, RcppEigen
Depends:R (≥ 3.5.0)
Suggests:rtdists, RWiener, ggplot2, reshape2, testthat, knitr,rmarkdown, microbenchmark, ggnewscale, ggforce, WienR, emmeans,estimability, lmtest, numDeriv
URL:https://github.com/rtdists/fddm
BugReports:https://github.com/rtdists/fddm/issues
RoxygenNote:7.3.1
Encoding:UTF-8
VignetteBuilder:knitr
NeedsCompilation:yes
Packaged:2024-07-01 13:22:08 UTC; kendal
Author:Kendal B. Foster [aut], Henrik SingmannORCID iD [ctb, cre], Achim Zeileis [ctb] (methods partially taken from betareg)
Maintainer:Henrik Singmann <singmann@gmail.com>
Repository:CRAN
Date/Publication:2024-07-02 16:00:07 UTC

Second-Order Partial Derivative of 5-parameter DDM PDF with respect to a(threshold separation)

Description

Second-Order Partial Derivative of the density function for the 5-parametervariant of the Ratcliff diffusion decision model (DDM) with respect to a,the threshold separation. This variant contains the following parameters:v (drift rate),a (threshold separation),t0 (non-decision time/response time constant),w(relative starting point),sv (inter-trial variability of drift),andsigma (diffusion coefficient of underlying Wiener process).

Usage

da2_dfddm(  rt,  response,  v,  a,  t0,  w = 0.5,  sv = 0,  sigma = 1,  sl_thresh = 0.5,  err_tol = 1e-06)

Arguments

rt

A vector of response times (in seconds). If a response time isnon-positve, then its density will evaluate to0 if log = FALSE and-∞ if log = TRUE.

response

Binary response(s) that correspond(s) to either the "lower"or "upper" threshold. This model parameter can either be a singular valueor a vector. The value(s) in 'response' can be of the following datatypes:

  • integers or doubles (1→ "lower",2→ "upper");

  • factors (the first level gets mapped to "lower", and the secondlevel gets mapped to "upper"; any additional levels are ignored).

  • strings (only the first character is checked, "L"→ "lower" or "U"→ "upper", case insensitive);

  • logicals (FALSE → "lower",TRUE → "upper");

v

Drift rate. Average slope of the information accumulation process.The drift gives information about the speed and direction of theaccumulation of information. Large (absolute) values of drift indicate agood performance. If received information supports the response linked tothe upper threshold, then the sign will be positive; similarly a negativevalue indicates that the received information supports the response linkedto the lower threshold. Allowed range:v is a real number. Typicalrange:-5 <v< 5.

a

Threshold separation. Amount of information that is considered fora decision. Large values indicate a conservative decisional style. Allowedrange:0 <a. Typical range:0.5 <a< 2.

t0

Non-decision time or response time constant (in seconds). Lowerbound for the duration of all non-decisional processes (encoding andresponse execution). If this value is greater thanrt, then theresulting density is returned as ifrt \le 0. Allowed range:0 \let0. Typical range:0.1 <t0< 0.5.

w

Relative starting point. Indicator of an a priori bias in decisionmaking. When the relative starting pointw deviates from0.5,the amount of information necessary for a decision differs betweenresponse alternatives. Allowed range:0 <w< 1.Default value is0.5 (i.e., no bias).

sv

Inter-trial-variability of drift rate. Standard deviation of anormal distribution with meanv describing the distribution ofactual drift rates from specific trials. Values different from0 canpredict slow errors. Allowed range:0 \lesv. Typical range:0 <sv< 2. Default value is0, which indicatesno drift in the function call. See Details for more information.

sigma

Diffusion coefficient of the underlying Wiener process. Allowedrange:0 <sigma. Default value is1. This parametersimply scales the parametersv,a, andsv as follows.See Details for more information.

  • aa/sigma

  • vv/sigma

  • svsv/sigma

.

sl_thresh

Threshold for deciding when to use the "small-time" variantor the "large-time" variant. If the "effective response time" is greaterthansl_thresh (i.e.,\frac{rt}{a^2} >sl_thresh),then the "large-time" variant is used; otherwise, the "small-time" variantis used. Allowed values are any real number; however any non-positivenumber means that the "large-time" variant will always be used. Similarly,any very large positive number (e.g., +Inf) means that the "small-time"variant will always be used. Default value is0.5.

err_tol

Allowed error tolerance of the overall calculation. Since thepartial derivative of the density function contains the sum of twoinfinite sums, each approximation of these two infinite sums will have anindividual error tolerance oferr_tol / 2; thus the total overallerror of the calculation will be at mosterr_tol. If the providederror tolerance is less than1e-300, it is set to1e-300.Default is1e-6.

Details

All of the model inputs and parameters (rt,response,v,a,t0,w,sv,sigma) can beinput as a single value or as a vector of values. If input as a vector ofvalues, then the standardR input wrapping will occur.

sv - Both the "small-time" and "large-time" variants of the densityfunction have two further variants: one with a constant drift ratev(i.e.,sv= 0), and one with a variable drift ratev(i.e.,sv> 0). The details of the differences between thesetwo density functions can be found in our associated paper. To use thedensity function with a constant drift rate, leave the parametersvto its default value ofsv = 0, as this will indicate no drift to thefunction. To use the density function with a variable drift rate, set theparametersv to some non-negative value, i.e.,sv> 0.

sigma - The default value of this parameter is1 because itonly scales the parametersv,a, andsv, as shownabove. However, other formulations of the DDM may setsigma = 0.1(see Ratcliff (1978), the fourth reference), so care must be taken whencomparing the results of different formulations.

Value

A vector containing the second-order partial derivatives of theDDM PDF with precisionerr_tol whose length matches that of thelongest input parameter (usuallyrt).

References

Navarro, D. J., & Fuss, I. G. (2009). Fast and accuratecalculations for first-passage times in Wiener diffusion models. Journalof Mathematical Psychology, 53(4), 222-230.

Gondan, M., Blurton, S. P., & Kesselmeier, M. (2014). Even faster and evenmore accurate first-passage time densities and distributions for theWiener diffusion model. Journal of Mathematical Psychology, 60, 20-22.

Blurton, S. P., Kesselmeier, M., & Gondan, M. (2017). The first-passagetime distribution for the diffusion model with variable drift. Journal ofMathematical Psychology, 76, 7-12.

Hartmann, R., Klauer, K. C. (2021). Partial derivatives for thefirst-passage time distribution in Wiener diffusion models. Journal ofMathematical Psychology, 103, 102550.

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

Examples

# derivative with respect to rt (response time)dt_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to t0 (non-decision time)dt0_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,          sv = 0.4, err_tol = 1e-6)# derivative with respect to a (threshold separation)da_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to v (drift rate)dv_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to w (relative starting point)dw_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to sv (inter-trial variability in the drift rate)dsv_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,          sv = 0.4, err_tol = 1e-6)#-------- Log Versions --------## # derivative with respect to rt (response time)# dt_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to t0 (non-decision time)# dt0_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#               sv = 0.4, err_tol = 1e-6)# # derivative with respect to a (threshold separation)# da_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to v (drift rate)# dv_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to w (relative starting point)# dw_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to sv (inter-trial variability in the drift rate)# dsv_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#               sv = 0.4, err_tol = 1e-6)

Partial Derivative of 5-parameter DDM PDF with respect to a (thresholdseparation)

Description

Partial Derivative of the density function for the 5-parameter variant ofthe Ratcliff diffusion decision model (DDM) with respect to a, thethreshold separation. This variant contains the following parameters:v (drift rate),a (threshold separation),t0 (non-decision time/response time constant),w(relative starting point),sv (inter-trial variability of drift),andsigma (diffusion coefficient of underlying Wiener process).

Usage

da_dfddm(  rt,  response,  v,  a,  t0,  w = 0.5,  sv = 0,  sigma = 1,  sl_thresh = 0.5,  err_tol = 1e-06)

Arguments

rt

A vector of response times (in seconds). If a response time isnon-positve, then its density will evaluate to0 if log = FALSE and-∞ if log = TRUE.

response

Binary response(s) that correspond(s) to either the "lower"or "upper" threshold. This model parameter can either be a singular valueor a vector. The value(s) in 'response' can be of the following datatypes:

  • integers or doubles (1→ "lower",2→ "upper");

  • factors (the first level gets mapped to "lower", and the secondlevel gets mapped to "upper"; any additional levels are ignored).

  • strings (only the first character is checked, "L"→ "lower" or "U"→ "upper", case insensitive);

  • logicals (FALSE → "lower",TRUE → "upper");

v

Drift rate. Average slope of the information accumulation process.The drift gives information about the speed and direction of theaccumulation of information. Large (absolute) values of drift indicate agood performance. If received information supports the response linked tothe upper threshold, then the sign will be positive; similarly a negativevalue indicates that the received information supports the response linkedto the lower threshold. Allowed range:v is a real number. Typicalrange:-5 <v< 5.

a

Threshold separation. Amount of information that is considered fora decision. Large values indicate a conservative decisional style. Allowedrange:0 <a. Typical range:0.5 <a< 2.

t0

Non-decision time or response time constant (in seconds). Lowerbound for the duration of all non-decisional processes (encoding andresponse execution). If this value is greater thanrt, then theresulting density is returned as ifrt \le 0. Allowed range:0 \let0. Typical range:0.1 <t0< 0.5.

w

Relative starting point. Indicator of an a priori bias in decisionmaking. When the relative starting pointw deviates from0.5,the amount of information necessary for a decision differs betweenresponse alternatives. Allowed range:0 <w< 1.Default value is0.5 (i.e., no bias).

sv

Inter-trial-variability of drift rate. Standard deviation of anormal distribution with meanv describing the distribution ofactual drift rates from specific trials. Values different from0 canpredict slow errors. Allowed range:0 \lesv. Typical range:0 <sv< 2. Default value is0, which indicatesno drift in the function call. See Details for more information.

sigma

Diffusion coefficient of the underlying Wiener process. Allowedrange:0 <sigma. Default value is1. This parametersimply scales the parametersv,a, andsv as follows.See Details for more information.

  • aa/sigma

  • vv/sigma

  • svsv/sigma

.

sl_thresh

Threshold for deciding when to use the "small-time" variantor the "large-time" variant. If the "effective response time" is greaterthansl_thresh (i.e.,\frac{rt}{a^2} >sl_thresh),then the "large-time" variant is used; otherwise, the "small-time" variantis used. Allowed values are any real number; however any non-positivenumber means that the "large-time" variant will always be used. Similarly,any very large positive number (e.g., +Inf) means that the "small-time"variant will always be used. Default value is0.5.

err_tol

Allowed error tolerance of the overall calculation. Since thepartial derivative of the density function contains the sum of twoinfinite sums, each approximation of these two infinite sums will have anindividual error tolerance oferr_tol / 2; thus the total overallerror of the calculation will be at mosterr_tol. If the providederror tolerance is less than1e-300, it is set to1e-300.Default is1e-6.

Details

All of the model inputs and parameters (rt,response,v,a,t0,w,sv,sigma) can beinput as a single value or as a vector of values. If input as a vector ofvalues, then the standardR input wrapping will occur.

sv - Both the "small-time" and "large-time" variants of the densityfunction have two further variants: one with a constant drift ratev(i.e.,sv= 0), and one with a variable drift ratev(i.e.,sv> 0). The details of the differences between thesetwo density functions can be found in our associated paper. To use thedensity function with a constant drift rate, leave the parametersvto its default value ofsv = 0, as this will indicate no drift to thefunction. To use the density function with a variable drift rate, set theparametersv to some non-negative value, i.e.,sv> 0.

sigma - The default value of this parameter is1 because itonly scales the parametersv,a, andsv, as shownabove. However, other formulations of the DDM may setsigma = 0.1(see Ratcliff (1978), the fourth reference), so care must be taken whencomparing the results of different formulations.

Value

A vector containing the partial derivatives of the DDM PDF withprecisionerr_tol whose length matches that of the longest inputparameter (usuallyrt).

References

Navarro, D. J., & Fuss, I. G. (2009). Fast and accuratecalculations for first-passage times in Wiener diffusion models. Journalof Mathematical Psychology, 53(4), 222-230.

Gondan, M., Blurton, S. P., & Kesselmeier, M. (2014). Even faster and evenmore accurate first-passage time densities and distributions for theWiener diffusion model. Journal of Mathematical Psychology, 60, 20-22.

Blurton, S. P., Kesselmeier, M., & Gondan, M. (2017). The first-passagetime distribution for the diffusion model with variable drift. Journal ofMathematical Psychology, 76, 7-12.

Hartmann, R., Klauer, K. C. (2021). Partial derivatives for thefirst-passage time distribution in Wiener diffusion models. Journal ofMathematical Psychology, 103, 102550.

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

Examples

# derivative with respect to rt (response time)dt_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to t0 (non-decision time)dt0_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,          sv = 0.4, err_tol = 1e-6)# derivative with respect to a (threshold separation)da_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to v (drift rate)dv_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to w (relative starting point)dw_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to sv (inter-trial variability in the drift rate)dsv_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,          sv = 0.4, err_tol = 1e-6)#-------- Log Versions --------## # derivative with respect to rt (response time)# dt_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to t0 (non-decision time)# dt0_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#               sv = 0.4, err_tol = 1e-6)# # derivative with respect to a (threshold separation)# da_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to v (drift rate)# dv_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to w (relative starting point)# dw_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to sv (inter-trial variability in the drift rate)# dsv_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#               sv = 0.4, err_tol = 1e-6)

Estimation of 5-Parameter DDM

Description

Fit the 5-parameter DDM (Diffusion Decision Model) via maximum likelihoodestimation. The model for each DDM parameter can be specified symbolicallyusing R's formula interface. With the exception of the drift rate (which isalways estimated) all parameters can be either fixed or estimates.

Usage

ddm(  drift,  boundary = ~1,  ndt = ~1,  bias = 0.5,  sv = 0,  data,  optim = "nlminb",  args_optim = list(init = NULL, lo_bds = NULL, up_bds = NULL, control = list()),  args_ddm = list(err_tol = 1e-06),  use_gradient = TRUE,  compiled_model = TRUE,  model = TRUE,  mmatrix = TRUE,  response = TRUE,  na.action,  subset,  contrasts = NULL)

Arguments

drift

Two-sided formula. The left-hand side describes the response,the right-hand side provides a symbolic description of the regression modelunderlying the drift rate (v). The left-hand side needs to specify thecolumn in the data containing response time and corresponding binarydecision, concatenated by+ , e.g.,rt + response ~ ...

boundary,ndt,bias,sv

Either a one-sided formula providing a symbolicdescription of the regression model or a scalar number given the value thisparameter should be fixed to. Boundary separation (a), non-decision time(t0), relative initial bias (w), or inter-trial variability in the driftrate (sv)

data,na.action,subset

arguments controlling formula processing viamodel.frame.

optim

character string or fitting function indicating which numericaloptimization method should be used. The default"nlminb" uses thecorresponding function.

args_optim

named list of additional arguments for the optimizationfunction. The available options are:

  • init vector containing the initial values to be used in theoptimization for each coefficient. Note that the number and type ofcoefficients used (i.e., intercept or difference) is determined bythe model matrices, which are in turn determined by the formulasassigned to each DDM parameter (see the Details section for anoverview of formulas and coefficients). For an example, run theddm() function with parameter set to its default value, andview the initial value vector via the slot$optim_info$args_optim$init. By default for interceptcoefficients, the initial values for the drift rate (v), boundaryseparation (a), and non-decision time (t0) will be generated usingEZ-Diffusion (Wagenmakers et al. 2007); bias (w) is initialized to0.5; inter-trial variability in the drift rate (sv) isinitialized to0.0. Difference coefficients are initializedto0.0.

  • lo_bds vector containing the lower bounds to be used in theoptimization for each coefficient. The same consideration ofcoefficient types occurs here as it does withinit. Thedefaults for intercept coefficients are: drift ratev > -Inf, boundary separationa > 0, non-decisiontimet0 > 0, biasw > 0, inter-trial variability inthe drift ratesv \le 0. All difference coefficientshave a lower bound of-Inf.

  • up_bds vector containing the upper bounds to be used in theoptimization for each coefficient. The same consideration ofcoefficient types occurs here as it does withinit. Thedefaults for intercept coefficients are: drift ratev < Inf, boundary separationa < Inf, non-decisiontimet0 < Inf, biasw < 1, inter-trial variability inthe drift ratesv < Inf. All difference coefficients have aupper bound ofInf.

  • control additional control arguments passed tocontrol argument of optimization function specified inoptim

args_ddm

named list of additional arguments passed to density functioncalculation. Currently, the only option for this iserr_tol, thedesired error tolerance used in the density function calculation.

use_gradient

logical. Should gradient be used during numericaloptimization? Default isTRUE.

compiled_model,model,mmatrix,response

logicals. IfTRUE thecorresponding components of the fit (the compiled model object, the modelframe, the model matrix, the response matrix) are returned.

contrasts

optional list. See the contrasts.arg ofmodel.matrix.default

Details

ddm usesmodel.matrix for transforming thesymbolic description of the regression model underlying each parameter intoestimated coefficients. The following provides a few examples:

To get meaningful results it is necessary to estimate separate drift ratesfor the different condition/item-types that are mapped onto the upper andlower boundary of the diffusion model.

If a non-default fitting function is used, it needs to minimize thenegative log-likelihood, accept the following arguments,init, objective, gradient, lower, upper, control , and return a listwith the following argumentscoefficients, loglik, converged, optim(whereconverged is boolean andoptim can be an arbitrarylist with additional information).

Value

Object of classddm (i.e., a list with components as listedbelow) for which a number of common methods such asprint,coef, andlogLik are implemented, seeddm-methods.

The C++ object accessible via thecompiled_model component of theabove R object of classddm contains the following components:

Examples

# prepare datadata(med_dec, package = "fddm")med_dec <- med_dec[which(med_dec[["rt"]] >= 0), ] ## only use valid RTs## select data from one participantp1 <- med_dec[med_dec[["id"]] == 2 & med_dec[["group"]] == "experienced", ]head(p1)##----------------------------------------------##        Easiest: Fitting using emmeans       -##----------------------------------------------## Because we use an ANOVA approach, we set orthogonal sum-to-zero contrastsop <- options(contrasts = c('contr.sum', 'contr.poly'))fit0 <- ddm(rt + response ~ classification*difficulty, data = p1)summary(fit0)## for more tests, we use emmeans:if (requireNamespace("emmeans")) {# for ANOVA table:emmeans::joint_tests(fit0)# get conditional main effects of difficulty (for each level of classification):emmeans::joint_tests(fit0, by = "classification")# get mean drift rates per condition:em1 <- emmeans::emmeans(fit0, "difficulty", by = "classification")em1# compare mean drift rates per conditionpairs(em1)update(pairs(em1), by = NULL, adjust = "holm")}options(op) # reset contrasts##----------------------------------------------------------------##              Fitting with custom parametrisation              -##----------------------------------------------------------------## one drift rate per classification by difficulty design cellfit1 <- ddm(rt + response ~ 0 + classification:difficulty, data = p1)summary(fit1)## set default contrasts (just in case contrasts have been changed)op <- options(contrasts = c('contr.treatment', 'contr.poly'))## one drift rate "intercept" per classification condition (blast vs. non-blast)## corresponding to first level of difficulty factor (easy)## plus one further coefficient per classification condition corresponding to## difference from "intercept" (hard - easy)fit1b <- ddm(rt + response ~ 0 + classification + classification:difficulty,             data = p1, args_optim = list(control = list(iter.max = 1000,                                                         eval.max = 1000)))summary(fit1b)options(op) # reset contrasts## set orthogonal sum-to-zero contrastsop <- options(contrasts = c('contr.sum', 'contr.poly'))## one drift rate "intercept" per classification condition (blast vs. non-blast)## corresponding to mean drift rate for the classification condition## plus one further coefficient per classification condition corresponding to## difference from "intercept" (hard/easy - mean drift rate)fit1c <- ddm(rt + response ~ 0 + classification + classification:difficulty,             data = p1)summary(fit1c)options(op) ## reset contrasts## all variants produce same fit, only meaning of parameters differslogLik(fit1)logLik(fit1b)logLik(fit1c)logLik(fit0) ## also model above## all models estimate same drift rates, but in different parametrisation:coef(fit1)  ## drift rates per design cell## same drift rates based on fit1b:c(coef(fit1b)[1:2],  coef(fit1b)[1] + coef(fit1b)[3], coef(fit1b)[2] + coef(fit1b)[4])## same drift rates based on fit1c:c(coef(fit1c)[1] + coef(fit1c)[3], coef(fit1c)[2] + coef(fit1c)[4],  coef(fit1c)[1] - coef(fit1c)[3], coef(fit1c)[2] - coef(fit1c)[4])# we can estimate a model that freely estimates response bias# (instead of fixing it at 0.5)fit2 <- ddm(rt + response ~ 0 + classification:difficulty, bias = ~1, data = p1)summary(fit2)## Note: estimating bias only makes sense in situations like here where the## response boundaries do not correspond to correct/incorrect but to the## actual responses participants gave (here: blast vs. non-blast classification)## now let's perform a likelihood ratio test to check if estimating response## bias freely leads to a significant increase in model fit?if (requireNamespace("lmtest")) { ## requires package lmtest  lmtest::lrtest(fit1, fit2)  ## does not look like it (p = 0.1691)}# we can also make a DDM parameter, such as boundary, depend on a numeric# variable, such as block numberfit3 <- ddm(rt + response ~ 0 + classification:difficulty,            boundary = ~ block, data = p1)summary(fit3)## does making boundary depend on block leads to a significant increase in model## fit?if (requireNamespace("lmtest")) { ## requires package lmtest  lmtest::lrtest(fit1, fit3)  ## does not look like it (p = 0.198)}##----------------------------------------------------------------##              Fitting with optimization arguments              -##----------------------------------------------------------------## example of how to use your own initial values and bounds for the optimization## of the coefficients (determined by the model matrices/formulas)options(op) # reset contrasts# this uses the default generated initial values and boundsfitex0 <- ddm(rt + response ~ 0 + classification:difficulty, data = p1)# we can see the number of coefficients (and thus the number of initial values# and bounds) required if we wish to use our ownfitex0$optim_info$args_optim$initfitex0$optim_info$args_optim$lo_bdsfitex0$optim_info$args_optim$up_bds# -1.9270279  2.5408864 -1.9270279  0.3181987  1.7907438  0.1264035# -Inf        -Inf      -Inf        -Inf       0          0# Inf         Inf       Inf         Inf        Inf        0.461# the first four coefficients are for the drift rate (given by the formula we# provided), and the last two are for the boundary separation and non-decision# time, respectively (note that the default is to estimate these two model# parameters with a single coefficient).# to use our own initial values, we can include them in the `args_optim` list,# but note that they must be within the generated boundsfitex1 <- ddm(rt + response ~ 0 + classification:difficulty, data = p1,              args_optim = list(init = c(-1.5, 1, -1, 1, 1.5, 0.3)))# to use our own bounds, we again can include them in the `args_optim` list,# but note that they must contain the generated initial valuesfitex2 <- ddm(rt + response ~ 0 + classification:difficulty, data = p1,              args_optim = list(lo_bds = c(-20, -20, -20, -20, 0, 0),                                up_bds = c(20, 20, 20, 20, 10, 0.5)))# to use both our own initial values and bounds, we include them in the# `args_optim` list, and the bounds must contain the initial valuesfitex3 <- ddm(rt + response ~ 0 + classification:difficulty, data = p1,              args_optim = list(init = c(-1.5, 1, -1, 1, 1.5, 0.3),                                lo_bds = c(-20, -20, -20, -20, 0, 0),                                up_bds = c(20, 20, 20, 20, 10, 0.5)))# the only other option in the `args_optim` list is the control parameters# directly used by the optimization function (e.g., the maximum number of# iterations); here we'll set the maximum number of iterations and function# evaluationsfitex4 <- ddm(rt + response ~ 0 + classification:difficulty, data = p1,              args_optim = list(control = list(iter.max = 1000,                                               eval.max = 1000)))

Methods for ddm objects

Description

Implemented S3 methods for objects of classddm as returned byfunctionddm().

Usage

## S3 method for class 'ddm'print(x, digits = max(3, getOption("digits") - 3), ...)## S3 method for class 'ddm'summary(object, ...)## S3 method for class 'summary.ddm'print(x, digits = max(3, getOption("digits") - 3), ...)## S3 method for class 'ddm'coef(object, dpar = c("drift", "boundary", "ndt", "bias", "sv", "full"), ...)## S3 method for class 'ddm'vcov(object, dpar = c("drift", "boundary", "ndt", "bias", "sv"), ...)## S3 method for class 'ddm'model.frame(formula, ...)## S3 method for class 'ddm'model.matrix(object, dpar = c("drift", "boundary", "ndt", "bias", "sv"), ...)## S3 method for class 'ddm'terms(x, dpar = c("drift", "boundary", "ndt", "bias", "sv"), ...)## S3 method for class 'ddm'logLik(object, ...)## S3 method for class 'ddm'update(object, ...)recover_data.ddm(object, data, ...)emm_basis.ddm(  object,  trms,  xlev,  grid,  dpar = c("drift", "boundary", "ndt", "bias", "sv"),  ...)

Arguments

digits

minimal number of significant digits, seeprint.default.

...

further arguments passed to or from other methods.

object,x

object of classddm

dpar

which distributional parameter or DDM parameter to focus on. Inaddition to the five DDM parametersc("drift", "boundary", "ndt", "bias", "sv"), some methods accept"full" which returns informationfor all estimated parameters.

formula

seemodel.frame

data,trms,xlev,grid

arguments needed foremmeans support.

Details

The methods should fail with an informative error if adistributional parameter is selected indpar that is fixed and notestimated.


Density of Ratcliff Diffusion Decision Model

Description

Density function for the Ratcliff diffusion decision model (DDM) withfollowing parameters:v (drift rate),a (thresholdseparation),t0 (non-decision time/response time constant),w(relative starting point),sv (inter-trial variability of drift), andsigma (diffusion coefficient of underlying Wiener process). If youare looking to fit the DDM, seeddm().

Usage

dfddm(  rt,  response,  v,  a,  t0,  w = 0.5,  sv = 0,  sigma = 1,  err_tol = 1e-06,  log = FALSE,  switch_mech = "eff_rt",  switch_thresh = 0.8,  n_terms_small = "SWSE",  summation_small = "2017")

Arguments

rt

A vector of response times (in seconds). If a response time isnon-positve, then its density will evaluate to0 if log = FALSE and-∞ if log = TRUE.

response

Binary response(s) that correspond(s) to either the "lower"or "upper" threshold. This model parameter can either be a singular valueor a vector. The value(s) in 'response' can be of the following datatypes:

  • integers or doubles (1→ "lower",2→ "upper");

  • factors (the first level gets mapped to "lower", and the secondlevel gets mapped to "upper"; any additional levels are ignored).

  • strings (only the first character is checked, "L"→ "lower" or "U"→ "upper", case insensitive);

  • logicals (FALSE → "lower",TRUE → "upper");

v

Drift rate. Average slope of the information accumulation process.The drift gives information about the speed and direction of theaccumulation of information. Large (absolute) values of drift indicate agood performance. If received information supports the response linked tothe upper threshold, then the sign will be positive; similarly a negativevalue indicates that the received information supports the response linkedto the lower threshold. Allowed range:v is a real number. Typicalrange:-5 <v< 5.

a

Threshold separation. Amount of information that is considered fora decision. Large values indicate a conservative decisional style. Allowedrange:0 <a. Typical range:0.5 <a< 2.

t0

Non-decision time or response time constant (in seconds). Lowerbound for the duration of all non-decisional processes (encoding andresponse execution). If this value is greater thanrt, then theresulting density is returned as ifrt \le 0. Allowed range:0 \let0. Typical range:0.1 <t0< 0.5.

w

Relative starting point. Indicator of an a priori bias in decisionmaking. When the relative starting pointw deviates from0.5,the amount of information necessary for a decision differs betweenresponse alternatives. Allowed range:0 <w< 1.Default value is0.5 (i.e., no bias).

sv

Inter-trial-variability of drift rate. Standard deviation of anormal distribution with meanv describing the distribution ofactual drift rates from specific trials. Values different from0 canpredict slow errors. Allowed range:0 \lesv. Typical range:0 <sv< 2. Default value is0, which indicatesno drift in the function call. See Details for more information.

sigma

Diffusion coefficient of the underlying Wiener process. Allowedrange:0 <sigma. Default value is1. This parametersimply scales the parametersa,v, andsv as follows.See Details for more information.

  • aa/sigma

  • vv/sigma

  • svsv/sigma

.

err_tol

Allowed error tolerance of the density function. The densityfunction contains an infinite sum that must be approximated; thisparameter is the upper bound of the total error incurred from thisapproximation (in absolute value). See Details for more information.Default is1e-6.

log

Logical; ifTRUE, probabilitiesp are given aslog(p). Default isFALSE, which gives the density on theprobability scale.

switch_mech

Which switching mechanism to use in the choice of the"large-time" or "small-time" density function. Can be one of{"eff_rt","terms_large","terms","small","large"}. Note that the large-time approximation is unstable forsmall effective response times ((rt-t0)/(a*a) < 0.009). See Details for moreinformation. Default is"eff_rt".

switch_thresh

Threshold for determining whether the effectiveresponse time ((rt-t0)/(a*a)) is "large" or "small". Thisparameter is only considered ifswitch_mech = "eff_rt" orswitch_mech = "terms_large".Ifswitch_mech = "eff_rt", an effective response time greater thanswitch_thresh is considered "large", and the "large-time" variantof the density function is used; otherwise, the "small-time" variant ofthe density function is used. The default is0.8.Ifswitch_mech = "terms_large", this parameter is treated asceiling(switch_thresh); the smallest integer that isnot less thanswitch_thresh. In this case, the default isceiling(0.8) = 1. See theswitch_mech section of Details formore information.Note that ifswitch_thresh \le 0, then the effective responsetime is always treated as "large"; contrarily, ifswitch_thresh =∞ then the effective responsetime is always treated as "small". However, it is better to simply setswitch_mech = "large" orswitch_mech = "small" to always usethe "large-time" or "small-time" variant, respectively.

n_terms_small

Which method to use for calculating the "small-time"approximation to the density function. Only applicable ifswitch_mech = "terms" orswitch_mech = "small"; all othervalues ofswitch_mech cause this parameter to be ignored. Ifswitch_mech = "small", the allowed values are"SWSE","Gondan", and"Navarro". The default value is"SWSE".Ifswitch_mech = "terms", the allowed values are"Gondan"and"Navarro". Note that if the user inputsswitch_mech = "terms", then the user must also explicitly inputeithern_terms_small = "Gondan" orn_terms_small = "Navarro". See Details for more information.

summation_small

Which style of summation to use for the small-timeapproximation to the infinite sum. Can be one of {"2017","2014"}. Only applicable ifswitch_mech is one of{"eff_rt","terms_large","terms","small"}.See Details for more information. Default is"2017".

Details

All of the model inputs and parameters (rt,response,v,a,t0,w,sv,sigma) can beinput as a single value or as a vector of values. If input as a vector ofvalues, then the standardR recycling rules apply to ensure allinputs are of the same length.

The default settings ofswitch_mech = "eff_rt",switch_thresh = "0.8",n_terms_small = "SWSE",summation_small = "2017" produce the fastest and most accurateresults, as shown in our associated paper.

sv - Both the "small-time" and "large-time" variants of the densityfunction have two further variants: one with a constant drift ratev(i.e.,sv= 0), and one with a variable drift ratev(i.e.,sv> 0). The details of the differences between thesetwo density functions can be found in our associated paper. To use thedensity function with a constant drift rate, leave the parametersvto its default value ofsv = 0, as this will indicate no drift to thefunction. To use the density function with a variable drift rate, set theparametersv to some non-negative value, i.e.,sv> 0.

sigma - The default value of this parameter is1 because itonly scales the parametersv,a, andsv, as shownabove. However, other formulations of the DDM may setsigma = 0.1(see Ratcliff (1978), the fourth reference), so care must be taken whencomparing the results of different formulations.

err_tol - The density function is composed of an infinite sum (thatmust be approximated) and a multiplicative term outside the infinite sum,m. The total error of the approximation is the error incurred fromtruncating the infinite sum multiplied bym. Thus, to ensure that thetotal error is bounded by the user-provided error tolerance,err_tol,the approximation to the infinite sum uses a modified error tolerance(err_tol / m). If the error tolerance is small andm islarge, the modified error tolerance can underflow to0. To protectagainst this, we check that the modified error tolerance is at least1e-300 (near the smallest value that is representable by a floatingpoint number with double precision). If the modified error tolerance issmaller than this threshold, then we silently change it to1e-300.This case should only be encountered if extreme values of error toleranceare used (i.e., on the scale of1e-300).

switch_mech - The density function for the DDM has traditionally beenwritten in two forms: a "large-time" variant, and a "small-time" variant(Navarro and Fuss, 2009). These two forms are moreefficient at calculating the density for large and small response times,respectively. The parameterswitch_mech determines howdfddmdecides which of these two variants is used.switch_mech = "small" usesonly the "small-time" variant, andswitch_mech = "large" uses onlythe "large-time" variant. The "large-time" variant is unstable for smalleffective response times ((rt-t0)/(a*a) < 0.009) and may produce inaccuratedensities; thus, we do not recommend using theswitch_mech = "large"option if the inputs may contain such small effective response times. Tocircumvent this accuracy issue and resolve the differing efficiencies of the"large-time" and "small-time" variants, there are three switching mechanismsthat can be used to determine which of the two variants is more efficient.First,switch_mech = "terms" is the traditional approach andpre-calculates the number of terms required for the "large-time" and"small-time" sums, and then uses whichever variant requires fewer terms.This is the mechanism used in the Navarro and Fuss (2009) and Gondan,Blurton, and Kesselmeier (2014) papers.Second,switch_mech = "terms_large" pre-calculates the number ofterms only for the "large-time" variant, and compares that to the constantvalue ofceil(switch_thresh) (default value ofceil(0.8) = 1) to determine if the "large-time" variant issufficiently efficient.Third,switch_mech = "eff_rt" determines whether a given effectiveresponse time ((rt-t0)/(a*a)) is considered "large" or "small" bycomparing it to the value of the parameterswitch_thresh (defaultvalue of0.8); it then uses the corresponding variant.Bothswitch_mech = "terms_large" andswitch_mech = "eff_rt"only use the SWSE "small-time" approximation in the case that the"small-time" variant is more efficient.switch_mech = "eff_rt" is themost efficient method to determine which variant of the density functionshould be used.

switch_thresh - This parameter determines what effective responsetimes (rt/(a*a)) are "large" and"small". Thepaper_analysis folder in thefddm GitHubrepository contains plots showing the relative efficiencies of a range ofvalues for theswitch_thresh parameter when used withswitch_mech = "eff_rt" and alsoswitch_mech = "terms_large".Note that this parameter changed name and purpose with the release offddm version 0.5-0.

n_terms_small - The "small-time" variant has three different methodsfor how to truncate the infinite sum in the density function. Thesedifferent methods are discussed extensively in our associated paper, but thekey distinction is thatn_terms_small = "SWSE" uses a new method oftruncating the infinite sum. Then_terms_small = "SWSE" method iscurrently recommended (when possible) because it is the fastest and moststable algorithm when used withswitch_mech = "eff_rt".

summation_small - The "large-time" variant of the density functiondoes not have any further variants, but the "small-time" variant has moreoptions with respect to evaluating the infinite sum. There are twoequivalent styles of summation,summation_small = "2017" andsummation_small = "2014", of which the"2017" versionevaluates slightly faster and thus earns our recommendation. These differentstyles of summation are discussed in our associated paper.

Value

A vector containing the densities of the DDM with precisionerr_tol whose length matches that of the longest input parameter(usuallyrt).

References

Navarro, D. J., & Fuss, I. G. (2009). Fast and accuratecalculations for first-passage times in Wiener diffusion models. Journalof Mathematical Psychology, 53(4), 222-230.

Gondan, M., Blurton, S. P., & Kesselmeier, M. (2014). Even faster and evenmore accurate first-passage time densities and distributions for theWiener diffusion model. Journal of Mathematical Psychology, 60, 20-22.

Blurton, S. P., Kesselmeier, M., & Gondan, M. (2017). The first-passagetime distribution for the diffusion model with variable drift. Journal ofMathematical Psychology, 76, 7-12.

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

See Also

ddm()

Examples

# minimal exampledfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3)# example with all function parameters set to default or a practical valuedfddm(rt = c(1.2, 0.9, 1.1, 1.4, 0.8, 1.3),      response = c("lower", "upper", "upper", "lower", "upper", "lower"),      a = 1, v = -1, t0 = 0.2, w = 0.5, sv = 0, sigma = 1,      err_tol = 1e-6, log = FALSE, switch_mech = "eff_rt", switch_thresh = 0.8,      n_terms_small = "SWSE", summation_small = "2017")# example of mismatched input lengthsdfddm(rt = c(1.2, 0.9, 1.1, 1.4, 0.8, 1.3),      response = c("lower", "upper", "upper", "lower", "upper", "lower"),      a = c(1, 3), v = c(-2, 2, 2, -2, 2, -2),      t0 = 0.3, w = c(0.4, 0.5, 0.6), sv = 0.9,      err_tol = 1e-10, log = FALSE, switch_mech = "large",      summation_small = "2017")# example with Wiener diffusion coefficient (sigma) not equal to 1dfddm(rt = c(1.2, 0.9, 1.1, 1.4, 0.8, 1.3),      response = c("lower", "upper", "upper", "lower", "upper", "lower"),      a = 1, v = -1, t0 = 0.3, w = 0.5, sv = 0, sigma = 0.1,      err_tol = 1e-10, log = TRUE, switch_mech = "terms_large",      switch_thresh = 1, summation_small = "2017")### examples of different response inputs# integerresp_int <- as.integer(c(1, 2, 2, 1, 2, 1))dfddm(rt = c(1.2, 0.9, 1.1, 1.4, 0.8, 1.3), response = resp_int,      a = 1, v = -2, t0 = 0.3, w = 0.5, sv = 0.1,      err_tol = 1e-10, log = FALSE, switch_mech = "eff_rt",      summation_small = "2017")# doubleresp_dbl <- as.double(c(1, 2, 2, 1, 2, 1))dfddm(rt = c(1.2, 0.9, 1.1, 1.4, 0.8, 1.3), response = resp_dbl,      a = 1, v = -2, t0 = 0.3, w = 0.5, sv = 0.1,      err_tol = 1e-10, log = FALSE, switch_mech = "eff_rt",      summation_small = "2017")# factor (first level is mapped to "lower")days <- c("Monday", "Friday", "Friday", "Monday", "Friday", "Monday")resp_fac <- factor(days, levels = c("Monday", "Friday"))dfddm(rt = c(1.2, 0.9, 1.1, 1.4, 0.8, 1.3), response = resp_fac,      a = 1, v = -2, t0 = 0.3, w = 0.5, sv = 0.1,      err_tol = 1e-10, log = FALSE, switch_mech = "eff_rt",      summation_small = "2017")# stringresp_str <- c("lower", "upper", "upper", "lower", "upper", "lower")dfddm(rt = c(1.2, 0.9, 1.1, 1.4, 0.8, 1.3), response = resp_str,      a = 1, v = -2, t0 = 0.3, w = 0.5, sv = 0.1,      err_tol = 1e-10, log = FALSE, switch_mech = "eff_rt",      summation_small = "2017")# logicalresp_log <- c(FALSE, TRUE, TRUE, FALSE, TRUE, FALSE)dfddm(rt = c(1.2, 0.9, 1.1, 1.4, 0.8, 1.3), response = resp_log,      a = 1, v = -2, t0 = 0.3, w = 0.5, sv = 0.1,      err_tol = 1e-10, log = FALSE, switch_mech = "eff_rt",      summation_small = "2017")

Second-Order Partial Derivative of 5-parameter DDM PDF with respect to sv(inter-trial variability in the drift rate)

Description

Second-Order Partial Derivative of the density function for the 5-parametervariant of the Ratcliff diffusion decision model (DDM) with respect to sv,the inter-trial variability in the drift rate. This variant contains thefollowing parameters:v (drift rate),a (threshold separation),t0 (non-decision time/response time constant),w(relative starting point),sv (inter-trial variability of drift),andsigma (diffusion coefficient of underlying Wiener process).

Usage

dsv2_dfddm(  rt,  response,  v,  a,  t0,  w = 0.5,  sv = 0,  sigma = 1,  sl_thresh = 0.355,  err_tol = 1e-06)

Arguments

rt

A vector of response times (in seconds). If a response time isnon-positve, then its density will evaluate to0 if log = FALSE and-∞ if log = TRUE.

response

Binary response(s) that correspond(s) to either the "lower"or "upper" threshold. This model parameter can either be a singular valueor a vector. The value(s) in 'response' can be of the following datatypes:

  • integers or doubles (1→ "lower",2→ "upper");

  • factors (the first level gets mapped to "lower", and the secondlevel gets mapped to "upper"; any additional levels are ignored).

  • strings (only the first character is checked, "L"→ "lower" or "U"→ "upper", case insensitive);

  • logicals (FALSE → "lower",TRUE → "upper");

v

Drift rate. Average slope of the information accumulation process.The drift gives information about the speed and direction of theaccumulation of information. Large (absolute) values of drift indicate agood performance. If received information supports the response linked tothe upper threshold, then the sign will be positive; similarly a negativevalue indicates that the received information supports the response linkedto the lower threshold. Allowed range:v is a real number. Typicalrange:-5 <v< 5.

a

Threshold separation. Amount of information that is considered fora decision. Large values indicate a conservative decisional style. Allowedrange:0 <a. Typical range:0.5 <a< 2.

t0

Non-decision time or response time constant (in seconds). Lowerbound for the duration of all non-decisional processes (encoding andresponse execution). If this value is greater thanrt, then theresulting density is returned as ifrt \le 0. Allowed range:0 \let0. Typical range:0.1 <t0< 0.5.

w

Relative starting point. Indicator of an a priori bias in decisionmaking. When the relative starting pointw deviates from0.5,the amount of information necessary for a decision differs betweenresponse alternatives. Allowed range:0 <w< 1.Default value is0.5 (i.e., no bias).

sv

Inter-trial-variability of drift rate. Standard deviation of anormal distribution with meanv describing the distribution ofactual drift rates from specific trials. Values different from0 canpredict slow errors. Allowed range:0 \lesv. Typical range:0 <sv< 2. Default value is0, which indicatesno drift in the function call. See Details for more information.

sigma

Diffusion coefficient of the underlying Wiener process. Allowedrange:0 <sigma. Default value is1. This parametersimply scales the parametersv,a, andsv as follows.See Details for more information.

  • aa/sigma

  • vv/sigma

  • svsv/sigma

.

sl_thresh

Threshold for deciding when to use the "small-time" variantor the "large-time" variant. If the "effective response time" is greaterthansl_thresh (i.e.,\frac{rt}{a^2} >sl_thresh),then the "large-time" variant is used; otherwise, the "small-time" variantis used. Allowed values are any real number; however any non-positivenumber means that the "large-time" variant will always be used. Similarly,any very large positive number (e.g., +Inf) means that the "small-time"variant will always be used. Default value is0.355.

err_tol

Allowed error tolerance of the overall calculation. Since thepartial derivative of the density function contains one infinite sum, thisparameter defines the precision of the approximation to that infinite sum.If the provided error tolerance is less than1e-300, it is set to1e-300. Default is1e-6.

Details

All of the model inputs and parameters (rt,response,v,a,t0,w,sv,sigma) can beinput as a single value or as a vector of values. If input as a vector ofvalues, then the standardR input wrapping will occur.

sv - Both the "small-time" and "large-time" variants of the densityfunction have two further variants: one with a constant drift ratev(i.e.,sv= 0), and one with a variable drift ratev(i.e.,sv> 0). The details of the differences between thesetwo density functions can be found in our associated paper. To use thedensity function with a constant drift rate, leave the parametersvto its default value ofsv = 0, as this will indicate no drift to thefunction. To use the density function with a variable drift rate, set theparametersv to some non-negative value, i.e.,sv> 0.

sigma - The default value of this parameter is1 because itonly scales the parametersv,a, andsv, as shownabove. However, other formulations of the DDM may setsigma = 0.1(see Ratcliff (1978), the fourth reference), so care must be taken whencomparing the results of different formulations.

Value

A vector containing the second-order partial derivatives of theDDM PDF with precisionerr_tol whose length matches that of thelongest input parameter (usuallyrt).

References

Navarro, D. J., & Fuss, I. G. (2009). Fast and accuratecalculations for first-passage times in Wiener diffusion models. Journalof Mathematical Psychology, 53(4), 222-230.

Gondan, M., Blurton, S. P., & Kesselmeier, M. (2014). Even faster and evenmore accurate first-passage time densities and distributions for theWiener diffusion model. Journal of Mathematical Psychology, 60, 20-22.

Blurton, S. P., Kesselmeier, M., & Gondan, M. (2017). The first-passagetime distribution for the diffusion model with variable drift. Journal ofMathematical Psychology, 76, 7-12.

Hartmann, R., Klauer, K. C. (2021). Partial derivatives for thefirst-passage time distribution in Wiener diffusion models. Journal ofMathematical Psychology, 103, 102550.

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

Examples

# derivative with respect to rt (response time)dt_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to t0 (non-decision time)dt0_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,          sv = 0.4, err_tol = 1e-6)# derivative with respect to a (threshold separation)da_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to v (drift rate)dv_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to w (relative starting point)dw_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to sv (inter-trial variability in the drift rate)dsv_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,          sv = 0.4, err_tol = 1e-6)#-------- Log Versions --------## # derivative with respect to rt (response time)# dt_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to t0 (non-decision time)# dt0_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#               sv = 0.4, err_tol = 1e-6)# # derivative with respect to a (threshold separation)# da_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to v (drift rate)# dv_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to w (relative starting point)# dw_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to sv (inter-trial variability in the drift rate)# dsv_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#               sv = 0.4, err_tol = 1e-6)

Partial Derivative of 5-parameter DDM PDF with respect to sv (inter-trialvariability in the drift rate)

Description

Partial Derivative of the density function for the 5-parameter variant ofthe Ratcliff diffusion decision model (DDM) with respect to w, theinter-trial variability in the drift rate. This variant contains thefollowing parameters:v (drift rate),a (threshold separation),t0 (non-decision time/response time constant),w(relative starting point),sv (inter-trial variability of drift),andsigma (diffusion coefficient of underlying Wiener process).

Usage

dsv_dfddm(  rt,  response,  v,  a,  t0,  w = 0.5,  sv = 0,  sigma = 1,  sl_thresh = 0.355,  err_tol = 1e-06)

Arguments

rt

A vector of response times (in seconds). If a response time isnon-positve, then its density will evaluate to0 if log = FALSE and-∞ if log = TRUE.

response

Binary response(s) that correspond(s) to either the "lower"or "upper" threshold. This model parameter can either be a singular valueor a vector. The value(s) in 'response' can be of the following datatypes:

  • integers or doubles (1→ "lower",2→ "upper");

  • factors (the first level gets mapped to "lower", and the secondlevel gets mapped to "upper"; any additional levels are ignored).

  • strings (only the first character is checked, "L"→ "lower" or "U"→ "upper", case insensitive);

  • logicals (FALSE → "lower",TRUE → "upper");

v

Drift rate. Average slope of the information accumulation process.The drift gives information about the speed and direction of theaccumulation of information. Large (absolute) values of drift indicate agood performance. If received information supports the response linked tothe upper threshold, then the sign will be positive; similarly a negativevalue indicates that the received information supports the response linkedto the lower threshold. Allowed range:v is a real number. Typicalrange:-5 <v< 5.

a

Threshold separation. Amount of information that is considered fora decision. Large values indicate a conservative decisional style. Allowedrange:0 <a. Typical range:0.5 <a< 2.

t0

Non-decision time or response time constant (in seconds). Lowerbound for the duration of all non-decisional processes (encoding andresponse execution). If this value is greater thanrt, then theresulting density is returned as ifrt \le 0. Allowed range:0 \let0. Typical range:0.1 <t0< 0.5.

w

Relative starting point. Indicator of an a priori bias in decisionmaking. When the relative starting pointw deviates from0.5,the amount of information necessary for a decision differs betweenresponse alternatives. Allowed range:0 <w< 1.Default value is0.5 (i.e., no bias).

sv

Inter-trial-variability of drift rate. Standard deviation of anormal distribution with meanv describing the distribution ofactual drift rates from specific trials. Values different from0 canpredict slow errors. Allowed range:0 \lesv. Typical range:0 <sv< 2. Default value is0, which indicatesno drift in the function call. See Details for more information.

sigma

Diffusion coefficient of the underlying Wiener process. Allowedrange:0 <sigma. Default value is1. This parametersimply scales the parametersv,a, andsv as follows.See Details for more information.

  • aa/sigma

  • vv/sigma

  • svsv/sigma

.

sl_thresh

Threshold for deciding when to use the "small-time" variantor the "large-time" variant. If the "effective response time" is greaterthansl_thresh (i.e.,\frac{rt}{a^2} >sl_thresh),then the "large-time" variant is used; otherwise, the "small-time" variantis used. Allowed values are any real number; however any non-positivenumber means that the "large-time" variant will always be used. Similarly,any very large positive number (e.g., +Inf) means that the "small-time"variant will always be used. Default value is0.355.

err_tol

Allowed error tolerance of the overall calculation. Since thepartial derivative of the density function contains one infinite sum, thisparameter defines the precision of the approximation to that infinite sum.If the provided error tolerance is less than1e-300, it is set to1e-300. Default is1e-6.

Details

All of the model inputs and parameters (rt,response,v,a,t0,w,sv,sigma) can beinput as a single value or as a vector of values. If input as a vector ofvalues, then the standardR input wrapping will occur.

sv - Both the "small-time" and "large-time" variants of the densityfunction have two further variants: one with a constant drift ratev(i.e.,sv= 0), and one with a variable drift ratev(i.e.,sv> 0). The details of the differences between thesetwo density functions can be found in our associated paper. To use thedensity function with a constant drift rate, leave the parametersvto its default value ofsv = 0, as this will indicate no drift to thefunction. To use the density function with a variable drift rate, set theparametersv to some non-negative value, i.e.,sv> 0.

sigma - The default value of this parameter is1 because itonly scales the parametersv,a, andsv, as shownabove. However, other formulations of the DDM may setsigma = 0.1(see Ratcliff (1978), the fourth reference), so care must be taken whencomparing the results of different formulations.

Value

A vector containing the partial derivatives of the DDM PDF withprecisionerr_tol whose length matches that of the longest inputparameter (usuallyrt).

References

Navarro, D. J., & Fuss, I. G. (2009). Fast and accuratecalculations for first-passage times in Wiener diffusion models. Journalof Mathematical Psychology, 53(4), 222-230.

Gondan, M., Blurton, S. P., & Kesselmeier, M. (2014). Even faster and evenmore accurate first-passage time densities and distributions for theWiener diffusion model. Journal of Mathematical Psychology, 60, 20-22.

Blurton, S. P., Kesselmeier, M., & Gondan, M. (2017). The first-passagetime distribution for the diffusion model with variable drift. Journal ofMathematical Psychology, 76, 7-12.

Hartmann, R., Klauer, K. C. (2021). Partial derivatives for thefirst-passage time distribution in Wiener diffusion models. Journal ofMathematical Psychology, 103, 102550.

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

Examples

# derivative with respect to rt (response time)dt_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to t0 (non-decision time)dt0_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,          sv = 0.4, err_tol = 1e-6)# derivative with respect to a (threshold separation)da_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to v (drift rate)dv_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to w (relative starting point)dw_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to sv (inter-trial variability in the drift rate)dsv_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,          sv = 0.4, err_tol = 1e-6)#-------- Log Versions --------## # derivative with respect to rt (response time)# dt_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to t0 (non-decision time)# dt0_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#               sv = 0.4, err_tol = 1e-6)# # derivative with respect to a (threshold separation)# da_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to v (drift rate)# dv_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to w (relative starting point)# dw_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to sv (inter-trial variability in the drift rate)# dsv_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#               sv = 0.4, err_tol = 1e-6)

Second-Order Partial Derivative of 5-parameter DDM PDF with respect to t0(non-decision time)

Description

Second-Order Partial Derivative of the density function for the 5-parametervariant of the Ratcliff diffusion decision model (DDM) with respect to t0,the non-decision time. This variant contains the following parameters:v (drift rate),a (threshold separation),t0 (non-decision time/response time constant),w(relative starting point),sv (inter-trial variability of drift),andsigma (diffusion coefficient of underlying Wiener process).

Usage

dt02_dfddm(  rt,  response,  v,  a,  t0,  w = 0.5,  sv = 0,  sigma = 1,  sl_thresh = 0.44,  err_tol = 1e-06)

Arguments

rt

A vector of response times (in seconds). If a response time isnon-positve, then its density will evaluate to0 if log = FALSE and-∞ if log = TRUE.

response

Binary response(s) that correspond(s) to either the "lower"or "upper" threshold. This model parameter can either be a singular valueor a vector. The value(s) in 'response' can be of the following datatypes:

  • integers or doubles (1→ "lower",2→ "upper");

  • factors (the first level gets mapped to "lower", and the secondlevel gets mapped to "upper"; any additional levels are ignored).

  • strings (only the first character is checked, "L"→ "lower" or "U"→ "upper", case insensitive);

  • logicals (FALSE → "lower",TRUE → "upper");

v

Drift rate. Average slope of the information accumulation process.The drift gives information about the speed and direction of theaccumulation of information. Large (absolute) values of drift indicate agood performance. If received information supports the response linked tothe upper threshold, then the sign will be positive; similarly a negativevalue indicates that the received information supports the response linkedto the lower threshold. Allowed range:v is a real number. Typicalrange:-5 <v< 5.

a

Threshold separation. Amount of information that is considered fora decision. Large values indicate a conservative decisional style. Allowedrange:0 <a. Typical range:0.5 <a< 2.

t0

Non-decision time or response time constant (in seconds). Lowerbound for the duration of all non-decisional processes (encoding andresponse execution). If this value is greater thanrt, then theresulting density is returned as ifrt \le 0. Allowed range:0 \let0. Typical range:0.1 <t0< 0.5.

w

Relative starting point. Indicator of an a priori bias in decisionmaking. When the relative starting pointw deviates from0.5,the amount of information necessary for a decision differs betweenresponse alternatives. Allowed range:0 <w< 1.Default value is0.5 (i.e., no bias).

sv

Inter-trial-variability of drift rate. Standard deviation of anormal distribution with meanv describing the distribution ofactual drift rates from specific trials. Values different from0 canpredict slow errors. Allowed range:0 \lesv. Typical range:0 <sv< 2. Default value is0, which indicatesno drift in the function call. See Details for more information.

sigma

Diffusion coefficient of the underlying Wiener process. Allowedrange:0 <sigma. Default value is1. This parametersimply scales the parametersv,a, andsv as follows.See Details for more information.

  • aa/sigma

  • vv/sigma

  • svsv/sigma

.

sl_thresh

Threshold for deciding when to use the "small-time" variantor the "large-time" variant. If the "effective response time" is greaterthansl_thresh (i.e.,\frac{rt}{a^2} >sl_thresh),then the "large-time" variant is used; otherwise, the "small-time" variantis used. Allowed values are any real number; however any non-positivenumber means that the "large-time" variant will always be used. Similarly,any very large positive number (e.g., +Inf) means that the "small-time"variant will always be used. Default value is0.5.

err_tol

Allowed error tolerance of the overall calculation. Since thepartial derivative of the density function contains the sum of twoinfinite sums, each approximation of these two infinite sums will have anindividual error tolerance oferr_tol / 2; thus the total overallerror of the calculation will be at mosterr_tol. If the providederror tolerance is less than1e-300, it is set to1e-300.Default is1e-6.

Details

All of the model inputs and parameters (rt,response,v,a,t0,w,sv,sigma) can beinput as a single value or as a vector of values. If input as a vector ofvalues, then the standardR input wrapping will occur.

sv - Both the "small-time" and "large-time" variants of the densityfunction have two further variants: one with a constant drift ratev(i.e.,sv= 0), and one with a variable drift ratev(i.e.,sv> 0). The details of the differences between thesetwo density functions can be found in our associated paper. To use thedensity function with a constant drift rate, leave the parametersvto its default value ofsv = 0, as this will indicate no drift to thefunction. To use the density function with a variable drift rate, set theparametersv to some non-negative value, i.e.,sv> 0.

sigma - The default value of this parameter is1 because itonly scales the parametersv,a, andsv, as shownabove. However, other formulations of the DDM may setsigma = 0.1(see Ratcliff (1978), the fourth reference), so care must be taken whencomparing the results of different formulations.

Value

A vector containing the second-order partial derivatives of theDDM PDF with precisionerr_tol whose length matches that of thelongest input parameter (usuallyrt).

References

Navarro, D. J., & Fuss, I. G. (2009). Fast and accuratecalculations for first-passage times in Wiener diffusion models. Journalof Mathematical Psychology, 53(4), 222-230.

Gondan, M., Blurton, S. P., & Kesselmeier, M. (2014). Even faster and evenmore accurate first-passage time densities and distributions for theWiener diffusion model. Journal of Mathematical Psychology, 60, 20-22.

Blurton, S. P., Kesselmeier, M., & Gondan, M. (2017). The first-passagetime distribution for the diffusion model with variable drift. Journal ofMathematical Psychology, 76, 7-12.

Hartmann, R., Klauer, K. C. (2021). Partial derivatives for thefirst-passage time distribution in Wiener diffusion models. Journal ofMathematical Psychology, 103, 102550.

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

Examples

# derivative with respect to rt (response time)dt_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to t0 (non-decision time)dt0_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,          sv = 0.4, err_tol = 1e-6)# derivative with respect to a (threshold separation)da_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to v (drift rate)dv_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to w (relative starting point)dw_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to sv (inter-trial variability in the drift rate)dsv_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,          sv = 0.4, err_tol = 1e-6)#-------- Log Versions --------## # derivative with respect to rt (response time)# dt_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to t0 (non-decision time)# dt0_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#               sv = 0.4, err_tol = 1e-6)# # derivative with respect to a (threshold separation)# da_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to v (drift rate)# dv_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to w (relative starting point)# dw_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to sv (inter-trial variability in the drift rate)# dsv_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#               sv = 0.4, err_tol = 1e-6)

Partial Derivative of 5-parameter DDM PDF with respect to t0 (non-decisiontime)

Description

Partial Derivative of the density function for the 5-parameter variant ofthe Ratcliff diffusion decision model (DDM) with respect to t0, thenon-decision time. This variant contains the following parameters:v (drift rate),a (threshold separation),t0 (non-decision time/response time constant),w(relative starting point),sv (inter-trial variability of drift),andsigma (diffusion coefficient of underlying Wiener process).

Usage

dt0_dfddm(  rt,  response,  v,  a,  t0,  w = 0.5,  sv = 0,  sigma = 1,  sl_thresh = 0.5,  err_tol = 1e-06)

Arguments

rt

A vector of response times (in seconds). If a response time isnon-positve, then its density will evaluate to0 if log = FALSE and-∞ if log = TRUE.

response

Binary response(s) that correspond(s) to either the "lower"or "upper" threshold. This model parameter can either be a singular valueor a vector. The value(s) in 'response' can be of the following datatypes:

  • integers or doubles (1→ "lower",2→ "upper");

  • factors (the first level gets mapped to "lower", and the secondlevel gets mapped to "upper"; any additional levels are ignored).

  • strings (only the first character is checked, "L"→ "lower" or "U"→ "upper", case insensitive);

  • logicals (FALSE → "lower",TRUE → "upper");

v

Drift rate. Average slope of the information accumulation process.The drift gives information about the speed and direction of theaccumulation of information. Large (absolute) values of drift indicate agood performance. If received information supports the response linked tothe upper threshold, then the sign will be positive; similarly a negativevalue indicates that the received information supports the response linkedto the lower threshold. Allowed range:v is a real number. Typicalrange:-5 <v< 5.

a

Threshold separation. Amount of information that is considered fora decision. Large values indicate a conservative decisional style. Allowedrange:0 <a. Typical range:0.5 <a< 2.

t0

Non-decision time or response time constant (in seconds). Lowerbound for the duration of all non-decisional processes (encoding andresponse execution). If this value is greater thanrt, then theresulting density is returned as ifrt \le 0. Allowed range:0 \let0. Typical range:0.1 <t0< 0.5.

w

Relative starting point. Indicator of an a priori bias in decisionmaking. When the relative starting pointw deviates from0.5,the amount of information necessary for a decision differs betweenresponse alternatives. Allowed range:0 <w< 1.Default value is0.5 (i.e., no bias).

sv

Inter-trial-variability of drift rate. Standard deviation of anormal distribution with meanv describing the distribution ofactual drift rates from specific trials. Values different from0 canpredict slow errors. Allowed range:0 \lesv. Typical range:0 <sv< 2. Default value is0, which indicatesno drift in the function call. See Details for more information.

sigma

Diffusion coefficient of the underlying Wiener process. Allowedrange:0 <sigma. Default value is1. This parametersimply scales the parametersv,a, andsv as follows.See Details for more information.

  • aa/sigma

  • vv/sigma

  • svsv/sigma

.

sl_thresh

Threshold for deciding when to use the "small-time" variantor the "large-time" variant. If the "effective response time" is greaterthansl_thresh (i.e.,\frac{rt}{a^2} >sl_thresh),then the "large-time" variant is used; otherwise, the "small-time" variantis used. Allowed values are any real number; however any non-positivenumber means that the "large-time" variant will always be used. Similarly,any very large positive number (e.g., +Inf) means that the "small-time"variant will always be used. Default value is0.5.

err_tol

Allowed error tolerance of the overall calculation. Since thepartial derivative of the density function contains the sum of twoinfinite sums, each approximation of these two infinite sums will have anindividual error tolerance oferr_tol / 2; thus the total overallerror of the calculation will be at mosterr_tol. If the providederror tolerance is less than1e-300, it is set to1e-300.Default is1e-6.

Details

All of the model inputs and parameters (rt,response,v,a,t0,w,sv,sigma) can beinput as a single value or as a vector of values. If input as a vector ofvalues, then the standardR input wrapping will occur.

sv - Both the "small-time" and "large-time" variants of the densityfunction have two further variants: one with a constant drift ratev(i.e.,sv= 0), and one with a variable drift ratev(i.e.,sv> 0). The details of the differences between thesetwo density functions can be found in our associated paper. To use thedensity function with a constant drift rate, leave the parametersvto its default value ofsv = 0, as this will indicate no drift to thefunction. To use the density function with a variable drift rate, set theparametersv to some non-negative value, i.e.,sv> 0.

sigma - The default value of this parameter is1 because itonly scales the parametersv,a, andsv, as shownabove. However, other formulations of the DDM may setsigma = 0.1(see Ratcliff (1978), the fourth reference), so care must be taken whencomparing the results of different formulations.

Value

A vector containing the partial derivatives of the DDM PDF withprecisionerr_tol whose length matches that of the longest inputparameter (usuallyrt).

References

Navarro, D. J., & Fuss, I. G. (2009). Fast and accuratecalculations for first-passage times in Wiener diffusion models. Journalof Mathematical Psychology, 53(4), 222-230.

Gondan, M., Blurton, S. P., & Kesselmeier, M. (2014). Even faster and evenmore accurate first-passage time densities and distributions for theWiener diffusion model. Journal of Mathematical Psychology, 60, 20-22.

Blurton, S. P., Kesselmeier, M., & Gondan, M. (2017). The first-passagetime distribution for the diffusion model with variable drift. Journal ofMathematical Psychology, 76, 7-12.

Hartmann, R., Klauer, K. C. (2021). Partial derivatives for thefirst-passage time distribution in Wiener diffusion models. Journal ofMathematical Psychology, 103, 102550.

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

Examples

# derivative with respect to rt (response time)dt_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to t0 (non-decision time)dt0_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,          sv = 0.4, err_tol = 1e-6)# derivative with respect to a (threshold separation)da_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to v (drift rate)dv_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to w (relative starting point)dw_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to sv (inter-trial variability in the drift rate)dsv_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,          sv = 0.4, err_tol = 1e-6)#-------- Log Versions --------## # derivative with respect to rt (response time)# dt_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to t0 (non-decision time)# dt0_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#               sv = 0.4, err_tol = 1e-6)# # derivative with respect to a (threshold separation)# da_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to v (drift rate)# dv_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to w (relative starting point)# dw_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to sv (inter-trial variability in the drift rate)# dsv_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#               sv = 0.4, err_tol = 1e-6)

Second-Order Partial Derivative of 5-parameter DDM PDF with respect to t(response time)

Description

Second-Order Partial Derivative of the density function for the 5-parametervariant of the Ratcliff diffusion decision model (DDM) with respect to t,the response time. This variant contains the following parameters:v (drift rate),a (threshold separation),t0 (non-decision time/response time constant),w(relative starting point),sv (inter-trial variability of drift),andsigma (diffusion coefficient of underlying Wiener process).

Usage

dt2_dfddm(  rt,  response,  v,  a,  t0,  w = 0.5,  sv = 0,  sigma = 1,  sl_thresh = 0.5,  err_tol = 1e-06)

Arguments

rt

A vector of response times (in seconds). If a response time isnon-positve, then its density will evaluate to0 if log = FALSE and-∞ if log = TRUE.

response

Binary response(s) that correspond(s) to either the "lower"or "upper" threshold. This model parameter can either be a singular valueor a vector. The value(s) in 'response' can be of the following datatypes:

  • integers or doubles (1→ "lower",2→ "upper");

  • factors (the first level gets mapped to "lower", and the secondlevel gets mapped to "upper"; any additional levels are ignored).

  • strings (only the first character is checked, "L"→ "lower" or "U"→ "upper", case insensitive);

  • logicals (FALSE → "lower",TRUE → "upper");

v

Drift rate. Average slope of the information accumulation process.The drift gives information about the speed and direction of theaccumulation of information. Large (absolute) values of drift indicate agood performance. If received information supports the response linked tothe upper threshold, then the sign will be positive; similarly a negativevalue indicates that the received information supports the response linkedto the lower threshold. Allowed range:v is a real number. Typicalrange:-5 <v< 5.

a

Threshold separation. Amount of information that is considered fora decision. Large values indicate a conservative decisional style. Allowedrange:0 <a. Typical range:0.5 <a< 2.

t0

Non-decision time or response time constant (in seconds). Lowerbound for the duration of all non-decisional processes (encoding andresponse execution). If this value is greater thanrt, then theresulting density is returned as ifrt \le 0. Allowed range:0 \let0. Typical range:0.1 <t0< 0.5.

w

Relative starting point. Indicator of an a priori bias in decisionmaking. When the relative starting pointw deviates from0.5,the amount of information necessary for a decision differs betweenresponse alternatives. Allowed range:0 <w< 1.Default value is0.5 (i.e., no bias).

sv

Inter-trial-variability of drift rate. Standard deviation of anormal distribution with meanv describing the distribution ofactual drift rates from specific trials. Values different from0 canpredict slow errors. Allowed range:0 \lesv. Typical range:0 <sv< 2. Default value is0, which indicatesno drift in the function call. See Details for more information.

sigma

Diffusion coefficient of the underlying Wiener process. Allowedrange:0 <sigma. Default value is1. This parametersimply scales the parametersv,a, andsv as follows.See Details for more information.

  • aa/sigma

  • vv/sigma

  • svsv/sigma

.

sl_thresh

Threshold for deciding when to use the "small-time" variantor the "large-time" variant. If the "effective response time" is greaterthansl_thresh (i.e.,\frac{rt}{a^2} >sl_thresh),then the "large-time" variant is used; otherwise, the "small-time" variantis used. Allowed values are any real number; however any non-positivenumber means that the "large-time" variant will always be used. Similarly,any very large positive number (e.g., +Inf) means that the "small-time"variant will always be used. Default value is0.5.

err_tol

Allowed error tolerance of the overall calculation. Since thepartial derivative of the density function contains the sum of twoinfinite sums, each approximation of these two infinite sums will have anindividual error tolerance oferr_tol / 2; thus the total overallerror of the calculation will be at mosterr_tol. If the providederror tolerance is less than1e-300, it is set to1e-300.Default is1e-6.

Details

All of the model inputs and parameters (rt,response,v,a,t0,w,sv,sigma) can beinput as a single value or as a vector of values. If input as a vector ofvalues, then the standardR input wrapping will occur.

sv - Both the "small-time" and "large-time" variants of the densityfunction have two further variants: one with a constant drift ratev(i.e.,sv= 0), and one with a variable drift ratev(i.e.,sv> 0). The details of the differences between thesetwo density functions can be found in our associated paper. To use thedensity function with a constant drift rate, leave the parametersvto its default value ofsv = 0, as this will indicate no drift to thefunction. To use the density function with a variable drift rate, set theparametersv to some non-negative value, i.e.,sv> 0.

sigma - The default value of this parameter is1 because itonly scales the parametersv,a, andsv, as shownabove. However, other formulations of the DDM may setsigma = 0.1(see Ratcliff (1978), the fourth reference), so care must be taken whencomparing the results of different formulations.

Value

A vector containing the second-order partial derivatives of theDDM PDF with precisionerr_tol whose length matches that of thelongest input parameter (usuallyrt).

References

Navarro, D. J., & Fuss, I. G. (2009). Fast and accuratecalculations for first-passage times in Wiener diffusion models. Journalof Mathematical Psychology, 53(4), 222-230.

Gondan, M., Blurton, S. P., & Kesselmeier, M. (2014). Even faster and evenmore accurate first-passage time densities and distributions for theWiener diffusion model. Journal of Mathematical Psychology, 60, 20-22.

Blurton, S. P., Kesselmeier, M., & Gondan, M. (2017). The first-passagetime distribution for the diffusion model with variable drift. Journal ofMathematical Psychology, 76, 7-12.

Hartmann, R., Klauer, K. C. (2021). Partial derivatives for thefirst-passage time distribution in Wiener diffusion models. Journal ofMathematical Psychology, 103, 102550.

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

Examples

# derivative with respect to rt (response time)dt_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to t0 (non-decision time)dt0_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,          sv = 0.4, err_tol = 1e-6)# derivative with respect to a (threshold separation)da_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to v (drift rate)dv_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to w (relative starting point)dw_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to sv (inter-trial variability in the drift rate)dsv_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,          sv = 0.4, err_tol = 1e-6)#-------- Log Versions --------## # derivative with respect to rt (response time)# dt_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to t0 (non-decision time)# dt0_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#               sv = 0.4, err_tol = 1e-6)# # derivative with respect to a (threshold separation)# da_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to v (drift rate)# dv_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to w (relative starting point)# dw_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to sv (inter-trial variability in the drift rate)# dsv_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#               sv = 0.4, err_tol = 1e-6)

Partial Derivative of 5-parameter DDM PDF with respect to t (response time)

Description

Partial Derivative of the density function for the 5-parameter variant ofthe Ratcliff diffusion decision model (DDM) with respect to t, theresponse time. This variant contains the following parameters:v (drift rate),a (threshold separation),t0 (non-decision time/response time constant),w(relative starting point),sv (inter-trial variability of drift),andsigma (diffusion coefficient of underlying Wiener process).

Usage

dt_dfddm(  rt,  response,  v,  a,  t0,  w = 0.5,  sv = 0,  sigma = 1,  sl_thresh = 0.5,  err_tol = 1e-06)

Arguments

rt

A vector of response times (in seconds). If a response time isnon-positve, then its density will evaluate to0 if log = FALSE and-∞ if log = TRUE.

response

Binary response(s) that correspond(s) to either the "lower"or "upper" threshold. This model parameter can either be a singular valueor a vector. The value(s) in 'response' can be of the following datatypes:

  • integers or doubles (1→ "lower",2→ "upper");

  • factors (the first level gets mapped to "lower", and the secondlevel gets mapped to "upper"; any additional levels are ignored).

  • strings (only the first character is checked, "L"→ "lower" or "U"→ "upper", case insensitive);

  • logicals (FALSE → "lower",TRUE → "upper");

v

Drift rate. Average slope of the information accumulation process.The drift gives information about the speed and direction of theaccumulation of information. Large (absolute) values of drift indicate agood performance. If received information supports the response linked tothe upper threshold, then the sign will be positive; similarly a negativevalue indicates that the received information supports the response linkedto the lower threshold. Allowed range:v is a real number. Typicalrange:-5 <v< 5.

a

Threshold separation. Amount of information that is considered fora decision. Large values indicate a conservative decisional style. Allowedrange:0 <a. Typical range:0.5 <a< 2.

t0

Non-decision time or response time constant (in seconds). Lowerbound for the duration of all non-decisional processes (encoding andresponse execution). If this value is greater thanrt, then theresulting density is returned as ifrt \le 0. Allowed range:0 \let0. Typical range:0.1 <t0< 0.5.

w

Relative starting point. Indicator of an a priori bias in decisionmaking. When the relative starting pointw deviates from0.5,the amount of information necessary for a decision differs betweenresponse alternatives. Allowed range:0 <w< 1.Default value is0.5 (i.e., no bias).

sv

Inter-trial-variability of drift rate. Standard deviation of anormal distribution with meanv describing the distribution ofactual drift rates from specific trials. Values different from0 canpredict slow errors. Allowed range:0 \lesv. Typical range:0 <sv< 2. Default value is0, which indicatesno drift in the function call. See Details for more information.

sigma

Diffusion coefficient of the underlying Wiener process. Allowedrange:0 <sigma. Default value is1. This parametersimply scales the parametersv,a, andsv as follows.See Details for more information.

  • aa/sigma

  • vv/sigma

  • svsv/sigma

.

sl_thresh

Threshold for deciding when to use the "small-time" variantor the "large-time" variant. If the "effective response time" is greaterthansl_thresh (i.e.,\frac{rt}{a^2} >sl_thresh),then the "large-time" variant is used; otherwise, the "small-time" variantis used. Allowed values are any real number; however any non-positivenumber means that the "large-time" variant will always be used. Similarly,any very large positive number (e.g., +Inf) means that the "small-time"variant will always be used. Default value is0.5.

err_tol

Allowed error tolerance of the overall calculation. Since thepartial derivative of the density function contains the sum of twoinfinite sums, each approximation of these two infinite sums will have anindividual error tolerance oferr_tol / 2; thus the total overallerror of the calculation will be at mosterr_tol. If the providederror tolerance is less than1e-300, it is set to1e-300.Default is1e-6.

Details

All of the model inputs and parameters (rt,response,v,a,t0,w,sv,sigma) can beinput as a single value or as a vector of values. If input as a vector ofvalues, then the standardR input wrapping will occur.

sv - Both the "small-time" and "large-time" variants of the densityfunction have two further variants: one with a constant drift ratev(i.e.,sv= 0), and one with a variable drift ratev(i.e.,sv> 0). The details of the differences between thesetwo density functions can be found in our associated paper. To use thedensity function with a constant drift rate, leave the parametersvto its default value ofsv = 0, as this will indicate no drift to thefunction. To use the density function with a variable drift rate, set theparametersv to some non-negative value, i.e.,sv> 0.

sigma - The default value of this parameter is1 because itonly scales the parametersv,a, andsv, as shownabove. However, other formulations of the DDM may setsigma = 0.1(see Ratcliff (1978), the fourth reference), so care must be taken whencomparing the results of different formulations.

Value

A vector containing the partial derivatives of the DDM PDF withprecisionerr_tol whose length matches that of the longest inputparameter (usuallyrt).

References

Navarro, D. J., & Fuss, I. G. (2009). Fast and accuratecalculations for first-passage times in Wiener diffusion models. Journalof Mathematical Psychology, 53(4), 222-230.

Gondan, M., Blurton, S. P., & Kesselmeier, M. (2014). Even faster and evenmore accurate first-passage time densities and distributions for theWiener diffusion model. Journal of Mathematical Psychology, 60, 20-22.

Blurton, S. P., Kesselmeier, M., & Gondan, M. (2017). The first-passagetime distribution for the diffusion model with variable drift. Journal ofMathematical Psychology, 76, 7-12.

Hartmann, R., Klauer, K. C. (2021). Partial derivatives for thefirst-passage time distribution in Wiener diffusion models. Journal ofMathematical Psychology, 103, 102550.

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

Examples

# derivative with respect to rt (response time)dt_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to t0 (non-decision time)dt0_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,          sv = 0.4, err_tol = 1e-6)# derivative with respect to a (threshold separation)da_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to v (drift rate)dv_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to w (relative starting point)dw_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to sv (inter-trial variability in the drift rate)dsv_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,          sv = 0.4, err_tol = 1e-6)#-------- Log Versions --------## # derivative with respect to rt (response time)# dt_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to t0 (non-decision time)# dt0_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#               sv = 0.4, err_tol = 1e-6)# # derivative with respect to a (threshold separation)# da_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to v (drift rate)# dv_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to w (relative starting point)# dw_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to sv (inter-trial variability in the drift rate)# dsv_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#               sv = 0.4, err_tol = 1e-6)

Second-Order Partial Derivative of 5-parameter DDM PDF with respect to v(drift rate)

Description

Second-Order Partial Derivative of the density function for the 5-parametervariant of the Ratcliff diffusion decision model (DDM) with respect to v,the drift rate. This variant contains the following parameters:v (drift rate),a (threshold separation),t0 (non-decision time/response time constant),w(relative starting point),sv (inter-trial variability of drift),andsigma (diffusion coefficient of underlying Wiener process).

Usage

dv2_dfddm(  rt,  response,  v,  a,  t0,  w = 0.5,  sv = 0,  sigma = 1,  sl_thresh = 0.355,  err_tol = 1e-06)

Arguments

rt

A vector of response times (in seconds). If a response time isnon-positve, then its density will evaluate to0 if log = FALSE and-∞ if log = TRUE.

response

Binary response(s) that correspond(s) to either the "lower"or "upper" threshold. This model parameter can either be a singular valueor a vector. The value(s) in 'response' can be of the following datatypes:

  • integers or doubles (1→ "lower",2→ "upper");

  • factors (the first level gets mapped to "lower", and the secondlevel gets mapped to "upper"; any additional levels are ignored).

  • strings (only the first character is checked, "L"→ "lower" or "U"→ "upper", case insensitive);

  • logicals (FALSE → "lower",TRUE → "upper");

v

Drift rate. Average slope of the information accumulation process.The drift gives information about the speed and direction of theaccumulation of information. Large (absolute) values of drift indicate agood performance. If received information supports the response linked tothe upper threshold, then the sign will be positive; similarly a negativevalue indicates that the received information supports the response linkedto the lower threshold. Allowed range:v is a real number. Typicalrange:-5 <v< 5.

a

Threshold separation. Amount of information that is considered fora decision. Large values indicate a conservative decisional style. Allowedrange:0 <a. Typical range:0.5 <a< 2.

t0

Non-decision time or response time constant (in seconds). Lowerbound for the duration of all non-decisional processes (encoding andresponse execution). If this value is greater thanrt, then theresulting density is returned as ifrt \le 0. Allowed range:0 \let0. Typical range:0.1 <t0< 0.5.

w

Relative starting point. Indicator of an a priori bias in decisionmaking. When the relative starting pointw deviates from0.5,the amount of information necessary for a decision differs betweenresponse alternatives. Allowed range:0 <w< 1.Default value is0.5 (i.e., no bias).

sv

Inter-trial-variability of drift rate. Standard deviation of anormal distribution with meanv describing the distribution ofactual drift rates from specific trials. Values different from0 canpredict slow errors. Allowed range:0 \lesv. Typical range:0 <sv< 2. Default value is0, which indicatesno drift in the function call. See Details for more information.

sigma

Diffusion coefficient of the underlying Wiener process. Allowedrange:0 <sigma. Default value is1. This parametersimply scales the parametersv,a, andsv as follows.See Details for more information.

  • aa/sigma

  • vv/sigma

  • svsv/sigma

.

sl_thresh

Threshold for deciding when to use the "small-time" variantor the "large-time" variant. If the "effective response time" is greaterthansl_thresh (i.e.,\frac{rt}{a^2} >sl_thresh),then the "large-time" variant is used; otherwise, the "small-time" variantis used. Allowed values are any real number; however any non-positivenumber means that the "large-time" variant will always be used. Similarly,any very large positive number (e.g., +Inf) means that the "small-time"variant will always be used. Default value is0.355.

err_tol

Allowed error tolerance of the overall calculation. Since thepartial derivative of the density function contains one infinite sum, thisparameter defines the precision of the approximation to that infinite sum.If the provided error tolerance is less than1e-300, it is set to1e-300. Default is1e-6.

Details

All of the model inputs and parameters (rt,response,v,a,t0,w,sv,sigma) can beinput as a single value or as a vector of values. If input as a vector ofvalues, then the standardR input wrapping will occur.

sv - Both the "small-time" and "large-time" variants of the densityfunction have two further variants: one with a constant drift ratev(i.e.,sv= 0), and one with a variable drift ratev(i.e.,sv> 0). The details of the differences between thesetwo density functions can be found in our associated paper. To use thedensity function with a constant drift rate, leave the parametersvto its default value ofsv = 0, as this will indicate no drift to thefunction. To use the density function with a variable drift rate, set theparametersv to some non-negative value, i.e.,sv> 0.

sigma - The default value of this parameter is1 because itonly scales the parametersv,a, andsv, as shownabove. However, other formulations of the DDM may setsigma = 0.1(see Ratcliff (1978), the fourth reference), so care must be taken whencomparing the results of different formulations.

Value

A vector containing the second-order partial derivatives of theDDM PDF with precisionerr_tol whose length matches that of thelongest input parameter (usuallyrt).

References

Navarro, D. J., & Fuss, I. G. (2009). Fast and accuratecalculations for first-passage times in Wiener diffusion models. Journalof Mathematical Psychology, 53(4), 222-230.

Gondan, M., Blurton, S. P., & Kesselmeier, M. (2014). Even faster and evenmore accurate first-passage time densities and distributions for theWiener diffusion model. Journal of Mathematical Psychology, 60, 20-22.

Blurton, S. P., Kesselmeier, M., & Gondan, M. (2017). The first-passagetime distribution for the diffusion model with variable drift. Journal ofMathematical Psychology, 76, 7-12.

Hartmann, R., Klauer, K. C. (2021). Partial derivatives for thefirst-passage time distribution in Wiener diffusion models. Journal ofMathematical Psychology, 103, 102550.

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

Examples

# derivative with respect to rt (response time)dt_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to t0 (non-decision time)dt0_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,          sv = 0.4, err_tol = 1e-6)# derivative with respect to a (threshold separation)da_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to v (drift rate)dv_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to w (relative starting point)dw_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to sv (inter-trial variability in the drift rate)dsv_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,          sv = 0.4, err_tol = 1e-6)#-------- Log Versions --------## # derivative with respect to rt (response time)# dt_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to t0 (non-decision time)# dt0_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#               sv = 0.4, err_tol = 1e-6)# # derivative with respect to a (threshold separation)# da_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to v (drift rate)# dv_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to w (relative starting point)# dw_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to sv (inter-trial variability in the drift rate)# dsv_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#               sv = 0.4, err_tol = 1e-6)

Partial Derivative of 5-parameter DDM PDF with respect to v (drift rate)

Description

Partial Derivative of the density function for the 5-parameter variant ofthe Ratcliff diffusion decision model (DDM) with respect to v, the driftrate. This variant contains the following parameters:v (drift rate),a (threshold separation),t0 (non-decision time/response time constant),w(relative starting point),sv (inter-trial variability of drift),andsigma (diffusion coefficient of underlying Wiener process).

Usage

dv_dfddm(  rt,  response,  v,  a,  t0,  w = 0.5,  sv = 0,  sigma = 1,  sl_thresh = 0.355,  err_tol = 1e-06)

Arguments

rt

A vector of response times (in seconds). If a response time isnon-positve, then its density will evaluate to0 if log = FALSE and-∞ if log = TRUE.

response

Binary response(s) that correspond(s) to either the "lower"or "upper" threshold. This model parameter can either be a singular valueor a vector. The value(s) in 'response' can be of the following datatypes:

  • integers or doubles (1→ "lower",2→ "upper");

  • factors (the first level gets mapped to "lower", and the secondlevel gets mapped to "upper"; any additional levels are ignored).

  • strings (only the first character is checked, "L"→ "lower" or "U"→ "upper", case insensitive);

  • logicals (FALSE → "lower",TRUE → "upper");

v

Drift rate. Average slope of the information accumulation process.The drift gives information about the speed and direction of theaccumulation of information. Large (absolute) values of drift indicate agood performance. If received information supports the response linked tothe upper threshold, then the sign will be positive; similarly a negativevalue indicates that the received information supports the response linkedto the lower threshold. Allowed range:v is a real number. Typicalrange:-5 <v< 5.

a

Threshold separation. Amount of information that is considered fora decision. Large values indicate a conservative decisional style. Allowedrange:0 <a. Typical range:0.5 <a< 2.

t0

Non-decision time or response time constant (in seconds). Lowerbound for the duration of all non-decisional processes (encoding andresponse execution). If this value is greater thanrt, then theresulting density is returned as ifrt \le 0. Allowed range:0 \let0. Typical range:0.1 <t0< 0.5.

w

Relative starting point. Indicator of an a priori bias in decisionmaking. When the relative starting pointw deviates from0.5,the amount of information necessary for a decision differs betweenresponse alternatives. Allowed range:0 <w< 1.Default value is0.5 (i.e., no bias).

sv

Inter-trial-variability of drift rate. Standard deviation of anormal distribution with meanv describing the distribution ofactual drift rates from specific trials. Values different from0 canpredict slow errors. Allowed range:0 \lesv. Typical range:0 <sv< 2. Default value is0, which indicatesno drift in the function call. See Details for more information.

sigma

Diffusion coefficient of the underlying Wiener process. Allowedrange:0 <sigma. Default value is1. This parametersimply scales the parametersv,a, andsv as follows.See Details for more information.

  • aa/sigma

  • vv/sigma

  • svsv/sigma

.

sl_thresh

Threshold for deciding when to use the "small-time" variantor the "large-time" variant. If the "effective response time" is greaterthansl_thresh (i.e.,\frac{rt}{a^2} >sl_thresh),then the "large-time" variant is used; otherwise, the "small-time" variantis used. Allowed values are any real number; however any non-positivenumber means that the "large-time" variant will always be used. Similarly,any very large positive number (e.g., +Inf) means that the "small-time"variant will always be used. Default value is0.355.

err_tol

Allowed error tolerance of the overall calculation. Since thepartial derivative of the density function contains one infinite sum, thisparameter defines the precision of the approximation to that infinite sum.If the provided error tolerance is less than1e-300, it is set to1e-300. Default is1e-6.

Details

All of the model inputs and parameters (rt,response,v,a,t0,w,sv,sigma) can beinput as a single value or as a vector of values. If input as a vector ofvalues, then the standardR input wrapping will occur.

sv - Both the "small-time" and "large-time" variants of the densityfunction have two further variants: one with a constant drift ratev(i.e.,sv= 0), and one with a variable drift ratev(i.e.,sv> 0). The details of the differences between thesetwo density functions can be found in our associated paper. To use thedensity function with a constant drift rate, leave the parametersvto its default value ofsv = 0, as this will indicate no drift to thefunction. To use the density function with a variable drift rate, set theparametersv to some non-negative value, i.e.,sv> 0.

sigma - The default value of this parameter is1 because itonly scales the parametersv,a, andsv, as shownabove. However, other formulations of the DDM may setsigma = 0.1(see Ratcliff (1978), the fourth reference), so care must be taken whencomparing the results of different formulations.

Value

A vector containing the partial derivatives of the DDM PDF withprecisionerr_tol whose length matches that of the longest inputparameter (usuallyrt).

References

Navarro, D. J., & Fuss, I. G. (2009). Fast and accuratecalculations for first-passage times in Wiener diffusion models. Journalof Mathematical Psychology, 53(4), 222-230.

Gondan, M., Blurton, S. P., & Kesselmeier, M. (2014). Even faster and evenmore accurate first-passage time densities and distributions for theWiener diffusion model. Journal of Mathematical Psychology, 60, 20-22.

Blurton, S. P., Kesselmeier, M., & Gondan, M. (2017). The first-passagetime distribution for the diffusion model with variable drift. Journal ofMathematical Psychology, 76, 7-12.

Hartmann, R., Klauer, K. C. (2021). Partial derivatives for thefirst-passage time distribution in Wiener diffusion models. Journal ofMathematical Psychology, 103, 102550.

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

Examples

# derivative with respect to rt (response time)dt_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to t0 (non-decision time)dt0_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,          sv = 0.4, err_tol = 1e-6)# derivative with respect to a (threshold separation)da_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to v (drift rate)dv_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to w (relative starting point)dw_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to sv (inter-trial variability in the drift rate)dsv_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,          sv = 0.4, err_tol = 1e-6)#-------- Log Versions --------## # derivative with respect to rt (response time)# dt_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to t0 (non-decision time)# dt0_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#               sv = 0.4, err_tol = 1e-6)# # derivative with respect to a (threshold separation)# da_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to v (drift rate)# dv_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to w (relative starting point)# dw_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to sv (inter-trial variability in the drift rate)# dsv_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#               sv = 0.4, err_tol = 1e-6)

Second-Order Partial Derivative of 5-parameter DDM PDF with respect to w(initial bias)

Description

Second-Order Partial Derivative of the density function for the 5-parametervariant of the Ratcliff diffusion decision model (DDM) with respect to w,the initial bias. This variant contains the following parameters:v (drift rate),a (threshold separation),t0 (non-decision time/response time constant),w(relative starting point),sv (inter-trial variability of drift),andsigma (diffusion coefficient of underlying Wiener process).

Usage

dw2_dfddm(  rt,  response,  v,  a,  t0,  w = 0.5,  sv = 0,  sigma = 1,  sl_thresh = 0.5,  err_tol = 1e-06)

Arguments

rt

A vector of response times (in seconds). If a response time isnon-positve, then its density will evaluate to0 if log = FALSE and-∞ if log = TRUE.

response

Binary response(s) that correspond(s) to either the "lower"or "upper" threshold. This model parameter can either be a singular valueor a vector. The value(s) in 'response' can be of the following datatypes:

  • integers or doubles (1→ "lower",2→ "upper");

  • factors (the first level gets mapped to "lower", and the secondlevel gets mapped to "upper"; any additional levels are ignored).

  • strings (only the first character is checked, "L"→ "lower" or "U"→ "upper", case insensitive);

  • logicals (FALSE → "lower",TRUE → "upper");

v

Drift rate. Average slope of the information accumulation process.The drift gives information about the speed and direction of theaccumulation of information. Large (absolute) values of drift indicate agood performance. If received information supports the response linked tothe upper threshold, then the sign will be positive; similarly a negativevalue indicates that the received information supports the response linkedto the lower threshold. Allowed range:v is a real number. Typicalrange:-5 <v< 5.

a

Threshold separation. Amount of information that is considered fora decision. Large values indicate a conservative decisional style. Allowedrange:0 <a. Typical range:0.5 <a< 2.

t0

Non-decision time or response time constant (in seconds). Lowerbound for the duration of all non-decisional processes (encoding andresponse execution). If this value is greater thanrt, then theresulting density is returned as ifrt \le 0. Allowed range:0 \let0. Typical range:0.1 <t0< 0.5.

w

Relative starting point. Indicator of an a priori bias in decisionmaking. When the relative starting pointw deviates from0.5,the amount of information necessary for a decision differs betweenresponse alternatives. Allowed range:0 <w< 1.Default value is0.5 (i.e., no bias).

sv

Inter-trial-variability of drift rate. Standard deviation of anormal distribution with meanv describing the distribution ofactual drift rates from specific trials. Values different from0 canpredict slow errors. Allowed range:0 \lesv. Typical range:0 <sv< 2. Default value is0, which indicatesno drift in the function call. See Details for more information.

sigma

Diffusion coefficient of the underlying Wiener process. Allowedrange:0 <sigma. Default value is1. This parametersimply scales the parametersv,a, andsv as follows.See Details for more information.

  • aa/sigma

  • vv/sigma

  • svsv/sigma

.

sl_thresh

Threshold for deciding when to use the "small-time" variantor the "large-time" variant in one half of the calculation of the partialderivative of the density function. This acts in exactly the same way asthe parametermax_terms_large in thedfddm() function: it isthe maximum number of terms to use for the "large-time" variant beforeswitching to using the "small-time" variant. The other half of thecalculation leverages a different type of comparison between the"large-time" and "small-time" variants that requires no input from theuser. Allowed values are any real number; however any non-positive numbermeans that the "small-time" variant will always be used. Similarly, anyvery large positive number (e.g., +Inf) means that the "large-time"variant will always be used. Default value is1.

err_tol

Allowed error tolerance of the overall calculation. Since thepartial derivative of the density function contains the sum of twoinfinite sums, each approximation of these two infinite sums will have anindividual error tolerance oferr_tol / 2; thus the total overallerror of the calculation will be at mosterr_tol. If the providederror tolerance is less than1e-300, it is set to1e-300.Default is1e-6.

Details

All of the model inputs and parameters (rt,response,v,a,t0,w,sv,sigma) can beinput as a single value or as a vector of values. If input as a vector ofvalues, then the standardR input wrapping will occur.

sv - Both the "small-time" and "large-time" variants of the densityfunction have two further variants: one with a constant drift ratev(i.e.,sv= 0), and one with a variable drift ratev(i.e.,sv> 0). The details of the differences between thesetwo density functions can be found in our associated paper. To use thedensity function with a constant drift rate, leave the parametersvto its default value ofsv = 0, as this will indicate no drift to thefunction. To use the density function with a variable drift rate, set theparametersv to some non-negative value, i.e.,sv> 0.

sigma - The default value of this parameter is1 because itonly scales the parametersv,a, andsv, as shownabove. However, other formulations of the DDM may setsigma = 0.1(see Ratcliff (1978), the fourth reference), so care must be taken whencomparing the results of different formulations.

Value

A vector containing the second-order partial derivatives of theDDM PDF with precisionerr_tol whose length matches that of thelongest input parameter (usuallyrt).

References

Navarro, D. J., & Fuss, I. G. (2009). Fast and accuratecalculations for first-passage times in Wiener diffusion models. Journalof Mathematical Psychology, 53(4), 222-230.

Gondan, M., Blurton, S. P., & Kesselmeier, M. (2014). Even faster and evenmore accurate first-passage time densities and distributions for theWiener diffusion model. Journal of Mathematical Psychology, 60, 20-22.

Blurton, S. P., Kesselmeier, M., & Gondan, M. (2017). The first-passagetime distribution for the diffusion model with variable drift. Journal ofMathematical Psychology, 76, 7-12.

Hartmann, R., Klauer, K. C. (2021). Partial derivatives for thefirst-passage time distribution in Wiener diffusion models. Journal ofMathematical Psychology, 103, 102550.

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

Examples

# derivative with respect to rt (response time)dt_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to t0 (non-decision time)dt0_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,          sv = 0.4, err_tol = 1e-6)# derivative with respect to a (threshold separation)da_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to v (drift rate)dv_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to w (relative starting point)dw_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to sv (inter-trial variability in the drift rate)dsv_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,          sv = 0.4, err_tol = 1e-6)#-------- Log Versions --------## # derivative with respect to rt (response time)# dt_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to t0 (non-decision time)# dt0_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#               sv = 0.4, err_tol = 1e-6)# # derivative with respect to a (threshold separation)# da_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to v (drift rate)# dv_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to w (relative starting point)# dw_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to sv (inter-trial variability in the drift rate)# dsv_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#               sv = 0.4, err_tol = 1e-6)

Partial Derivative of 5-parameter DDM PDF with respect to w (initial bias)

Description

Partial Derivative of the density function for the 5-parameter variant ofthe Ratcliff diffusion decision model (DDM) with respect to w, the initialbias. This variant contains the following parameters:v (drift rate),a (threshold separation),t0 (non-decision time/response time constant),w(relative starting point),sv (inter-trial variability of drift),andsigma (diffusion coefficient of underlying Wiener process).

Usage

dw_dfddm(  rt,  response,  v,  a,  t0,  w = 0.5,  sv = 0,  sigma = 1,  sl_thresh = 1,  err_tol = 1e-06)

Arguments

rt

A vector of response times (in seconds). If a response time isnon-positve, then its density will evaluate to0 if log = FALSE and-∞ if log = TRUE.

response

Binary response(s) that correspond(s) to either the "lower"or "upper" threshold. This model parameter can either be a singular valueor a vector. The value(s) in 'response' can be of the following datatypes:

  • integers or doubles (1→ "lower",2→ "upper");

  • factors (the first level gets mapped to "lower", and the secondlevel gets mapped to "upper"; any additional levels are ignored).

  • strings (only the first character is checked, "L"→ "lower" or "U"→ "upper", case insensitive);

  • logicals (FALSE → "lower",TRUE → "upper");

v

Drift rate. Average slope of the information accumulation process.The drift gives information about the speed and direction of theaccumulation of information. Large (absolute) values of drift indicate agood performance. If received information supports the response linked tothe upper threshold, then the sign will be positive; similarly a negativevalue indicates that the received information supports the response linkedto the lower threshold. Allowed range:v is a real number. Typicalrange:-5 <v< 5.

a

Threshold separation. Amount of information that is considered fora decision. Large values indicate a conservative decisional style. Allowedrange:0 <a. Typical range:0.5 <a< 2.

t0

Non-decision time or response time constant (in seconds). Lowerbound for the duration of all non-decisional processes (encoding andresponse execution). If this value is greater thanrt, then theresulting density is returned as ifrt \le 0. Allowed range:0 \let0. Typical range:0.1 <t0< 0.5.

w

Relative starting point. Indicator of an a priori bias in decisionmaking. When the relative starting pointw deviates from0.5,the amount of information necessary for a decision differs betweenresponse alternatives. Allowed range:0 <w< 1.Default value is0.5 (i.e., no bias).

sv

Inter-trial-variability of drift rate. Standard deviation of anormal distribution with meanv describing the distribution ofactual drift rates from specific trials. Values different from0 canpredict slow errors. Allowed range:0 \lesv. Typical range:0 <sv< 2. Default value is0, which indicatesno drift in the function call. See Details for more information.

sigma

Diffusion coefficient of the underlying Wiener process. Allowedrange:0 <sigma. Default value is1. This parametersimply scales the parametersv,a, andsv as follows.See Details for more information.

  • aa/sigma

  • vv/sigma

  • svsv/sigma

.

sl_thresh

Threshold for deciding when to use the "small-time" variantor the "large-time" variant in one half of the calculation of the partialderivative of the density function. This acts in exactly the same way asthe parametermax_terms_large in thedfddm() function: it isthe maximum number of terms to use for the "large-time" variant beforeswitching to using the "small-time" variant. The other half of thecalculation leverages a different type of comparison between the"large-time" and "small-time" variants that requires no input from theuser. Allowed values are any real number; however any non-positive numbermeans that the "small-time" variant will always be used. Similarly, anyvery large positive number (e.g., +Inf) means that the "large-time"variant will always be used. Default value is1.

err_tol

Allowed error tolerance of the overall calculation. Since thepartial derivative of the density function contains the sum of twoinfinite sums, each approximation of these two infinite sums will have anindividual error tolerance oferr_tol / 2; thus the total overallerror of the calculation will be at mosterr_tol. If the providederror tolerance is less than1e-300, it is set to1e-300.Default is1e-6.

Details

All of the model inputs and parameters (rt,response,v,a,t0,w,sv,sigma) can beinput as a single value or as a vector of values. If input as a vector ofvalues, then the standardR input wrapping will occur.

sv - Both the "small-time" and "large-time" variants of the densityfunction have two further variants: one with a constant drift ratev(i.e.,sv= 0), and one with a variable drift ratev(i.e.,sv> 0). The details of the differences between thesetwo density functions can be found in our associated paper. To use thedensity function with a constant drift rate, leave the parametersvto its default value ofsv = 0, as this will indicate no drift to thefunction. To use the density function with a variable drift rate, set theparametersv to some non-negative value, i.e.,sv> 0.

sigma - The default value of this parameter is1 because itonly scales the parametersv,a, andsv, as shownabove. However, other formulations of the DDM may setsigma = 0.1(see Ratcliff (1978), the fourth reference), so care must be taken whencomparing the results of different formulations.

Value

A vector containing the partial derivatives of the DDM PDF withprecisionerr_tol whose length matches that of the longest inputparameter (usuallyrt).

References

Navarro, D. J., & Fuss, I. G. (2009). Fast and accuratecalculations for first-passage times in Wiener diffusion models. Journalof Mathematical Psychology, 53(4), 222-230.

Gondan, M., Blurton, S. P., & Kesselmeier, M. (2014). Even faster and evenmore accurate first-passage time densities and distributions for theWiener diffusion model. Journal of Mathematical Psychology, 60, 20-22.

Blurton, S. P., Kesselmeier, M., & Gondan, M. (2017). The first-passagetime distribution for the diffusion model with variable drift. Journal ofMathematical Psychology, 76, 7-12.

Hartmann, R., Klauer, K. C. (2021). Partial derivatives for thefirst-passage time distribution in Wiener diffusion models. Journal ofMathematical Psychology, 103, 102550.

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

Examples

# derivative with respect to rt (response time)dt_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to t0 (non-decision time)dt0_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,          sv = 0.4, err_tol = 1e-6)# derivative with respect to a (threshold separation)da_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to v (drift rate)dv_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to w (relative starting point)dw_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,         sv = 0.4, err_tol = 1e-6)# derivative with respect to sv (inter-trial variability in the drift rate)dsv_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,          sv = 0.4, err_tol = 1e-6)#-------- Log Versions --------## # derivative with respect to rt (response time)# dt_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to t0 (non-decision time)# dt0_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#               sv = 0.4, err_tol = 1e-6)# # derivative with respect to a (threshold separation)# da_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to v (drift rate)# dv_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to w (relative starting point)# dw_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#              sv = 0.4, err_tol = 1e-6)# # derivative with respect to sv (inter-trial variability in the drift rate)# dsv_log_dfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3, w = 0.5,#               sv = 0.4, err_tol = 1e-6)

Medicial decision data

Description

Part of the accuracy and response time data presented in Trueblood et al.(2017) investigating medical decision making among medical professionals(pathologists) and novices (i.e., undergraduate students). The task ofparticipants was to judge whether pictures of blood cells show cancerouscells (i.e., blast cells) or non-cancerous cells (i.e., non-blast cells). Thecurrent data set contains 200 decisions per participant (the "accuracy"condition from Trueblood et al.).

Usage

data(med_dec)

Format

A data frame with 11000 rows and 9 variables:

id

identification number of the participant

group

expertise of participant; "experienced", "inexperienced", or "novice". The first two levels refer to different type of medical professional (i.e., experts).

block

block number

trial

index of trial for each participant

classification

true classification of the pictured cell; i.e. the correct response

difficulty

adjudged difficulty of the task for the particular image

response

response given by the participant; either "blast" or "non-blast"

rt

the response time associated with the response, in seconds

stimulus

the image file used for the specific trial

Details

At the beginning of the experiment, both novices and medical expertscompleted a training to familiarize themselves with blast cells. After that,each participant performed the main task in which they judged whether or notpresented images were blast cells or non-blast cells. Among them, some of thecells were judged as easy and some as difficult trials by an additional groupof experts. The current data set only contains the data from the "accuracy"condition (i.e., Trueblood et al. considered additional conditions that arenot part of the current data set).

The relevant part of the method section for the accuracy condition from theoriginal paper is as follows:

"The main task consisted of six blocks with 100 trials in each block. Themain task was the same as the practice block, where participants were askedto identify single images. However, participants did not receivetrial-by-trial feedback about their choices. They received feedback abouttheir performance at the end of each block. The 100 trials in each block werecomposed of equal numbers of easy blast images, hard blast images, easynon-blast images, and hard non-blast images, fully randomized.

There were three manipulations across blocks: accuracy, speed, and bias. Inthe accuracy blocks, participants were instructed to respond as accurately aspossible and were given 5 s to respond. [...] If they responded after thedeadline, they received the message "Too Slow!" The 5-s [...] responsewindows for the accuracy [...] [condition was] based on the response timedata from the three expert raters. The 0.975 quantile of the expert raters'response times was 4.96 s; thus, we set the accuracy response window to 5 s.

The order of the first three blocks was randomized but with the constraintthat there was one block for each type of manipulation (i.e., accuracy,speed, and bias). The order of the last three blocks was identical to theorder of the first three blocks."

Note that this dataset contains some negative response times that indicate amissing response (i.e., the response value for that trial isNA). Take carein removing these values before using this dataset. See our Validity vignettefor an example of use in an optimization setting.

Source

Trueblood, J.S., Holmes, W.R., Seegmiller, A.C. et al. The impact ofspeed and bias on the cognitive processes of experts and novices in medicalimage decision-making. Cogn. Research 3, 28 (2018).https://doi.org/10.1186/s41235-018-0119-2

Examples

data("med_dec", package = "fddm")str(med_dec)## number of participants per expertise condition:aggregate(id ~ group, med_dec, function(x) length(unique(x)))## number of trials per participantaggregate(rt ~ group + id, med_dec, length)

Distribution of Ratcliff Diffusion Decision Model

Description

Density function for the Ratcliff diffusion decision model (DDM) withfollowing parameters:v (drift rate),a (thresholdseparation),t0 (non-decision time/response time constant),w(relative starting point),sv (inter-trial variability of drift), andsigma (diffusion coefficient of underlying Wiener process).

Usage

pfddm(  rt,  response,  v,  a,  t0,  w = 0.5,  sv = 0,  sigma = 1,  err_tol = 1e-06,  log = FALSE,  method = "Mills")

Arguments

rt

A vector of response times (in seconds). If a response time isnon-positve, then its density will evaluate to0 if log = FALSE and-∞ if log = TRUE.

response

Binary response(s) that correspond(s) to either the "lower"or "upper" threshold. This model parameter can either be a singular valueor a vector. The value(s) in 'response' can be of the following datatypes:

  • integers or doubles (1→ "lower",2→ "upper");

  • factors (the first level gets mapped to "lower", and the secondlevel gets mapped to "upper"; any additional levels are ignored).

  • strings (only the first character is checked, "L"→ "lower" or "U"→ "upper", case insensitive);

  • logicals (FALSE → "lower",TRUE → "upper");

v

Drift rate. Average slope of the information accumulation process.The drift gives information about the speed and direction of theaccumulation of information. Large (absolute) values of drift indicate agood performance. If received information supports the response linked tothe upper threshold, then the sign will be positive; similarly a negativevalue indicates that the received information supports the response linkedto the lower threshold. Allowed range:v is a real number. Typicalrange:-5 <v< 5.

a

Threshold separation. Amount of information that is considered fora decision. Large values indicate a conservative decisional style. Allowedrange:0 <a. Typical range:0.5 <a< 2.

t0

Non-decision time or response time constant (in seconds). Lowerbound for the duration of all non-decisional processes (encoding andresponse execution). If this value is greater thanrt, then theresulting density is returned as ifrt \le 0. Allowed range:0 \let0. Typical range:0.1 <t0< 0.5.

w

Relative starting point. Indicator of an a priori bias in decisionmaking. When the relative starting pointw deviates from0.5,the amount of information necessary for a decision differs betweenresponse alternatives. Allowed range:0 <w< 1.Default value is0.5 (i.e., no bias).

sv

Inter-trial-variability of drift rate. Standard deviation of anormal distribution with meanv describing the distribution ofactual drift rates from specific trials. Values different from0 canpredict slow errors. Allowed range:0 \lesv. Typical range:0 <sv< 2. Default value is0, which indicatesno drift in the function call. See Details for more information.

sigma

Diffusion coefficient of the underlying Wiener process. Allowedrange:0 <sigma. Default value is1. This parametersimply scales the parametersa,v, andsv as follows.See Details for more information.

  • aa/sigma

  • vv/sigma

  • svsv/sigma

.

err_tol

Allowed error tolerance of the density function. Since thedensity function contains an infinite sum, this parameter defines theprecision of the approximation to that infinite sum. If the providederror tolerance is less than1e-300, it is set to1e-300.Default is1e-6.

log

Logical; ifTRUE, probabilitiesp are given aslog(p). Default isFALSE.

method

Which method of calculating the CDF to use. Can be one of{"Mills","NCDF"}, case-insensitive. Default is"Mills".

Details

All of the model inputs and parameters (rt,response,v,a,t0,w,sv,sigma) can beinput as a single value or as a vector of values. If input as a vector ofvalues, then the standardR input wrapping will occur.

sigma - The default value of this parameter is1 because itonly scales the parametersv,a, andsv, as shownabove. However, other formulations of the DDM may setsigma = 0.1(see Ratcliff (1978), the fourth reference), so care must be taken whencomparing the results of different formulations.

Value

A vector containing the distribution of the DDM with precisionerr_tol whose length matches that of the longest input parameter(usuallyrt).

References

Navarro, D. J., & Fuss, I. G. (2009). Fast and accuratecalculations for first-passage times in Wiener diffusion models. Journalof Mathematical Psychology, 53(4), 222-230.

Gondan, M., Blurton, S. P., & Kesselmeier, M. (2014). Even faster and evenmore accurate first-passage time densities and distributions for theWiener diffusion model. Journal of Mathematical Psychology, 60, 20-22.

Blurton, S. P., Kesselmeier, M., & Gondan, M. (2017). The first-passagetime distribution for the diffusion model with variable drift. Journal ofMathematical Psychology, 76, 7-12.

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

Examples

# minimal examplepfddm(rt = 1.2, response = "lower", a = 1, v = -1, t0 = 0.3)# example with all function parameters set to default or a practical valuepfddm(rt = c(1.2, 0.9, 1.1, 1.4, 0.8, 1.3),      response = c("lower", "upper", "upper", "lower", "upper", "lower"),      a = 1, v = -1, t0 = 0.2, w = 0.5, sv = 0, sigma = 1,      err_tol = 1e-6, log = FALSE, method = "Mills")# example of mismatched input lengthspfddm(rt = c(1.2, 0.9, 1.1, 1.4, 0.8, 1.3),      response = c("lower", "upper", "upper", "lower", "upper", "lower"),      a = c(1, 3), v = c(-2, 2, 2, -2, 2, -2),      t0 = 0.3, w = c(0.4, 0.5, 0.6), sv = 0.9,      err_tol = 1e-10, log = FALSE, method = "NCDF")# example with Wiener diffusion coefficient (sigma) not equal to 1pfddm(rt = c(1.2, 0.9, 1.1, 1.4, 0.8, 1.3),      response = c("lower", "upper", "upper", "lower", "upper", "lower"),      a = 1, v = -1, t0 = 0.3, w = 0.5, sv = 0, sigma = 0.1,      err_tol = 1e-10, log = TRUE, method = "Mills")### examples of different response inputs# integerresp_int <- as.integer(c(1, 2, 2, 1, 2, 1))pfddm(rt = c(1.2, 0.9, 1.1, 1.4, 0.8, 1.3), response = resp_int,      a = 1, v = -2, t0 = 0.3, w = 0.5, sv = 0.1,      err_tol = 1e-10, log = FALSE, method = "Mills")# doubleresp_dbl <- as.double(c(1, 2, 2, 1, 2, 1))pfddm(rt = c(1.2, 0.9, 1.1, 1.4, 0.8, 1.3), response = resp_dbl,      a = 1, v = -2, t0 = 0.3, w = 0.5, sv = 0.1,      err_tol = 1e-10, log = FALSE, method = "Mills")# factor (first level is mapped to "lower")days <- c("Monday", "Friday", "Friday", "Monday", "Friday", "Monday")resp_fac <- factor(days, levels = c("Monday", "Friday"))pfddm(rt = c(1.2, 0.9, 1.1, 1.4, 0.8, 1.3), response = resp_fac,      a = 1, v = -2, t0 = 0.3, w = 0.5, sv = 0.1,      err_tol = 1e-10, log = FALSE, method = "Mills")# stringresp_str <- c("lower", "upper", "upper", "lower", "upper", "lower")pfddm(rt = c(1.2, 0.9, 1.1, 1.4, 0.8, 1.3), response = resp_str,      a = 1, v = -2, t0 = 0.3, w = 0.5, sv = 0.1,      err_tol = 1e-10, log = FALSE, method = "Mills")# logicalresp_log <- c(FALSE, TRUE, TRUE, FALSE, TRUE, FALSE)pfddm(rt = c(1.2, 0.9, 1.1, 1.4, 0.8, 1.3), response = resp_log,      a = 1, v = -2, t0 = 0.3, w = 0.5, sv = 0.1,      err_tol = 1e-10, log = FALSE, method = "Mills")

[8]ページ先頭

©2009-2025 Movatter.jp