| Version: | 2.0.0 |
| Date: | 2026-12-04 |
| Title: | Estimating Stop Signal Reaction Times and Stop Signal Delay |
| Description: | Helper functions for estimating the SSRT (stop signal reaction time) in a Stop-Signal Task based on Verbruggen et al. (2019) <doi:10.7554/eLife.46323> and a mid-run estimates method for computing the mean SSD (stop signal delay) based on Levitt (1971) <doi:10.1121/1.1912375>. |
| Maintainer: | Samuel Sonntag <samuel.sonntag@uni-tuebingen.de> |
| License: | MIT + file LICENSE |
| RoxygenNote: | 7.3.3 |
| Encoding: | UTF-8 |
| Depends: | R (≥ 4.1.0) |
| Imports: | cli, dplyr (≥ 1.1.0), utils, rlang, stats |
| URL: | https://github.com/sonntasa/sstFun |
| Suggests: | testthat (≥ 3.2.0) |
| Config/testthat/edition: | 3 |
| LazyData: | true |
| BugReports: | https://github.com/sonntasa/sstFun/issues |
| Language: | en-US |
| NeedsCompilation: | no |
| Packaged: | 2026-12-04 11:49:00 UTC; sonntaghimself |
| Author: | Samuel Sonntag |
| Repository: | CRAN |
| Date/Publication: | 2026-12-04 12:20:02 UTC |
Integration Method of computing the SSRT
Description
utilises the RT distribution of go trials in a Stop-Signal task to estimate the Stop-Signal Reaction Time using the distribution of go-trials (with replacement of go-omissions) and the probability of giving a response when a signal is present for each participant (see Verbruggen et al., 2019).
Usage
intSSRT(
dat,
participant = id,
trial_type = trial_type,
corr = corr,
ssd = ssd,
rt = rt,
replace_slow = TRUE,
rt_max = 600,
mid_run = FALSE,
return_full = FALSE,
trial_labels = c(stop = "stop", go = "go")
)
Arguments
dat |
a dataframe with one row per trial, containing id, trial_type, a correct code, the SSD per trial and the RT. |
participant |
column containing the personal identifier. |
trial_type |
column containing the trial type ("go" vs. "stop"). |
corr |
boolean that reflects whether the current trial is Correct (e.g. whether they correctly responded to go trials and omitted responses on stop trials.) |
ssd |
column containing the SSD. |
rt |
column containing the reaction times. |
replace_slow |
logical; if |
rt_max |
a single number (in ms). Go RTs slower than this value count
as slow and are replaced when |
mid_run |
logical; if TRUE, the mid-run SSD estimate is used to estimate the SSRT, otherwise the mean SSD. |
return_full |
logical; if TRUE, the full data set is returned (e.g. for diagnostic purposes). Otherwise only participant id and SSRT are returned. |
trial_labels |
named character vector with elements go and stop |
Value
a dataframe containing the id and an estimate of the SSRT. If return_full is set: the mean Stop Signal delay, the p(response | signal), (the mid-run estimate of the SSD, the number of runs that went into the estimation of the SSD) and the estimated SSRT.
Examples
set.seed(1)
dat <- data.frame(
id = 1,
trial_type = rep(c("go", "stop"), c(60, 20)),
corr = c(rep(TRUE, 60), rep(c(TRUE, FALSE), 10)),
ssd = c(rep(NA, 60), rep(c(100, 150, 200, 150), 5)),
rt = c(round(rnorm(60, 500, 80)), rep(NA, 20))
)
intSSRT(dat,
participant = id, trial_type = trial_type, corr = corr,
ssd = ssd, rt = rt, mid_run = FALSE
)
Mean Estimation of the SSRT
Description
Estimates the SSRT with the mean method: mean go RT minus the mean SSD. This assumes that p(response | signal) = 0.5.
Usage
meanSSRT(
dat,
participant = id,
trial_type = trial_type,
corr = corr,
ssd = ssd,
rt = rt,
rt_max = 600,
replace_slow = TRUE,
err_exc = FALSE,
mid_run = FALSE,
return_full = FALSE,
trial_labels = c(stop = "stop", go = "go")
)
Arguments
dat |
a dataframe with one row per trial, containing id, trial_type, a correct code, the SSD per trial and the RT. |
participant |
column containing the personal identifier. |
trial_type |
column containing the trial type ("go" vs. "stop"). |
corr |
boolean that reflects whether the current trial is Correct (e.g. whether they correctly responded to go trials and omitted responses on stop trials.) |
ssd |
column containing the SSD. |
rt |
column containing the reaction times. |
rt_max |
a single number (in ms). Go RTs slower than this value count
as slow and are replaced when |
replace_slow |
logical; if |
err_exc |
logical; if TRUE, incorrect trials are excluded from the analysis |
mid_run |
logical; if TRUE, the mid-run SSD estimate is used to estimate the SSRT, otherwise the mean SSD. |
return_full |
logical; if TRUE, the full data set is returned (e.g. for diagnostic purposes). Otherwise only participant id and SSRT are returned. |
trial_labels |
named character vector with elements go and stop |
Value
a dataframe with one row per participant, containing the participant id and the SSRT. If return_full is set, the full data frame is returned.
Examples
set.seed(1)
dat <- data.frame(
id = 1,
trial_type = rep(c("go", "stop"), c(60, 20)),
corr = c(rep(TRUE, 60), rep(c(TRUE, FALSE), 10)),
ssd = c(rep(NA, 60), rep(c(100, 150, 200, 150), 5)),
rt = c(round(rnorm(60, 500, 80)), rep(NA, 20))
)
meanSSRT(dat,
participant = id, trial_type = trial_type, corr = corr,
ssd = ssd, rt = rt
)
Median Method of computing the SSRT
Description
estimates the SSRT using the median go RT and the mid-run estimate of the SSD
Usage
medSSRT(
dat,
participant = id,
trial_type = trial_type,
corr = corr,
ssd = ssd,
rt = rt,
replace_slow = TRUE,
rt_max = 600,
mid_run = TRUE,
return_full = FALSE,
trial_labels = c(stop = "stop", go = "go")
)
Arguments
dat |
a dataframe with one row per trial, containing id, trial_type, a correct code, the SSD per trial and the RT. |
participant |
column containing the personal identifier. |
trial_type |
column containing the trial type ("go" vs. "stop"). |
corr |
boolean that reflects whether the current trial is Correct (e.g. whether they correctly responded to go trials and omitted responses on stop trials.) |
ssd |
column containing the SSD. |
rt |
column containing the reaction times. |
replace_slow |
logical; if |
rt_max |
a single number (in ms). Go RTs slower than this value count
as slow and are replaced when |
mid_run |
logical; if TRUE, the mid-run SSD estimate is used to estimate the SSRT, otherwise the mean SSD. |
return_full |
logical; if TRUE, the full data set is returned (e.g. for diagnostic purposes). Otherwise only participant id and SSRT are returned. |
trial_labels |
named character vector with elements go and stop |
Value
a dataframe containing the id, an estimate of the SSRT. If return_full is set: the median RT, used to compute the SSRT, the mean Stop Signal delay, the p(response | signal), the mid-run estimate of the SSD, the number of runs that went into the estimation of the SSD and the estimated SSRT.
Examples
set.seed(1)
dat <- data.frame(
id = 1,
trial_type = rep(c("go", "stop"), c(60, 20)),
corr = c(rep(TRUE, 60), rep(c(TRUE, FALSE), 10)),
ssd = c(rep(NA, 60), rep(c(100, 150, 200, 150), 5)),
rt = c(round(rnorm(60, 500, 80)), rep(NA, 20))
)
medSSRT(dat,
participant = id, trial_type = trial_type, corr = corr,
ssd = ssd, rt = rt
)
mid-run average estimation of the SSD
Description
Estimates the SSD with the mid-run estimates method (Levitt, 1971; Wetherill & Levitt, 1965). To this end, the average mid-point of every second run is used (per participant) to compute the average SSD.
Usage
mid_run_avg(
dat,
participant = id,
trial_type = trial_type,
ssd = ssd,
trial_labels = c(stop = "stop", go = "go"),
every_second = TRUE,
return_full = FALSE
)
Arguments
dat |
a dataframe containing id, ssd, trial_type |
participant |
Name of the column containing the participant identifier. |
trial_type |
the column that reflects the current trial type (stop vs. go) |
ssd |
Name of the column containing the current stop signal delay |
trial_labels |
prevents silent failing, coding of stop and go trials |
every_second |
boolean use every second run or use all (full) runs |
return_full |
boolean if TRUE, the full data set is returned. |
Value
returns a mid-run estimate (of the SSD) for each participant. If return_full is set: a dataframe containing an estimate of the SSD and the number of runs used to calculate the SSD
Examples
dat <- data.frame(
id = 1,
trial_type = rep(c(rep("stop", 5), "go"), 10),
ssd = rep(c(100, 150, 200, 150, 100, 100), 10)
)
mid_run_avg(dat, participant = id, trial_type = trial_type, ssd = ssd)
mid_run_avg(dat, participant = id, trial_type = trial_type, ssd = ssd, every_second = FALSE)
Simulated stop-signal task data
Description
Trial-level data from 12 simulated participants, each with one
block of 480 trials (360 go, 120 stop) and one continuous stop-signal delay
(SSD) tracking staircase. The column names match the defaults of
meanSSRT(), intSSRT(), medSSRT() and mid_run_avg(), so the
estimators can be called directly on the data.
Besides the observed data, the simulated latent variables are included
(go_rt and ssrt_true). They are not available in real data, but allow
the accuracy of the estimators to be investigated at the level of
participants and trials.
Usage
sst_example
Format
A data frame with 5760 rows and 8 variables. The first six columns
are observed data. go_rt and ssrt_true are latent simulation variables
that cannot be observed in real data.
- id
participant identifier (integer, 1 to 12).
- trl
trial number within participant. Rows are in trial order, which
mid_run_avg()relies on.- trial_type
"go"or"stop".- ssd
stop-signal delay in ms;
NAon go trials.- rt
reaction time in ms, rounded;
NAfor go omissions and for successful stops.- corr
logical. On go trials
TRUEif the participant responded (FALSEis an omission). On stop trialsTRUEif the response was successfully inhibited, soFALSEmeans the participant responded.- go_rt
latent. Go finishing time in ms (unrounded), drawn on every trial. Equals
rtbefore rounding whenever a response occurred.- ssrt_true
latent. Stop latency in ms, drawn on every trial; only relevant on stop trials.
Details
The data come from an independent race model. On every trial a go RT and a stop latency are drawn; the participant responds if the go process finishes first. On go trials only the go process runs, and an omission occurs with probability .01.
All participants share the same parameters:
Go RT: ex-Gaussian with mu = 350 ms, sigma = 40 ms and tau = 70 ms (mean 420 ms). The right skew means that a small share of go RTs is slower than the default
rt_maxof the estimators.Stop latency: normal with a mean of 220 ms and an SD of 30 ms, so the true mean SSRT is 220 ms for every participant.
Staircase: starts at 150 ms, moves up by 50 ms after a successful stop and down by 50 ms after a failed stop, bounded between 0 and 600 ms. It therefore converges towards p(respond | signal) of about .5.
Latent versus observed variables. go_rt is the latent go finishing
time on every trial, including trials without a response: inhibited stop
trials and go omissions. It is not an observed RT and should never be passed
as rt to an estimator, since this would give inhibited trials an RT and
hide the omissions. The observed RT is rt, which equals the rounded
go_rt if the participant responded and is NA otherwise. Likewise,
ssrt_true is the latent stop latency of each trial. It is drawn for go
trials too, but only matters on stop trials.
A target for the estimators. Because the stop latencies of the sample
vary, the mean of ssrt_true over a participant's stop trials differs
somewhat from the generating value of 220 ms. This realised mean is the
more appropriate benchmark when evaluating the estimate of one participant;
see the examples.
Source
Simulated; see https://github.com/sonntasa/sstFun/blob/main/data-raw/sst_example.R
See Also
meanSSRT(), intSSRT(), medSSRT(), mid_run_avg()
Examples
head(sst_example)
# estimates per participant
meanSSRT(sst_example)
intSSRT(sst_example, return_full = TRUE)
# compare with the realised mean stop latency of each participant
truth <- aggregate(
ssrt_true ~ id,
data = subset(sst_example, trial_type == "stop"),
FUN = mean
)
merge(intSSRT(sst_example), truth, by = "id")