simulate_QL: Simulate data from single and dual learning rate Q-learning...

View source: R/simulate_QL.R

simulate_QLR Documentation

Simulate data from single and dual learning rate Q-learning models

Description

simulate_QL is a function to simulate data from 1-alpha and 2-alpha Q-learning models, with an experiment structure identical to that run online. The parameter values can be from (a sample of) those fitted previously to the real data, or can be randomly sampled.

Usage

simulate_QL(
  summary_df = NULL,
  sample_size = NULL,
  gain_loss = TRUE,
  test = FALSE,
  affect = FALSE,
  time_pars = "overall",
  prev_sample = NULL,
  raw_df = NULL,
  ...
)

Arguments

summary_df

cmdstanr::summary() output containing posterior mean parameter values for a group of individuals. If left as NULL, a random sample of size sample_size will be taken from specified distributions.

sample_size

How may sets of parameters to sample; defaults to 100 or the number of individuals in the summary_df.

gain_loss

Fit the dual learning rate model?

test

Simulate test choices in addition to training choices?

affect

Simulate subjective affect ratings (uses full passage-of-time model).

time_pars

Which time parameters to include in the affect model: either "none"; or either/both "overall" (default) or "block".

prev_sample

An optional previous sample of id numbers (if you wish to simulate data for the same subset of individual parameters across a number of models).

raw_df

Provide the raw data used to fit the data originally, so that subject IDs can be labelled appropriately.

...

Other arguments which can be used to control the parameters of the Beta/Gaussian distributions from which parameter values are sampled.

Value

Simulated training data (and test data relevant) for a random or previously fitted sample of parameter values.

Examples

train_sim_2a <- simulate_QL(
  sample_size = 5,
  alpha_pos_dens = c(shape = 2, scale = 0.1), # default
  alpha_neg_dens = c(shape = 2, scale = 0.1), # default
  beta_dens = c(mean = 3, sd = 1) # default
)


qdercon/pstpipeline documentation built on June 1, 2025, 1:11 p.m.