rlba_r | R Documentation |
Simulate Choices and Response Times
rlba_r(
parameter_r,
is_positive_drift_r,
time_parameter_r,
n = 1L,
use_inverse_method = FALSE,
debug = FALSE
)
rlba(
parameter_r,
is_positive_drift_r,
time_parameter_r,
n = 1L,
use_inverse_method = FALSE,
debug = FALSE,
seed = NULL
)
parameter_r |
A numeric matrix of LBA parameters. Each column corresponds to an accumulator, and each row corresponds to a parameter, with the expected order being:
|
is_positive_drift_r |
A logical vector indicating whether the
drift rate ( |
time_parameter_r |
A numeric vector to set the simulated time grid,
with the expected value for: minimal and maximum decision times and the
difference time (i.e., |
n |
Integer. Number of trials to simulate. Defaults to |
use_inverse_method |
Logical. If |
debug |
Logical. If |
seed |
Optional integer. If provided, sets the random seed for
reproducible simulation. Defaults to |
This function generates simulated data for the LBA model. The function supports both standard and inverse transform sampling methods. The inverse method may offer better numerical behaviour in edge cases (e.g., small RTs or boundary conditions).
A data.frame
. Each row corresponds to a simulated trial
containing:
trial
— Trial index
choice
— Index of the winning accumulator
rt
— Simulated response time
param_list2mat <- function(param_list) {
n_row <- length(param_list[[1]])
n_col <- length(param_list)
out <- matrix(NA, nrow = n_row, ncol = n_col)
for (i in seq_len(n_col)) {
out[, i] <- param_list[[i]]
}
t(out)
}
A <- 1.2
b <- 2.7
t0 <- .2
mean_v <- c(2.4, 2.2)
sd_v <- c(1, 1)
RT <- seq(0, 3, .4) + t0
posdrift <- TRUE
nv <- length(mean_v)
st0 <- 0
params_tmp <- list(
A = rep(A, nv),
b = rep(b, nv),
mean_v = mean_v,
sd_v = sd_v,
st0 = rep(st0, nv),
t0 = rep(t0, nv)
)
params <- param_list2mat(params_tmp)
is_positive_drift <- rep(TRUE, nv)
n <- 1
seed <- 123
dt <- 0.01
min_dt <- 0
max_dt <- 5
time_parameter_r <- c(min_dt, max_dt, dt)
set.seed(seed)
# R interface
result1 <- rlba(params, is_positive_drift, time_parameter_r, n,
seed = seed, debug = TRUE
)
# C++ interface. No seed argument.
result2 <- rlba_r(params, is_positive_drift, time_parameter_r, n,
debug = TRUE
)
print(result1)
print(result2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.