The Autocorrelated Bayesian Sampler

Lucas Castillo

University of Warwick

C. Stella Qian

University of Warwick

Adam N. Sanborn

University of Warwick

Anchoring example

ABS

Many response modes

Also gives reaction time.

Figure adapted from Zhu et al. (2024)

Object-Oriented Programming

  1. Make a new instance of the model
myModel <- Zhu23ABS$new(...)
  1. Sample from the model
myModel$simulate(...)
  1. Look at results
myModel$sim_results

Note

Follow along with 3.abs.R file.

Making a new instance with $new()

ABS uses MC3 as the MCMC sampler (MH + Multiple Chains)

Target distribution is Gaussian, centred at the stimulus mean.

Parameters:

  • width: Width of proposal distribution
  • n_chains: Number of Chains
  • distr_name: Must be "norm"
  • distr_params: Width of the posterior distribution.

The decision time for a trial will be \(t \sim \text{Erlang}(N, \lambda) + n.d.t.\)

\(n.d.t.\) either fixed (when s_nd_time = 0) or variable (\(n.d.t. \sim \mathcal U (nd, nd+s\_nd)\).

  • lambda: Parameter in Erlang distribution
  • nd_time
  • s_nd_time

\[\mathbb E (Erlang) = \frac N \lambda\]

myModel <- Zhu23ABS$new(
  width = 25, 
  n_chains = 6, 
  distr_name = "norm", 
  distr_params = 30, 
  lambda = 4, 
  nd_time = 1, 
  s_nd_time = 0
)

Simulating results with $simulate()

  • For now, set stopping rule to fixed (I’ll explain this later!)
  • Sample \(N\) samples
  • trial_stim: Mean of the stimulus (in our example 24 - we can add multiple trials)
  • start_point: First sample for each trial
myModel$simulate(
  stopping_rule = "fixed",
  n_sample=4,
  trial_stim=c(24, 22, 27), 
  start_point=c(12, 12, 12)
)

Results

Examining results

print(myModel$sim_results)
  trial                   samples stimulus   rt point_est
1     1  12.00, 18.65, 4.13, 1.86       24 2.31      1.86
2     2  12.00, 8.02, 8.34, 10.53       22 1.63     10.53
3     3 12.00, 7.45, 10.59, 20.10       27 3.12      20.1

Adding confidence intervals

myModel$confidence_interval(conf_level = .75)
  trial samples stimulus   rt point_est ci_l  ci_u
1     1     ...       24 2.31      1.86 2.71 16.16
2     2     ...       22 1.63     10.53 8.14 11.45
3     3     ...       27 3.12      20.1 8.63 17.06

Practice

Make ABS estimate the height of the Cologne cathedral with an anchor of 320m (the correct height is 127m).

  • How long does it take, when \(\lambda = 4\) and \(N_{samples} = 10\)?
  • What is the 80% confidence interval?
  • Estimate: 300
  • 80% Confidence interval: 300-315
  • RT: 4.33s
model <- Zhu23ABS$new(
  width = 25,
  n_chains = 6,
  distr_name = "norm",
  distr_params = 30,
  lambda = 4,
  nd_time = 1,
  s_nd_time = 0
)
model$simulate(
  stopping_rule = "fixed",
  start_point = 320,
  n_sample=10,
  trial_stim = 127
)
model$confidence_interval(.8)
model$sim_results

“Relative” Stopping Rule

$simulate() with a relative stopping rule

2-alternative-forced-choice task (e.g., random dot motion task)

Model counts difference in evidence between the two hypotheses and terminates whenever it exceeds a threshold.

Parameters:

  • delta: threshold of the accumulated difference
  • dec_bdry: decision boundary that splits the posterior
  • prior_on_resp: the prior on responses, which determines the prior preference for a response (Beta).
  • discrim: discriminabilty, determines the mean values of the distributions for the posterior of hypotheses.
myModel$simulate(
  stopping_rule = "relative",
  delta = 2,
  dec_bdry = 0,
  discrim = 3,
  prior_on_resp=c(1,1),
  trial_stim = factor(
    c("left", "right", "left"))
)

Practice

The speed-accuracy trade-off states that

  • if you’re trying to be fast, you’ll be less accurate, and
  • if you’re trying to be accurate, you’ll be slower

Consider a 2AFC task - how can ABS replicate this effect?

My solution

Setup

set.seed(1)
stimuli <- factor(
  sample(c("left", "right"), 100, T)
)
myModel <- Zhu23ABS$new(
  width = 2,
  n_chains = 6,
  distr_name = "norm",
  distr_params = 2,
  lambda = 4,
  nd_time = 1,
  s_nd_time = 0
)

Slow

slow <- myModel$simulate(
  stopping_rule = "relative",
  delta = 10,
  dec_bdry = 0,
  discrim = 3,
  prior_on_resp=c(1,1),
  trial_stim = stimuli
)$sim_results

Fast

myModel$reset_sim_results()
fast <- myModel$simulate(
  stopping_rule = "relative",
  delta = 2,
  dec_bdry = 0,
  discrim = 3,
  prior_on_resp=c(1,1),
  trial_stim = stimuli
)$sim_results

My solution

mean(fast$rt);
[1] 1.627338
mean(fast$accuracy)
[1] 0.64
mean(slow$rt);
[1] 5.543572
mean(slow$accuracy)
[1] 0.95

Interim Wrap-up

So far

  1. Learned about MCMC and past applications to cognitive modelling
  2. Learned about how to use the samplr package to:
  • produce samples from different MCMC algorithms
  • produce responses from the ABS cognitive framework (Zhu et al., 2024)

Rest of the workshop

  • Learn how to fit these models to data.
  • Discuss future directions

References

Zhu, J.-Q., Sundh, J., Spicer, J., Chater, N., & Sanborn, A. N. (2024). The autocorrelated Bayesian sampler: A rational process for probability judgments, estimates, confidence intervals, choices, confidence judgments, and response times. Psychological Review, 131(2), 456–493. https://doi.org/10.1037/rev0000427