Learn R Programming

SSRTcalc (version 2.1.1)

ssrt_stan: Bayesian SSRT estimation via Stan

Description

Fits the independent horse-race model with ex-Gaussian go- and stop-process distributions using Hamiltonian Monte Carlo via Stan. Supports single-subject and multi-subject hierarchical designs, with an optional trigger-failure parameter following Matzke et al. (2013).

Usage

ssrt_stan(
  data,
  model = c("single", "hierarchical"),
  subject_col = NULL,
  trigger_failure = FALSE,
  n_quad = 100,
  chains = 4,
  iter = 2000,
  warmup = 1000,
  cores = 4,
  backend = "auto",
  adapt_delta = 0.95,
  stop_col = "vol",
  rt_col = "RT_exp",
  acc_col = "correct",
  ssd_col = "soa",
  seed = 42,
  ...
)

Value

An object of class ssrt_stan.

Arguments

data

data.frame in SSRTcalc long format.

model

"single" (default) or "hierarchical".

subject_col

Column with subject IDs (required for hierarchical).

trigger_failure

Logical: include trigger-failure parameter. Default FALSE.

n_quad

Quadrature resolution for P(inhibit) integral. Default 100.

chains

Number of MCMC chains. Default 4.

iter

Total iterations per chain including warmup. Default 2000.

warmup

Warmup iterations. Default 1000.

cores

Parallel cores. Default 4.

backend

"cmdstanr", "rstan", or "auto".

adapt_delta

HMC target acceptance rate. Increase to 0.99 if divergences appear. Default 0.95.

stop_col, rt_col, acc_col, ssd_col

Column names.

seed

Random seed. Default 42.

...

Additional arguments passed to the Stan sampler.

References

Matzke, D., et al. (2013). Bayesian parametric estimation of stop-signal reaction time distributions. Journal of Experimental Psychology: General, 142(4), 1047--1073.

Examples

Run this code
if (FALSE) {
data(adaptive)
d <- adaptive[adaptive$SubjID == 1, ]
fit <- ssrt_stan(d, chains = 4, iter = 2000)
print(fit)
plot(fit)

# Hierarchical
fit_h <- ssrt_stan(adaptive, model = "hierarchical",
                   subject_col = "SubjID", chains = 4)
ranef(fit_h)
}

Run the code above in your browser using DataLab