rpl_e | R Documentation |
After completing Step 3 using fit_p()
to obtain the optimal parameters
for each subject and saving the resulting CSV locally, this function
allows you to load that result dataset. It then applies these optimal
parameters back into the reinforcement learning model, effectively
simulating how the "robot" (the model) would make its choices.
Based on this generated dataset, you can then analyze the robot's data in the same manner as you would analyze human behavioral data. If a particular model's fitted data can successfully reproduce the experimental effects observed in human subjects, it strongly suggests that this model is a good and valid representation of the process.
rpl_e(
data,
id = NULL,
result,
model,
model_name,
param_prefix = "param_",
n_trials = NULL
)
data |
[data.frame] This data should include the following mandatory columns:
|
id |
[CharacterVector] A vector specifying the subject ID(s) for which parameters should be fitted. The function will process only the subjects provided in this vector. To fit all subjects, you can either explicitly set the argument as
It is strongly recommended to avoid using simple numeric sequences like
default: |
result |
[data.frame] Output data generated by the |
model |
[Function] A model function to be applied in evaluating the experimental effect. |
model_name |
[string] A character string specifying the name of the model to extract from the result. |
param_prefix |
[string] A prefix string used to identify parameter columns in the result data default: |
n_trials |
[integer] Represents the total number of trials a single subject experienced
in the experiment. If this parameter is kept at its default value
of default: |
A list, where each element is a data.frame representing one subject's
results. Each data.frame includes the value update history for each option,
the learning rate (eta
), utility function (gamma
), and other
relevant information used in each update.
## Not run:
list <- list()
list[[1]] <- dplyr::bind_rows(
binaryRL::rpl_e(
data = binaryRL::Mason_2024_G2,
result = read.csv("../OUTPUT/result_comparison.csv"),
model = binaryRL::TD,
model_name = "TD",
param_prefix = "param_",
)
)
list[[2]] <- dplyr::bind_rows(
binaryRL::rpl_e(
data = binaryRL::Mason_2024_G2,
result = read.csv("../OUTPUT/result_comparison.csv"),
model = binaryRL::RSTD,
model_name = "RSTD",
param_prefix = "param_",
)
)
list[[3]] <- dplyr::bind_rows(
binaryRL::rpl_e(
data = binaryRL::Mason_2024_G2,
result = read.csv("../OUTPUT/result_comparison.csv"),
model = binaryRL::Utility,
param_prefix = "param_",
model_name = "Utility",
)
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.