simulate_lba: Simulate Data from an LBA Model

simulate_lbaR Documentation

Simulate Data from an LBA Model

Description

Simulate response times and choices from a Linear Ballistic Accumulation (LBA) model with a model specification (typically from ggdmcModel::BuildModel).

Usage

## S4 method for signature 'lba'
simulate(
  object,
  nsim = 4L,
  seed = NULL,
  n_subject = 3L,
  parameter_vector = NULL,
  use_inverse_method = FALSE,
  debug = FALSE
)

Arguments

object

An object of class lba that defines the model structure and parameters.

nsim

Integer. Number of trials to simulate per subject. Defaults to 4.

seed

Optional integer. Sets the random seed for reproducibility. Defaults to NULL.

n_subject

Integer. Number of subjects to simulate. Defaults to 3.

parameter_vector

A named vector or list of parameters (e.g., A, b, mean_v.true, t0). Supply either parameter_vector here or a population distribution via setLBA (typically built with ggdmcPrior::BuildPrior). Defaults to NULL.

use_inverse_method

Logical. If TRUE, use inverse transform sampling; otherwise use the process model to sample. Defaults to FALSE.

debug

Logical. If TRUE, print debugging output during simulation. Defaults to FALSE.

Details

This method simulates data from a design-based LBA model. You can simulate multiple subjects, override default parameters, and choose between standard and inverse sampling methods. Turn on debugging mode by entering TRUE to the option, debug.

Value

A data frame with:

  • s (lowercase): subject identifiers (factor)

  • R (uppercase): choices (integer/character)

  • RT: response times (numeric)

Plus user-defined condition columns derived from the model

Notes

The internal mechanism is case sensitive. The choice of using upper- or lowercase letters to denote variables is a convention (originated from DMC), rather than a strict requirement.

See Also

simulate_lba_trials (low-level C++ back end), theoretical_dlba, plba, dlba

Other LBA simulation: validate_lba_parameters()

Examples

if (requireNamespace("ggdmcModel", quietly = TRUE)) {
  BuildModel <- getFromNamespace("BuildModel", "ggdmcModel")

  model <- BuildModel(
    p_map = list(
      A = "1", B = "1", t0 = "1", mean_v = "M", sd_v = "1",
      st0 = "1"
    ),
    match_map = list(M = list("s1" = "r1", "s2" = "r2")),
    factors = list(S = c("s1", "s2")),
    constants = c(sd_v = 1, st0 = 0),
    accumulators = c("r1", "r2"),
    type = "lba"
  )
}
p_vector <- c(
  A = .75, B = 1.25, mean_v.false = 1.5, mean_v.true = 2.5,
  t0 = 0.15
)
sub_model <- setLBA(model)
sim_dat <- simulate(sub_model,
  nsim = 256, parameter_vector = p_vector,
  n_subject = 1
)
head(sim_dat)


lbaModel documentation built on Sept. 15, 2025, 9:08 a.m.