Skip to contents

This function is responsible for generating synthetic (fake) data using random numbers. For all parameters except the last one, their values are drawn from a uniform distribution within their respective specified ranges.

The last parameter, representing the temperature (`tau`) in the soft-max function, is drawn from an exponential distribution. If its `upper` bound is set to 1, it implies `tau` is sampled from `Exp(1)` (an exponential distribution with a rate parameter of 1). If its `lower` bound is set to 1, this means that after `tau` is randomly generated, it is shifted to the right by adding 1 (i.e., `tau + 1`), establishing a minimum value.

Usage

simulate_list(
  data,
  id = 1,
  obj_func,
  n_params,
  n_trials,
  lower,
  upper,
  iteration = 10,
  seed = 123
)

Arguments

data

[data.frame] This data should include the following mandatory columns:

  • "sub"

  • "time_line" (e.g., "Block", "Trial")

  • "L_choice"

  • "R_choice"

  • "L_reward"

  • "R_reward"

  • "sub_choose"

id

[vector] Specifies which subject's data to use. In parameter and model recovery analyses, the specific subject ID is often irrelevant. Although the experimental trial order might have some randomness for each subject, the sequence of reward feedback is typically pseudo-random.

The default value for this argument is `NULL`. When `id` is `NULL`, the program automatically detects existing subject IDs within the dataset. It then randomly selects one subject as a sample, and the parameter and model recovery procedures are performed based on this selected subject's data.

default: id = NULL

obj_func

[function] The objective function that the optimization algorithm package accepts. This function must strictly take only one argument, `params` (a vector of model parameters). Its output must be a single numeric value representing the loss function to be minimized. For more detailed requirements and examples, please refer to the relevant documentation ( TD, RSTD, Utility ).

n_params

[integer] The number of free parameters in your model.

n_trials

[integer] The total number of trials in your experiment.

lower

[vector] Lower bounds of free parameters

upper

[vector] Upper bounds of free parameters

iteration

[integer] This parameter determines how many simulated datasets are created for subsequent model and parameter recovery analyses.

seed

[integer] Random seed. This ensures that the results are reproducible and remain the same each time the function is run.

default: seed = 123

Value

a list with fake data generated by random free parameters

Examples

if (FALSE) { # \dontrun{
list_simulated <- binaryRL::simulate_list(
  data = binaryRL::Mason_2024_Exp2,
  obj_func = binaryRL::RSTD,
  n_params = 3,
  n_trials = 360,
  lower = c(0, 0, 1),
  upper = c(1, 1, 1),
  iteration = 100
)

df_recovery <- binaryRL::recovery_data(
  list = list_simulated,
  fit_model = binaryRL::RSTD,
  model_name = "RSTD",
  n_params = 3,
  n_trials = 360,
  lower = c(0, 0, 1),
  upper = c(1, 1, 5),
  iteration = 100,
  nc = 1,
  algorithm = "L-BFGS-B"
)
} # }