Unlimited learning, half price | 50% off

Last chance! 50% off unlimited learning

Sale ends in


⚠️There's a newer version (3.1.1) of this package.Take me there.

EMC2: Extended Models of Choice 2:

The R package EMC2 provides tools to perform Bayesian hierarchical analyses of the following cognitive models: Diffusion Decision Model (DDM), Linear Ballistic Accumulator Model (LBA), Racing Diffusion Model (RDM), and Lognormal Racing Model (LNR). Specifically, the package provides functionality for specifying individual model designs, estimating the models, examining convergence as well as model fit through posterior prediction methods. It also includes various plotting functions and relative model comparison methods such as Bayes factors. In addition, users can specify their own likelihood function and perform non-hierarchical estimation. The package uses particle metropolis Markov chain Monte Carlo sampling. For hierarchical models, it uses efficient Gibbs sampling at the population level and supports a variety of covariance structures, extending the work of Gunawan and colleagues (2020).

Installation

To install the R package, and its dependencies you can use:

remotes::install_github("ampl-psych/EMC2",dependencies=TRUE)

Workflow Overview

Pictured below are the four phases of an EMC2cognitive model analysis with associated functions (in courier font).

 

 

For details, please see:

Stevenson, N., Donzallaz, M. C., Innes, R. J., Forstmann, B., Matzke, D., & Heathcote, A. (2024, January 30). EMC2: An R Package for cognitive models of choice. https://doi.org/10.31234/osf.io/2e4dq

Bug Reports, Contributing, and Feature Requests

If you come across any bugs, or have ideas for extensions of EMC2, you can add them as an issue here. If you would like to contribute to the package's code, please submit a pull request.

References

Stevenson, N., Donzallaz, M. C., Innes, R. J., Forstmann, B., Matzke, D., & Heathcote, A. (2024, January 30). EMC2: An R Package for cognitive models of choice. https://doi.org/10.31234/osf.io/2e4dq

Gunawan, D., Hawkins, G. E., Tran, M. N., Kohn, R., & Brown, S. D. (2020). New estimation approaches for the hierarchical Linear Ballistic Accumulator model. Journal of Mathematical Psychology, 96, 102368. https://doi.org/10.1016/j.jmp.2020.102368

Copy Link

Version

Install

install.packages('EMC2')

Monthly Downloads

389

Version

2.0.2

License

GPL (>= 3)

Maintainer

Niek Stevenson

Last Published

September 10th, 2024

Functions in EMC2 (2.0.2)

compare_MLL

Calculate a table of model probabilities based for a list of samples objects based on samples of marginal log-likelihood (MLL) added to these objects by run_IS2. Probabilities estimated by a bootstrap ath picks a vector of MLLs, one for each model in the list randomly with replacement nboot times, calculates model probabilities and averages
LBA

The Linear Ballistic Accumulator model
auto_burn

Runs burn-in for emc.
compare_subject

Information criteria for each participant
forstmann

Forstmann et al.'s data
gd_summary.emc

Gelman-Rubin statistic
contr.anova

Anova style contrast matrix
LNR

The Log-Normal Race Model
contr.bayes

Contrast to enforce equal prior variance on each level
make_missing

make_missing
EMC2-package

EMC2: Bayesian Hierarchical Analysis of Cognitive Models of Choice
RDM

The Racing Diffusion Model
add_constants

Augments parameter matrix or vector p with constant parameters (also used in data)
get_BayesFactor

Bayes Factors
get_prior_blocked

Prior specification or prior sampling for blocked estimation
get_data.emc

Get data
make_random_effects

Make random effects
probit

Gaussian Signal Detection Theory Model
chain_n

chain_n()
get_prior_standard

Prior specification or prior sampling for standard estimation.
get_prior_diag

Prior specification or prior sampling for diagonal estimation
hypothesis.emc

Within-model hypothesis testing
init_chains

Initialize chains
plot.emc

Plot function for emc objects
credible.emc

Posterior credible interval tests
IC

Calculate information criteria (DIC, BPIC), effective number of parameters and constituent posterior deviance (D) summaries (meanD = mean of D, Dmean = D for mean of posterior parameters and minD = minimum of D).
plot_defective_density

Plot defective densities for each subject and cell
run_emc

Custom function for more controlled model estimation
run_sample

Runs sample stage for emc.
make_data

Simulate data
contr.increasing

Contrast to enforce increasing estimates
contr.decreasing

Contrast to enforce decreasing estimates
pairs_posterior

Plot within-chain correlations
parameters.emc

Returns a parameter type from an emc object as a data frame.
profile_plot

Likelihood profile plots
DDMt0natural

Diffusion decision model with t0 on the natural scale
DDM

The Diffusion Decision Model
design

Specify a design and model
ess_summary.emc

Effective sample size
fit.emc

Model estimation in EMC2
check.emc

Convergence checks for an emc object
get_prior_SEM

Prior specification or prior sampling for SEM estimation.
get_pars

Filter/manipulate parameters from emc object
compare

Information criteria and marginal likelihoods
plot_mcmc

Plot MCMC
get_prior_factor

Prior specification and prior sampling for factor estimation
plot_mcmc_list

Plot MCMC.list
posterior_summary.emc

Posterior quantiles
plot_relations

Plot relations
get_prior_single

Prior specification or prior sampling for single subject estimation
plot_pars

Plots density for parameters
standardize_loadings

Standardized factor loadings
make_emc

Make an emc object
plot_prior

Title
subset.emc

Shorten an emc object
summary.emc

Summary statistics for emc objects
mapped_par

Parameter mapping back to the design factors
make_factor_diagram

Factor diagram plot
plot_fit

Posterior predictive checks
merge_chains

Merge samples
predict.emc

Generate posterior predictives
prior

Prior specification
plot_fit_choice

Plots choice data
run_adapt

Runs adapt stage for emc.
run_bridge_sampling

Estimating Marginal likelihoods using WARP-III bridge sampling
recovery.emc

Recovery plots
sampled_p_vector

Get model parameters from a design
run_IS2

Runs IS2 from Tran et al. 2021 on a list of emc
samples_LNR

An emc object of an LNR model of the Forstmann dataset using the first three subjects