Title: | Circular Drift-Diffusion Model |
---|---|
Description: | Circular drift-diffusion model for continuous reports. |
Authors: | Yi-Shin Lin [aut, cre], Andrew Heathcote [aut], Peter Kvam [aut] |
Maintainer: | Yi-Shin Lin <[email protected]> |
License: | GPL-2 |
Version: | 0.1.0 |
Built: | 2025-02-23 04:01:10 UTC |
Source: | https://github.com/cran/CircularDDM |
Find first k positive zeros of the Bessel function J(n,x) or Y(n,x) using Halley's method.
besselzero(nu, k, kind)
besselzero(nu, k, kind)
nu |
The order of the corresponding Bessel function. |
k |
an integer for first k positive zeros. |
kind |
a vector
nu <- seq(0, 5, length.out=10) output <- matrix(numeric(5*length(nu)), nrow=5) for(i in 1:length(nu)) { output[,i] <- besselzero(nu[i], 5, 1) } output output <- matrix(numeric(5*length(nu)), nrow=5) for(i in 1:length(nu)) { output[,i] <- besselzero(nu[i], 5, 2) } output
nu <- seq(0, 5, length.out=10) output <- matrix(numeric(5*length(nu)), nrow=5) for(i in 1:length(nu)) { output[,i] <- besselzero(nu[i], 5, 1) } output output <- matrix(numeric(5*length(nu)), nrow=5) for(i in 1:length(nu)) { output[,i] <- besselzero(nu[i], 5, 2) } output
Circular drift-diffusion model for continuous report.
Yi-Shin Lin <[email protected]>
Andrew Heathcote <[email protected]>
Peter Kvam <[email protected]>
Smith, P. L. (2016). Diffusion Theory of Decision Making in Continuous Report, Psychological Review, 123(4), 425–451.
Density function and random generation for the circular drift-diffusion
model with theta vector equal to pVec
. dcddm
is the
equation (23) on page 433 in Smith (2016).
dcddm(x, pVec, k = 141L) rcddm(n, pVec, p = 0.15)
dcddm(x, pVec, k = 141L) rcddm(n, pVec, p = 0.15)
x |
a matrix storing a first column as RT and a second column of continuous responses/reports/outcomes. Each row is a trial. |
pVec |
a parameter vector with the order [a, vx, vy, t0, s], or [thresh, mu1, mu2, ndt, sigmasq]. The order matters. |
k |
a precision for calculating the infinite series in |
n |
number of observations. |
p |
a precision for random walk step in |
dcddm
gives a log-likelihood vector. rddm
generates
random deviates, returning a n x 3 matrix with the columns: RTs, choices
and then angles.
Smith, P. L. (2016). Diffusion Theory of Decision Making in Continuous Report, Psychological Review, 123 (4), 425–451.
## dcddm example x <- cbind( RT= c(1.2595272, 0.8693937, 0.8009044, 1.0018933, 2.3640007, 1.0521304), R = c(1.9217430, 1.7844653, 0.2662521, 2.1569724, 1.7277440, 0.8607271) ) pVec <- c(a=2.45, vx=1.5, vy=1.25, t0=.1, s=1) dcddm(x, pVec) ## rcddm example pVec <- c(a=2, vx=1.5, vy=1.25, t0=.25, s=1) den <- rcddm(1e3, pVec); hist(den[,1], breaks = "fd", xlab="Response Time", main="Density") hist(den[,3], breaks = "fd", xlab="Response Angle", main="Density")
## dcddm example x <- cbind( RT= c(1.2595272, 0.8693937, 0.8009044, 1.0018933, 2.3640007, 1.0521304), R = c(1.9217430, 1.7844653, 0.2662521, 2.1569724, 1.7277440, 0.8607271) ) pVec <- c(a=2.45, vx=1.5, vy=1.25, t0=.1, s=1) dcddm(x, pVec) ## rcddm example pVec <- c(a=2, vx=1.5, vy=1.25, t0=.25, s=1) den <- rcddm(1e3, pVec); hist(den[,1], breaks = "fd", xlab="Response Time", main="Density") hist(den[,3], breaks = "fd", xlab="Response Angle", main="Density")
Calculate circular log-likelihood of the first passage time, using equation (22) on p 432.
logLik_dt(x, pVec, k = 141L)
logLik_dt(x, pVec, k = 141L)
x |
a matrix storing a first column as RT and a second column of continuous responses/reports/outcomes. Each row is a trial. |
pVec |
a parameter vector with the order [a, vx, vy, t0, s], a stands for response threshold, vx is the drift rate along x axis, vy is the drift rate along y axis, t0 is the non-decision time, and s is the within-trial standard deviation. |
k |
a precision for bessel function. The larger the k is, the larger the memory space is required. Default is 141. |
a vector
Smith, P. L. (2016). Diffusion Theory of Decision Making in Continuous Report, Psychological Review, 123 (4), 425–451.
x <- cbind( RT=c(1.2595272, 0.8693937, 0.8009044, 1.0018933, 2.3640007, 1.0521304), R =c(1.9217430, 1.7844653, 0.2662521, 2.1569724, 1.7277440, 0.8607271) ) pVec <- c(a=2.45, vx=1.5, vy=1.25, t0=.1, s=1) den <- logLik_dt(x, pVec=pVec); den
x <- cbind( RT=c(1.2595272, 0.8693937, 0.8009044, 1.0018933, 2.3640007, 1.0521304), R =c(1.9217430, 1.7844653, 0.2662521, 2.1569724, 1.7277440, 0.8607271) ) pVec <- c(a=2.45, vx=1.5, vy=1.25, t0=.1, s=1) den <- logLik_dt(x, pVec=pVec); den
Calculate log-likelihood of the continuous reports, using part part in equation (23) on p 433.
logLik_resp(x, pVec)
logLik_resp(x, pVec)
x |
a matrix storing a first column as RT and a second column of continuous responses/reports/outcomes. Each row is a trial. |
pVec |
a parameter vector with the order [a, vx, vy, t0, s], or [thresh, mu1, mu2, ndt, sigmasq], using alternative names. |
a vector
Smith, P. L. (2016). Diffusion Theory of Decision Making in Continuous Report, Psychological Review, 123 (4), 425–451.
x <- cbind( RT=c(1.2595272, 0.8693937, 0.8009044, 1.0018933, 2.3640007, 1.0521304), R =c(1.9217430, 1.7844653, 0.2662521, 2.1569724, 1.7277440, 0.8607271) ) pVec <- c(a=2.45, vx=1.5, vy=1.25, t0=.1, s=1) den <- logLik_resp(x, pVec=pVec); den
x <- cbind( RT=c(1.2595272, 0.8693937, 0.8009044, 1.0018933, 2.3640007, 1.0521304), R =c(1.9217430, 1.7844653, 0.2662521, 2.1569724, 1.7277440, 0.8607271) ) pVec <- c(a=2.45, vx=1.5, vy=1.25, t0=.1, s=1) den <- logLik_resp(x, pVec=pVec); den
Generate random deviates for the von Mises distribution.
rvm(n, mu, k)
rvm(n, mu, k)
n |
number of observations. |
mu |
mean direction of the distribution. |
k |
non-negative numeric value for the concentration parameter of the distribution |
A random variable for circular normal distribution has the form:
theta is withins 0 and 2 * pi.
I0(kappa)
in the normalizing constant is the modified Bessel
function of the first kind and order zero.
a vector
n <- 100 mu <- 0 k <- 10 vm3_de <- rvm(n, mu, k) ## in degree unit vm3_pi <- vm3_de %% (2 * pi) ## in radian unit
n <- 100 mu <- 0 k <- 10 vm3_de <- rvm(n, mu, k) ## in degree unit vm3_pi <- vm3_de %% (2 * pi) ## in radian unit