In this document, I demonstrate the behavior of the simulation by varying the parameter settings and visualizing the resulting behavior. The full simulation code can be found in sim.R, and all plot-related functions come from plot_utils.R.

1 Standard settings

rm(list = ls())
# setwd("R_simulation/")

sim <- new.env()
source("sim.R", local = sim)  # access functions using sim$fun()

params_std <- list(
  n_part = 50,
  n_trials = 30,
  LR_group = 0.4,
  inv_temp_group = 0.5,
  initQ_group = list(F = 8, U = 2),
  mu_R_group = list(F = 5, U = 5),
  sigma_R_group = 2
)
plot <- new.env()
source("../plot_utils.R", local = plot)  # access functions using plot$fun()

dat <- sim$run_std(params_std)
plot$sim_plots(dat, params_std)

1.1 Varying learning rate

params <- modifyList(params_std, list(LR_group = 0.2))
dat <- sim$run_std(params)
plot$sim_plots(dat, params)

params <- modifyList(params_std, list(LR_group = 0.8))
dat <- sim$run_std(params)
plot$sim_plots(dat, params)

1.2 Varying inverse temperature

params <- modifyList(params_std, list(inv_temp_group = 0))
dat <- sim$run_std(params)
plot$sim_plots(dat, params)

params <- modifyList(params_std, list(inv_temp_group = 1.5))
dat <- sim$run_std(params)
plot$sim_plots(dat, params)

2 Confirmation bias

The decision tree shows the many options we have for implementing confirmation bias.

The first differentiation is whether bias occurs at the level of learning (LRN) or the level of rating (RTN).

2.1 Learning: LRN

We assume that the relationship between confirmation and learning rate (LR) is either discrete (discr) or continuous (cont).

2.1.1 Discrete: discr

Confirmatory and disconfirmatory outcomes have separate learning rates, where LR_conf > LR_disconf.

2.1.1.1 Close to belief: approx

\[LR = \begin{cases} {LR}_\text{conf} &\text{if}\ \left| R - \text{belief} \right| \leq \text{margin} \\ LR_\text{disconf} &\text{else} \end{cases}\] If the difference between the rating and belief is lesser than or equal to the defined margin, the outcome is treated as confirmatory. Else disconfirmatory. Name approx comes from the LaTeX code for the “approximately equal to” sign: \(R \approx \text{belief}\).

params_LRN_discr <- list(
  n_part = 50,
  n_trials = 30,
  LRs_group = list(conf = 0.8, disconf = 0.2),
  inv_temp_group = 0.5,
  initQ_group = list(F = 8, U = 2),
  mu_R_group = list(F = 5, U = 5),
  sigma_R_group = 2,
  margin_group = 2
)
stat

Beliefs are the static “outside-world values” that one has before starting the experiment.

dat <- sim$run_LRN_discr(params_LRN_discr, sim$LR_approx, "stat")
plot$sim_plots(dat, params_LRN_discr)

dyn

Beliefs are the dynamic “within-experiment values”.

dat <- sim$run_LRN_discr(params_LRN_discr, sim$LR_approx, "dyn")
plot$sim_plots(dat, params_LRN_discr)

2.1.1.2 Greater than or equal to belief: geq

\[LR = \begin{cases} {LR}_\text{conf} &\text{if}\ R + \text{margin} \geq \text{belief} \\ LR_\text{disconf} &\text{else} \end{cases}\] If the sum of the rating and the defined margin is equal to or larger than the rating, the outcome is treated as confirmatory. Else disconfirmatory. Name geq comes from the LaTeX code for the “greater than or equal to” sign: \(R \geq \text{belief}\).

stat

Beliefs are the static “outside-world values” that one has before starting the experiment.

dat <- sim$run_LRN_discr(params_LRN_discr, sim$LR_geq, "stat")
plot$sim_plots(dat, params_LRN_discr)

dyn

Beliefs are the dynamic “within-experiment values”.

dat <- sim$run_LRN_discr(params_LRN_discr, sim$LR_geq, "dyn")
plot$sim_plots(dat, params_LRN_discr)

2.1.2 Continuous: cont

The learning rate relates to the deviation from belief in a continuous way, with limits at 0 and predefined LR_max. The relationship is defined by LR_slope.

\[\begin{alignat*}{2} LR = LR_{\max} \cdot & LR'\\ & LR' = \begin{cases} 1 &\text{if}\ R + \text{margin} \geq \text{belief} \\ LR_\text{slope} \cdot \text{diff} + 1 &\text{else} \end{cases}\\ \text{with } & LR' \in [0, 1] \end{alignat*}\]

See figure below (LR_slope = 0.25).

dummy <- data.frame(
  diff = c(-9, 0, 9),
  LR_prime = c(0, 1, 1)
)
ggplot(dummy) + 
  geom_line(aes(x = diff, y = LR_prime)) +
  geom_vline(aes(xintercept = 0), lty = 2) +
  scale_x_continuous(breaks = seq(-9, 9, 3)) +
  scale_y_continuous(breaks = c(0, 1), labels = c("0", expression(w[LR]))) +
  labs(x = "R - belief", y = "LR") +
  plot$my_theme_classic

stat

params_LRN_cont <- list(
  n_part = 50,
  n_trials = 30,
  w_LR_group = 0.8,
  inv_temp_group = 0.5,
  initQ_group = list(F = 8, U = 2),
  mu_R_group = list(F = 5, U = 5),
  sigma_R_group = 2
)

dat <- sim$run_LRN_cont(params_LRN_cont, "stat")
plot$sim_plots(dat, params_LRN_cont)

dyn

dat <- sim$run_LRN_cont(params_LRN_cont, "dyn")
plot$sim_plots(dat, params_LRN_cont)

2.2 Rating: RTN