StanDDM: StanDDM: Multi-level Bayesian Fitting Procedure for...

View source: R/main.r

StanDDMR Documentation

StanDDM: Multi-level Bayesian Fitting Procedure for Decision-Making Data

Description

Will fit or simulate all models defined in "include" and apply all Stan sampler arguments.

Usage

StanDDM(data = NULL, include_models = c(), num_cores = 4,
  simulation = FALSE, warmup = 500, iter = 2000, stepsize = 0.15,
  adapt_delta = 0.85, max_treedepth = 30)

Arguments

data

If simulation = FALSE, then a data frame with decision-making data has to be provided. Check the 'example_data' provided with the package. Required columns are 'suj' (subject ID), 'rt' (reaction times in seconds), 'crit' for the diffusion criteria (accuracy coding or stimuli coding, more info on the github readme) and 'cor' (correct or incorrect answer).

include_models

A vector of strings to indicate which models should be fitted to the data or used in the simulations. 'Pure', 'st', 'sv', 'sz', 'sv_sz', 'st_sv', 'sz_st' and 'sv_sz_st' can be included in any order. It is also possible to load in custom models. See the github readme for instructions.

num_cores

Number of CPU cores to be used for the fitting procedure. Note that for each core, a MCMC chain will be assigned automatically. The minimum amount of available cores on your machine should be 4.

simulation

A boolean that if simulation = TRUE, a parameter recovery study for the current model is launched. In that mode, a set of parameters will be randomly generated and also the corresponding data for 10 simulated subjects. That synthetic data will then be fitted with the indicated model. Plots and fitting quality will be saved in your working directory. Interesting are the by-iteration plots for each parameter. If simulation = FALSE, a data frame has to be provided in the correct format. The models will fit the provided data.

warmup

Warmup iterations which will be discarded. 500 to 1000 are recommended, but should be adjusted to accomodate rig capacities and model properties.

iter

MCMC iterations per chain. 1000 to 5000 are recommended but should be adjusted to accomodate rig capacities and model properties.

stepsize

Initial NUTS step-size. Will adapt after a some iterations. Adjust to own parameter space if necessary. See the Stan Manual for more information.

adapt_delta

See the Stan Manual for more information.

max_treedepth

See the Stan Manual for more information.

Value

Calls the defined models, which will return a stanfit object, save plots on memory and show RMSE and R^2 values. If simulation = TRUE, additional plots will be saved for checking how well parameters were recovered.


Seneketh/StanDDM documentation built on Oct. 17, 2023, 4:26 p.m.