Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ wiener_lpdf() [2/4]

template<bool propto = false, typename T_y , typename T_a , typename T_t0 , typename T_w , typename T_v , typename T_sv , typename T_sw , typename T_st0 >
auto stan::math::wiener_lpdf ( const T_y &  y,
const T_a &  a,
const T_t0 &  t0,
const T_w &  w,
const T_v &  v,
const T_sv &  sv,
const T_sw &  sw,
const T_st0 &  st0,
const double &  precision_derivatives = 1e-4 
)
inline

The log of the first passage time density function for a (Wiener) drift diffusion model with up to 7 parameters, where \(y\in \mathbb{R}_{+}\) is the reacion time, \(a \in \mathbb{R}_{+}\) the boundary separation, \(t_0 \in \mathbb{R}_{\geq 0}\) the non-decision time, \(w \in (0, 1)\) the relative starting point (aka a-priori bias), \(v \in \mathbb{R}\) the drifte rate, \(s_v \in \mathbb{R}_{\geq 0}\) the inter-trial variability of the drift rate, \(s_w \in [0, 1)\) the inter-trial variability of the relative starting point, and \(s_{t_0} \in \mathbb{R}_{\geq 0}\) the inter-trial variability of the non-decision time.

\begin{eqnarray*} y &\sim& \text{wiener_full}(a,t_0,w,v,s_v,s_w,s_{t_0}) \\ \log(p(y|a,v,w,t_0,s_v,s_w,s_{t_0})) &=& \log(\frac{1}{s_{t_0}} \int_{t_0}^{t_o + s_{t_0}} \frac{1}{s_{w}}\int_{w -0.5s_w}^{w + 0.5s_{w}} \int_{-\infty}^{\infty} p_3(y-\tau_0|a,\nu,\omega) \\ &&\times\frac{1}{\sqrt{2\pi s_\nu^2}} \mathbb{e}^{-\frac{(\nu-v)^2}{2s_\nu^2}} \ d\nu \ d\omega \ d\tau_0) \\ &=& \log(\frac{1}{s_{t_0}} \int_{t_0}^{t_o + s_{t_0}} \frac{1}{s_{w}}\int_{w -0.5s_w}^{w + 0.5s_{w}} M \times p_3(y-\tau_0|a,v,\omega) \ d\omega \ d\tau_0), \end{eqnarray*}

where \(M\) and \(p_3()\) are defined, by using \(t:=y-\tau_0\), as

\begin{eqnarray*} M &:=& \frac{1}{\sqrt{1+s^2_v t}} \mathbb{e}^{av\omega+\frac{v^2t}{2}+\frac{s^2_v a^2 \omega^2-2av\omega-v^2t}{2(1+s^2_vt)}} \text{ and} \\ p_3(t|a,v,w) &:=& \frac{1}{a^2} \mathbb{e}^{-a v w -\frac{v^2t}{2}} f(\frac{t}{a^2}|0,1,w), \end{eqnarray*}

where \(f(t^*=\frac{t}{a^2}|0,1,w)\) has two forms

\begin{eqnarray*} f_l(t^*|0,1,w) &=& \sum_{k=1}^{\infty} k\pi \mathbb{e}^{-\frac{k^2\pi^2t^*}{2}} \sin{(k \pi w)}\text{ and} \\ f_s(t^*|0,1,w) &=& \sum_{k=-\infty}^{\infty} \frac{1}{\sqrt{2\pi (t^*)^3}} (w+2k) \mathbb{e}^{-\frac{(w+2k)^2}{2t^*}}, \end{eqnarray*}

which are selected depending on the number of components \(k\), needed to guarantee a certain precision.

Note that the parameterization for non-decision time and relative starting point is as follows: t0 is the lower bound of the variability interval; w is the mean of the variability interval.

See Details below for more details on how to use wiener_lpdf().

Template Parameters
T_ytype of scalar
T_atype of boundary separation
T_t0type of non-decision time
T_wtype of relative starting point
T_vtype of drift rate
T_svtype of inter-trial variability of drift rate
T_swtype of inter-trial variability of relative starting point
T_st0type of inter-trial variability of non-decision time
Parameters
yA scalar variable; the reaction time in seconds
aThe boundary separation
t0The non-decision time
wThe relative starting point
vThe drift rate
svThe inter-trial variability of the drift rate
swThe inter-trial variability of the relative starting point
st0The inter-trial variability of the non-decision time
precision_derivativesLevel of precision in estimation of partial derivatives
Returns
The log of the Wiener first passage time density with the specified arguments for upper boundary responses
Exceptions
std::domain_errorif non-decision time t0 is greater than reaction time y.
std::domain_errorif 1-sw/2 is smaller than or equal to w.
std::domain_errorif sw/2 is larger than or equal to w.

Details

The function can be called by

target += wiener_lpdf(y, a, t0, w, v, sv, sw, st0);
auto wiener_lpdf(const T_y &y, const T_a &a, const T_t0 &t0, const T_w &w, const T_v &v, const T_sv &sv, const double &precision_derivatives=1e-4)
Log-density function for the 5-parameter Wiener density.

or

y ~ wiener_full(a, t0, w, v, sv, sw, st0);

By default wiener_lpdf() gives the log of the Wiener first-passage time probability density function for the upper response boundary. To use the lower response boundary v and w must be changed to -v and (1-w), respectively.

sv, sw, st0, and t0 can be set to zero, indicating no inter-trial variability in \(v\), no inter-trial variability in \(w\), no inter-trial variability in \(t_0\), and no non-decision time, respectively. If t0 is zero, st0 must be zero as well. For example, when no inter-trial variability for the relative starting point is needed one can write something like:

target += wiener_lpdf(y, a, t0, w, v, sv, 0, st0)

If no inter-trial variability is needed at all one can write something like:

target += wiener_lpdf(y, a, t0, w, v, 0, 0, 0)

If for some reason no non-decision time is assumed one can write something like:

target += wiener_lpdf(y, a, 0, w, v, sv, sw, 0)

If only inter-trial variability for the drift rate is needed can write something like:

target += wiener_lpdf(y, a, t0, w, v, sv)

To also control the precision in the estimation of the partial derivatives:

target += wiener_lpdf(y, a, t0, w, v, sv, sw, st0, precision);

References

  • Blurton, S. P., Kesselmeier, M., & Gondan, M. (2017). The first-passage time distribution for the diffusion model with variable drift. Journal of Mathematical Psychology, 76, 7–12. https://doi.org/10.1016/j.jmp.2016.11.003
  • Foster, K., & Singmann, H. (2021). Another Approximation of the First-Passage Time Densities for the Ratcliff Diffusion Decision Model. arXiv preprint arXiv:2104.01902
  • Gondan, M., Blurton, S. P., & Kesselmeier, M. (2014). Even faster and even more accurate first-passage time densities and distributions for the Wiener diffusion model. Journal of Mathematical Psychology, 60, 20–22. https://doi.org/10.1016/j.jmp.2014.05.002
  • Hartmann, R., & Klauer, K. C. (2021). Partial derivatives for the first-passage time distribution in Wiener diffusion models. Journal of Mathematical Psychology, 103, 102550. https://doi.org/10.1016/j.jmp.2021.102550
  • Henrich, F., Hartmann, R., Pratz, V., Voss, A., & Klauer, K.C. (2023). The Seven-parameter Diffusion Model: An Implementation in Stan for Bayesian Analyses. Behavior Research Methods.
  • Navarro, D. J., & Fuss, I. G. (2009). Fast and accurate calculations for first-passage times in Wiener diffusion models. Journal of Mathematical Psychology, 53(4), 222–230. https://doi.org/10.1016/j.jmp.2009.02.003

Definition at line 320 of file wiener_full_lpdf.hpp.