# Define formulas for the simulation
prior_formulas <- list(
V ~ distributional::dist_uniform(0.1, 1.0),
ndt ~ 0.3,
noise_coef ~ 1
)
between_trial_formulas <- list()
item_formulas <- list(
A_upper ~ 1,
A_lower ~ -1,
V ~ V
)
# Define noise factory
noise_factory <- function(context) {
noise_coef <- context$noise_coef
function(n, dt) {
noise_coef * rnorm(n, mean = 0, sd = sqrt(dt))
}
}
# Create configuration
config <- new_simulation_config(
prior_formulas = prior_formulas,
between_trial_formulas = between_trial_formulas,
item_formulas = item_formulas,
n_conditions = 10,
n_trials_per_condition = 10,
n_items = 5,
max_reached = 5,
max_t = 10,
dt = 0.01,
noise_mechanism = "add",
noise_factory = noise_factory,
model = "ddm",
parallel = FALSE
)
# Run simulation
sim_output <- run_simulation(config)
# Access results
dataset <- sim_output$open_dataset()
dataset # an arrow dataset object
# if you want to load it into memory, you can use:
df <- as.data.frame(dataset)
head(df)
# Access evaluated condition parameters
cond_dataset <- sim_output$open_evaluated_conditions()
df_cond <- as.data.frame(cond_dataset)
head(df_cond)
Run the code above in your browser using DataLab