Learn R Programming

eam

eam is a simulation-based evidence accumulation models for analyzing responses and reaction times in single- and multi-response tasks. The package includes simulation engines for five representative models: the Diffusion Decision Model (DDM), Leaky Competing Accumulator (LCA), Linear Ballistic Accumulator (LBA), Racing Diffusion Model (RDM), and Lévy Flight Model (LFM), and extends these frameworks to multi-response settings.

The package supports user-defined functions for item-level parameterization and the incorporation of covariates, enabling flexible customization and the development of new model variants based on existing architectures. Inference is performed using simulation-based methods, including Approximate Bayesian Computation (ABC) and Amortized Bayesian Inference (ABI), which allow parameter estimation without requiring tractable likelihood functions.

In addition to core inference tools, the package provides modules for parameter recovery, posterior predictive checks, and model comparison. Overall, it facilitates the study of a wide range of cognitive processes in tasks involving perceptual decision making, memory retrieval, and value-based decision making.

Features

  • ⚙️ High-Performance Backend
    • Pure C++ core with fast vectorization-friendly algorithms designed. 100x speedup compared with naive python implementations.
    • Memory-efficient computation, enabling more than 10 million trials on a standard desktop machine.
    • Parallel execution with near-linear speed-up across multiple CPU cores.

Copy Link

Version

Install

install.packages('eam')

Version

1.0.1

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Guang Yang

Last Published

January 17th, 2026

Functions in eam (1.0.1)

get_column_names

Extract column names from simulation results
map_by_condition.process_chunk

Process a single chunk for map_by_condition
route_model_to_backend

Route model alias to backend and enrich configuration
plot_cv_recovery

Plot CV parameter recovery
resolve_symbol

Helper to resolved defined symbols in our formulas
plot_cv_pair_correlation

Plot CV parameter pair correlations
plot_resample_medians

Plot resample median distributions
summarise_by

Summarise data by groups with optional pivoting
new_simulation_config.chunk_size.heuristic

Heuristic to calculate optimal chunk size for simulation configuration
plot_rt

Plot reaction time distributions
new_simulation_output

Create a eam_simulation_output object
run_simulation_serial

Run a full simulation across multiple conditions (serial version)
run_trial_ddm

Run a single trial of the DDM simulation
run_trial_lca_gi

Run a single trial of the LCA-GI simulation
summarise_by_impl

Internal function to perform the core summarise_by logic
run_trial_ddm_2b

Run a single trial of the 2-boundary DDM simulation
plot_resample_forest

Plot resample forest plots
new_simulation_config

Create a new simulation configuration
plot_posterior_parameters

Plot parameter posterior distributions
detect_backend_lca_gi

Backend detector for LCA-GI
get_config_env_names

Extract all left-hand side variable names from config formulas and prior_params
plot_accuracy

Plot accuracy comparison between posterior and observed data
plot_accuracy_ddm

Plot accuracy for DDM model (internal)
+.eam_summarise_by_tbl

Join two eam_summarise_by_tbl objects
+.eam_summarise_by_spec

Add two summarise_by specs together
preallocate_columns

Pre-allocate data.table columns with appropriate data types
init_simulation_output_dir

Initialize simulation output directory structure
print.eam_simulation_config

Print method for eam simulation configuration
run_chunk

Run a chunk of simulation conditions and save results to disk
run_condition

Run a given condition with multiple trials
summarise_resample_medians

Summarise resample medians
load_simulation_output

Rebuild eam_simulation_output from an existing output directory
plot_accuracy_ddm_2b

Plot accuracy for DDM-2B model (internal)
run_simulation

Run a simulation with specified configuration
summarise_posterior_parameters

Summarise posterior parameter distributions
plot_accuracy_graph

Plot accuracy graph (internal)
run_simulation_parallel

Run a full simulation across multiple conditions in parallel
abc_posterior_bootstrap

Bootstrap resample ABC posterior samples
abc_resample

ABC with resampling
accumulate_evidence_ddm

Simulate evidence accumulation in a drift-diffusion model
build_abc_input

Build input for Approximate Bayesian Computation (ABC)
abc_postpr

ABC model comparison wrapper
get_backend_detectors

Get all registered backend detectors
detect_backend_ddm

Backend detector for standard DDM
apply_summarise_by_spec

Internal function to apply a spec to data
accumulate_evidence_ddm_2b

Simulate evidence accumulation in a two-bound drift-diffusion model
accumulate_evidence_lca_gi

Simulate evidence accumulation in a leaky competing accumulator model with Global Inhibition (LCA-GI)
calculate_total_rows

Calculate total number of rows needed for flattened data
flatten_simulation_results

Convert simulation results to a tidy data.table
detect_backend_ddm_2b

Backend detector for 2-boundary DDM
map_by_condition

Map a function by condition across simulation output chunks
map_by_condition.parallel.heuristic

Heuristic to determine if parallel processing should be used
extract_abc_param_values

Extract parameter values from abc result
evaluate_with_dt

Evaluate a list of formulas sequentially with data
fill_data_table

Fill pre-allocated data.table with simulation results
extract_resample_medians

Extract posterior medians from abc_resample output