This function is an internal function of `fit_p`. We isolate it from direct use by capable users.
The function provides several optimization algorithms:
1. L-BFGS-B (from `stats::optim`);
2. Simulated Annealing (`GenSA`);
3. Genetic Algorithm (`GA`);
4. Differential Evolution (`DEoptim`);
5. Particle Swarm Optimization (`pso`);
6. Bayesian Optimization (`mlrMBO`);
7. Covariance Matrix Adapting Evolutionary Strategy (`cmaes`);
8. Nonlinear Optimization (`nloptr`)
For more information, please refer to the GitHub repository: https://github.com/yuki-961004/binaryRL
optimize_para(
data,
id,
obj_func,
n_params,
n_trials,
lower,
upper,
initial_params = NA,
initial_size = 50,
iteration = 10,
seed = 123,
algorithm
)
the result of binaryRL with optimal parameters
[data.frame] raw data. 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"
[integer] which subject is going to be analyzed. is being analyzed. The value should correspond to an entry in the "sub" column, which must contain the subject IDs. e.g., `id = 18`
[function] A function with only ONE argument `params`. Refer to `binaryRL::TD` to mimic the establishment of an objective function.
[integer] The number of free parameters in your model.
[integer] The total number of trials in your experiment.
[vector] lower bounds of free parameters
[vector] upper bounds of free parameters
[vector] Initial values for the free parameters. automatically generate initial values. for `L-BFGS-B`, `GenSA`, set `initial = c(0, 0, ...)`
[integer] Initial population size for the free parameters. automatically generate initial values. for `Bayesian`, `GA`, set `initial = 50`
[integer] the number of iteration
[integer] random seed. This ensures that the results are reproducible and remain the same each time the function is run. default: `seed = 123`
[character] Choose an algorithm package from `L-BFGS-B`, `GenSA`, `GA`, `DEoptim`, `PSO`, `Bayesian`, `CMA-ES`. In addition, any algorithm from the `nloptr` package is also supported. If your chosen `nloptr` algorithm requires a local search, you need to input a character vector. The first element represents the algorithm used for global search, and the second element represents the algorithm used for local search.