MyNixOS website logo
Description

Monte Carlo and Bayesian Stop-Signal Reaction Time Estimation.

Estimates stop-signal reaction time (SSRT) in the stop-signal task using the integration and mean methods described by Verbruggen and colleagues (2019) <doi:10.7554/eLife.46323>. In addition to point estimates, the package provides Monte Carlo tools (nonparametric bootstrap confidence intervals, parametric ex-Gaussian simulation, minimum-trial-count and power analysis, and sensitivity analysis under violations of the horse-race assumptions) and Bayesian estimation via 'Stan', including single-subject and hierarchical ex-Gaussian horse-race models with an optional trigger-failure parameter following Matzke and colleagues (2013) <doi:10.1037/a0030543>, posterior inhibition functions, and posterior predictive checks. The Bayesian layer works with either the 'cmdstanr' or 'rstan' backend.

SSRTcalc

Tools to estimate stop-signal reaction time (SSRT) in R, following the consensus guidance of Verbruggen et al. (2019, eLife).

Version 2.1.0 adds three major extensions on top of the original point estimators:

  1. Monte Carlo methods -- bootstrap confidence intervals, parametric ex-Gaussian simulation, minimum-trial-count / power analysis, and robustness checks under violations of the horse-race assumptions.
  2. Bayesian estimation via Stan -- single-subject and hierarchical ex-Gaussian horse-race models, an optional trigger-failure parameter (Matzke et al., 2013), posterior inhibition functions, and posterior predictive checks.
  3. Convenience wrappers for running a full battery of analyses (run_all_mc()) or comparing models (ssrt_stan_compare()) in one call.

Installation

install.packages("devtools")
devtools::install_github("agleontyev/SSRTcalc")
#Alternative
pak::pkg_install("agleontyev/SSRTcalc")

The Monte Carlo functions only need base R (plus MASS, used automatically if available). The Bayesian functions additionally need one of:

# Recommended
install.packages("cmdstanr",
  repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
cmdstanr::install_cmdstan()

# Alternative
install.packages("rstan")

Quick start

library(SSRTcalc)
data(adaptive)
d <- adaptive[adaptive$SubjID == 1, ]

# Point estimates
integration_adaptiveSSD(d)
mean_adaptiveSSD(d)

Monte Carlo extensions

# Bootstrap confidence interval
b <- ssrt_boot(d, n_iter = 2000)
print(b)
plot(b)

# Parametric ex-Gaussian simulation
s <- ssrt_simulate(d, n_iter = 2000)
print(s)

# How many stop trials do you need?
p <- ssrt_power(d, trial_counts = c(10, 20, 30, 50, 100), n_iter = 500)
print(p)
plot(p)

# Sensitivity to assumption violations
r <- ssrt_robustness(d, violation = "trigger_failure", n_iter = 500)
print(r)
plot(r)

# Or run all four at once
res <- run_all_mc(d, n_iter = 1000)

Bayesian estimation via Stan

# Single subject
fit <- ssrt_stan(d, chains = 4, iter = 2000)
print(fit)
plot(fit)

ssrt_stan_pp_check(fit)
ssrt_stan_inhibition_fn(fit)

# With a trigger-failure parameter (Matzke et al., 2013)
fit_tf <- ssrt_stan(d, trigger_failure = TRUE, adapt_delta = 0.99)

# Compare the base and trigger-failure models
cmp <- ssrt_stan_compare(d, chains = 4, iter = 2000)
cmp$comparison

# Hierarchical model across all subjects
fit_h <- ssrt_stan(adaptive, model = "hierarchical",
                    subject_col = "SubjID", chains = 4, cores = 4)
ranef(fit_h)
plot(fit_h)

Data format

All functions expect one row per trial, with these default columns (configurable via stop_col, rt_col, acc_col, ssd_col):

ColumnMeaning
vol0 = go trial, 1 = stop trial
RT_expReaction time (ms); NA if the stop trial was inhibited
correctAccuracy (1 = correct / successful inhibition)
soaStop-signal delay (ms); NA on go trials

Two datasets are bundled: adaptive (20 subjects x 200 trials, a staircase/adaptive-SSD design) and fixed (50 subjects, ~576 trials each, a fixed-SSD motion-discrimination task). Both follow the format above and are used throughout the documentation examples.

References

Verbruggen, F., Aron, A. R., Band, G. P. H., Beste, C., Bissett, P. G., Brockett, A. T., ... Boehler, C. N. (2019). A consensus guide to capturing the ability to inhibit actions and impulses: the stop-signal task. eLife, 8, e46323. https://doi.org/10.7554/eLife.46323

Matzke, D., Dolan, C. V., Logan, G. D., Brown, S. D., & Wagenmakers, E.-J. (2013). Bayesian parametric estimation of stop-signal reaction time distributions. Journal of Experimental Psychology: General, 142(4), 1047-1073. https://doi.org/10.1037/a0030543

License

GPL-3

Metadata

Version

2.1.1

License

Unknown

Platforms (79)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    wasip1
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arc-linux
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • sh4-linux
  • vc4-none
  • wasm32-wasip1
  • wasm64-wasip1
  • x86_64-cygwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows