knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
The goal of bandit2arm is to educate users on how to simulate behavioral data obtained from the two-armed bandit task and, subsequently, take the simulated data and estimate the behavior that generated the data.
You can install the released version of bandit2arm from CRAN with:
install.packages("bandit2arm")
And the development version from GitHub with:
# install.packages("devtools") devtools::install_github("psuthaharan/bandit2arm")
Imagine you are a clinical psychologist - an individual who is passionate about understanding human behavior. You have this amazing task called the two-armed bandit task and you are excited to get participants to try it out! This task contains 200 trials and your goal is to recruit 100 participants:
library(bandit2arm) ## generate 100 individuals who completed the task # dataset1 contains behavioral data keeping only those selected-choice trials dataset1 <- simulate_bandit2arm(n_subj = 100, n_tr = 200, trials.unique = TRUE) # dataset2 contains behavioral data keeping all trials (selected-choice and the non-selected-choice) dataset2 <- simulate_bandit2arm(n_subj = 100, n_tr = 200, trials.unique = FALSE)
A month goes by and you have behavioral data from 100 participants. Let's see how some of these individuals performed!
# for plotting purpose - let's use dataset2 # You randomly select a few participant data to observe their behavior # Participant 100 # View first 10 rows of data head(dataset2$bandit2arm[[100]],10) # Visualize behavior plot_bandit2arm(data = dataset2, subj = 100, colors = c("orange","purple")) # Participant 65 # View first 10 rows of data head(dataset2$bandit2arm[[65]],10) # Visualize behavior plot_bandit2arm(data = dataset2, subj = 65, colors = c("green","red")) # Participant 33 # View first 10 rows of data head(dataset2$bandit2arm[[33]],10) # Visualize behavior plot_bandit2arm(data = dataset2, subj = 33, colors = c("#AA4499","#44AA99"))
# Run MLE estimate_bandit2arm(data = dataset1, method = "mle", plot = TRUE) # Run MAP estimate_bandit2arm(data = dataset1, method = "map", plot = TRUE) # Run MLE estimate_bandit2arm(data = dataset1, method = "eml", plot = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.