Package: EMC2 3.4.1

Niek Stevenson

EMC2: Bayesian Hierarchical Analysis of Cognitive Models of Choice

Fit Bayesian (hierarchical) cognitive models using a linear modeling language interface using particle Metropolis Markov chain Monte Carlo sampling with Gibbs steps. The diffusion decision model (DDM), linear ballistic accumulator model (LBA), racing diffusion model (RDM), and the lognormal race model (LNR) are supported. Additionally, users can specify their own likelihood function and/or choose for non-hierarchical estimation, as well as for a diagonal, blocked or full multivariate normal group-level distribution to test individual differences. Prior specification is facilitated through methods that visualize the (implied) prior. A wide range of plotting functions assist in assessing model convergence and posterior inference. Models can be easily evaluated using functions that plot posterior predictions or using relative model comparison metrics such as information criteria or Bayes factors. References: Stevenson et al. (2024) <doi:10.31234/osf.io/2e4dq>.

Authors:Niek Stevenson [aut, cre], Michelle Donzallaz [aut], Andrew Heathcote [aut], Steven Miletić [aut], Luke Strickland [ctb], Frank Hezemans [ctb], Raphael Hartmann [ctb], Karl C. Klauer [ctb], Steven G. Johnson [ctb], Jean M. Linhart [ctb], Brian Gough [ctb], Gerard Jungman [ctb], Rudolf Schuerer [ctb], Przemyslaw Sliwa [ctb], Jason H. Stover [ctb]

EMC2_3.4.1.tar.gz
EMC2_3.4.1.zip(r-4.7)EMC2_3.4.1.zip(r-4.6)EMC2_3.4.1.zip(r-4.5)
EMC2_3.4.1.tgz(r-4.6-x86_64)EMC2_3.4.1.tgz(r-4.6-arm64)EMC2_3.4.1.tgz(r-4.5-x86_64)EMC2_3.4.1.tgz(r-4.5-arm64)
EMC2_3.4.1.tar.gz(r-4.7-arm64)EMC2_3.4.1.tar.gz(r-4.7-x86_64)EMC2_3.4.1.tar.gz(r-4.6-arm64)EMC2_3.4.1.tar.gz(r-4.6-x86_64)
EMC2_3.4.1.tgz(r-4.6-emscripten)
manual.pdf |manual.html
DESCRIPTION |NEWS
card.svg |card.png
EMC2/json (API)

# Install 'EMC2' in R:
install.packages('EMC2', repos = c('https://ampl-psych.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/ampl-psych/emc2/issues

Pkgdown/docs site:https://ampl-psych.github.io

Uses libs:
  • c++– GNU Standard C++ Library v3
Datasets:

On CRAN:

Conda:

cpp

9.46 score 40 stars 412 scripts 621 downloads 81 exports 33 dependencies

Last updated from:1887e45a62. Checks:13 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-arm64OK258
linux-devel-x86_64OK263
source / vignettesOK310
linux-release-arm64OK257
linux-release-x86_64OK257
macos-release-arm64OK250
macos-release-x86_64OK602
macos-oldrel-arm64OK187
macos-oldrel-x86_64OK325
windows-develOK268
windows-releaseOK272
windows-oldrelOK264
wasm-releaseOK192

Exports:align_loadingsapply_kernelauto_thinchain_ncheckcomparecompare_subjectcontr.anovacontr.bayescontr.decreasingcontr.increasingconvolve_design_matrixcrediblecredintcut_factorsDDMDDMGNGdesigndesign_fmriess_summaryfitfix_custom_kernel_pointersgd_summaryget_BayesFactorget_dataget_designget_group_designget_parsget_power_spectraget_priorget_trend_pnamesgroup_designhigh_pass_filterhypothesisinit_chainsLBALNRmake_datamake_emcmake_random_effectsmake_SEM_diagrammake_sem_structuremake_trendmapped_parsmerge_chainsmodel_averagingMRIMRI_AR1pairs_posteriorparametersplot_cafplot_cdfplot_deltaplot_densityplot_designplot_design_fmriplot_fmriplot_parsplot_relationsplot_sbc_ecdfplot_sbc_histplot_spectrumplot_statplot_trendpriorprior_helpprofile_plotRDMrecoveryregister_trendreshape_eventsrotate_loadingsrun_bridge_samplingrun_emcrun_hyperrun_sbcsampled_parsSDTsplit_timeseriestrend_helpupdate2version

Dependencies:abindBrobdingnagclicodacolorspacecorrplotexpmgenericsglueGPArotationlatticelifecyclelpSolvemagicmagrittrMASSMatrixmatrixcalcmnormtmsmmvtnormnlmepillarpkgconfigpsychRcppRcppArmadillorlangsurvivaltibbleutf8vctrsWienR

Race Models
Introduction | 1. Specify a Race-Model Design | 2. Inspect Parameters and Mapping | 3. Simulate Data | 4. Set Prior and Build EMC Object | 5. Fit | 6. Summarize and Check Model Fit

Last update: 2026-02-26
Started: 2026-02-26

Diffusion Decision Model (DDM)
Introduction | 1. Specify a DDM Design | 2. Inspect Parameters and Mapping | 3. Simulate Data | 4. Set Prior and Build EMC Object | 5. Fit | 6. Summarize and Check Model Fit

Last update: 2026-02-26
Started: 2026-02-26

Simulation-based Calibration
Introduction | How to SBC | 1. Specify the Probabilistic Model | 2. Simulate Parameters and Data | 3. Compute Posterior Distributions | 4. Evaluate the Rank Statistics | 5. Check Uniformity | Non-hierarchical SBC in EMC2 | Compression | LBA | DDM | Hierarchical SBC | Prior structure | RDM | LNR

Last update: 2026-02-26
Started: 2024-10-14

Trends
Introduction | Trend Composition | Quick Start: From trend to model | Defining a Trend | Available Kernel Types | Linear Trends | Exponential Trends | Power Trends | Polynomial Trends | Learning Rule Trends | Multiple Trends | Sharing Parameters | Phases | Parameter Inputs (par_input) | Apply a trend only at a factor level (at) | Multiple contributions to the same parameter | Phase per trend entry | Sharing kernel parameters (not only base weights) | Missing input values (NA handling) | Trial‑wise evaluation and conditional covariates | Vary trend parameters via the design formula | Custom C++ Trends | Tips for Choosing Trends | Interpreting Bases and Transforms

Last update: 2025-12-24
Started: 2025-05-16

Readme and manuals

Help Manual

Help pageTopics
Reorder MCMC Samples of Factor Loadingsalign_loadings
Apply a kernel implied in an emc objectapply_kernel
Automatically Thin an emc Objectauto_thin auto_thin.emc
MCMC Chain Iterationschain_n
Convergence Checks for an emc Objectcheck check.emc
Information Criteria and Marginal Likelihoodscompare
Information Criteria For Each Participantcompare_subject
Anova Style Contrast Matrixcontr.anova
Contrast Enforcing Equal Prior Variance on each Levelcontr.bayes
Contrast Enforcing Decreasing Estimatescontr.decreasing
Contrast Enforcing Increasing Estimatescontr.increasing
Convolve Events with HRF to Construct Design Matricesconvolve_design_matrix
Posterior Credible Interval Testscredible credible.emc
Posterior Quantilescredint credint.emc credint.emc.prior
Cut Factors Based on Credible Loadingscut_factors
The Diffusion Decision ModelDDM
The GNG (go/nogo) Diffusion Decision ModelDDMGNG
Specify a Design and Modeldesign
Create fMRI Design for EMC2 Samplingdesign_fmri
Effective Sample Sizeess_summary ess_summary.emc
Factor diagram plot #Makes a factor diagram plot. Heavily based on the fa.diagram function of the 'psych' package.factor_diagram
Model Estimation in EMC2fit fit.emc
Reset pointers of custom C++ trend kernels to an emc objectfix_custom_kernel_pointers
Forstmann et al.'s Dataforstmann
Gelman-Rubin Statisticgd_summary gd_summary.emc
Bayes Factorsget_BayesFactor
Extract pointers of custom C++ trend kernels from trend list or emc objectget_custom_kernel_pointers
Get Dataget_data get_data.emc
Get Designget_design get_design.emc get_design.emc.prior
Get Group Designget_group_design get_group_design.emc get_group_design.emc.prior
Filter/Manipulate Parameters from emc Objectget_pars
Compute Power Spectra With Optional Subject-Level Aggregationget_power_spectra
Get Priorget_prior get_prior.emc
Get parameter types from trend objectget_trend_pnames
Create Group-Level Design Matricesgroup_design
Apply High-Pass Filtering to fMRI Datahigh_pass_filter
Within-Model Hypothesis Testinghypothesis hypothesis.emc
Initialize Chainsinit_chains
The Linear Ballistic Accumulator modelLBA
The Log-Normal Race ModelLNR
Simulate Datamake_data
Make an emc Objectmake_emc
Generate Subject-Level Parametersmake_random_effects
Make SEM Diagrammake_SEM_diagram
Define Structural Equation Model (SEM) Matricesmake_sem_structure
Create a trend specification for model parametersmake_trend
Parameter Mapping Back to the Design Factorsmapped_pars mapped_pars.emc mapped_pars.emc.design mapped_pars.emc.prior
Merge Samplesmerge_chains
Model Averagingmodel_averaging
GLM model for fMRI dataMRI
Create an AR(1) GLM model for fMRI dataMRI_AR1
Plot Within-Chain Correlationspairs_posterior
Return Data Frame of Parametersparameters parameters.emc parameters.emc.prior
Plot conditional accuracy functionsplot_caf
Plot Defective Cumulative Distribution Functionsplot_cdf
Plot Difference of Cumulative Distribution Functionsplot_delta
Plot Defective Densitiesplot_density
Plot fMRI Design Matrixplot_design_fmri
Plot Designplot_design plot_design.emc plot_design.emc.design plot_design.emc.prior
Plot fMRI peri-stimulus time coursesplot_fmri
Plots Density for Parametersplot_pars
Plot Group-Level Relationsplot_relations
Plot the ECDF Difference in SBC Ranksplot_sbc_ecdf
Plot the Histogram of the Observed Rank Statistics of SBCplot_sbc_hist
Plot Empirical and Posterior Predictive Power Spectraplot_spectrum
Plot Statistics on Dataplot_stat
Plots trends over timeplot_trend
Plot Function for emc Objectsplot.emc
Plot method for emc.design objectsplot.emc.design
Plot a priorplot.emc.prior
Generate Posterior/Prior Predictivespredict.emc predict.emc.prior
Specify Priors for the Chosen Modelprior
Prior Specification Informationprior_help
Likelihood Profile Plotsprofile_plot
The Racing Diffusion ModelRDM
Recovery Plotsrecovery recovery.emc
Register a custom C++ trend kernelregister_trend
Reshape events data for fMRI analysisreshape_events
Rotate loadings based on posterior medianrotate_loadings
Estimating Marginal Likelihoods Using WARP-III Bridge Samplingrun_bridge_sampling
Fine-Tuned Model Estimationrun_emc
Run a Group-level Model.run_hyper
Simulation-Based Calibrationrun_sbc
Get Model Parameters from a Designsampled_pars sampled_pars.emc sampled_pars.emc.design sampled_pars.emc.group_design sampled_pars.emc.prior
LNR Model of Forstmann Data (First 3 Subjects)samples_LNR
Gaussian Signal Detection Theory Model for Binary ResponsesSDT
(Re-)Set pointers of custom C++ trend kernels to an emc objectset_custom_kernel_pointers
Split fMRI Timeseries Data by ROI Columnssplit_timeseries
Shorten an emc Objectsubset.emc
Summary Statistics for emc Objectssummary.emc
Summary method for emc.design objectssummary.emc.design
Summary method for emc.group_design objectssummary.emc.group_design
Summary method for emc.prior objectssummary.emc.prior
Get help information for trend kernels and basestrend_help
Update EMC Objects to the Current Versionupdate2version