This Auto-correlated Bayesian Sampler model (ABS, Zhu et al. 2024) is developed by Zhu.

References

Zhu J, Sundh J, Spicer J, Chater N, Sanborn AN (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. doi:10.1037/rev0000427 .

Super class

samplr::CoreABS -> Zhu23ABS

Public fields

width

the standard deviation of the proposal distribution for MC3.

lambda

the rate parameter of the Erlang distribution for decision time.

Methods


Method new()

Create a new 'Zhu23ABS' object.

Usage

Zhu23ABS$new(
  width,
  n_chains,
  nd_time,
  s_nd_time,
  lambda,
  distr_name = NULL,
  distr_params = NULL,
  custom_distr = NULL,
  custom_start = NULL
)

Arguments

width

a numeric value of the standard deviation of the proposal distribution for MC3.

n_chains

an integer of the number of chains for the sampler.

nd_time

a numeric value of the non-decision time (in seconds). When s_nd_time is not 0, nd_time represents the lower bound of the non-decision time.

s_nd_time

a numeric value of the inter-trial-variability of the non-decision time (in seconds).

lambda

a numeric value of the rate parameter of the Erlang distribution for decision time.

distr_name

a character string indicating the type of the posterior hypothesis distribution.

distr_params

a numeric vector of the additional parameters for the posterior hypothesis distribution.

custom_distr

a list of functions that define the posterior hypothesis distribution.

custom_start

a numeric value of the starting point if "custom_distr" is provided.

Returns

A new 'Zhu23ABS' object.

Examples

zhuabs <- Zhu23ABS$new(
    width = 1, n_chains = 5, nd_time = 0.3, s_nd_time = 0.5,
    lambda = 10, distr_name = 'norm', distr_params = 1
)


Method simulate()

Simulate the ABS model.

Usage

Zhu23ABS$simulate(stopping_rule, start_point = NA, ...)

Arguments

stopping_rule

a character string indicating the stopping rule of ABS to be applied. Possible values are "fixed" and "relative". See also Details.

start_point

a numeric vector setting the start point of each trial for the sampler. By default, it's set to NA, indicating that the starting point of the first trial is a random point from the posterior of hypotheses, and the starting points of subsequent trials are set to the last sample of the previous trial. For more detailed information, please refer to the vignette "Simulations of the Autocorrelated Bayesian Sampler".

...

further arguments passed to the ABS model, see also Details.

Details

The ABS model has two types of stopping rules: fixed and relative. The fixed stopping rule means that a fixed number of samples are drawn to complete the tasks such as estimations and confidence intervals. This rule applies to tasks such as estimation tasks. On the other hand, the relative stopping rule means that the model counts the difference in evidence between the two hypotheses, and terminates the sampling process whenever the accumulated difference exceeds a threshold. This rule applies to tasks such as two-alternative force choice tasks.

When the stopping rule is "fixed", the following arguments are required:

  • n_sample an integer of the fixed number of samples for each trial.

  • trial_stim a numeric vector of the stimulus of each trial.

When the stopping rule is "relative", the following arguments are required:

  • delta an integer of the relative difference between the number of samples supporting each hypothesis.

  • dec_bdry a numeric value of the decision boundary that separates the posterior hypothesis distribution.

  • discrim a numeric value of the stimuli discriminability.

  • trial_stim a factor that indicates the stimuli of each trial. It only consists of either one level or two levels. By definition, level 1 represents the stimulus below the decision boundary, while level 2 represents the stimulus above the decision boundary.

  • prior_on_resp a numeric vector for the Beta prior on responses. Defaults to c(1,1) representing the distribution Beta(1,1).

  • prior_depend a boolean variable that control whether the prior on responses changes regarding the last stimulus. Defaults to TRUE. Please refer to the vignette for more information.

  • max_iterations an integer of the maximum length of the MC3 sampler. Defaults to 1000. The program will stop the sampling process after the length of the sampling sequence reaches to this limitation.

No values will be return after running this method, but the field sim_results will be updated instead. If the stopping rule is "fixed", simulation_results will be a data frame with five columns:

  1. trial: The index of trials;

  2. samples: The samples of ABS sampler for the trial;

  3. stimulus: The stimuli of the experiment;

  4. rt: The response time;

  5. point_est: The response of point estimation;

On the other hand, if the stopping rule is "relative", sim_results will be a data frame with seven columns:

  1. trial: The index of trials;

  2. samples: The samples of ABS sampler for the trial;

  3. response: The response predicted by ABS;

  4. stimulus: The stimuli of the experiment;

  5. accuracy: Whether the response is the same as the feedback. 0 represents error, and 1 represents correct;

  6. rt: The response time, including both the non-decision and the decision time;

  7. confidence: The confidence of the response.

Examples


trial_stim <- round(runif(5, 10, 50))
zhuabs$simulate(stopping_rule='fixed', n_sample = 5, trial_stim = trial_stim)
zhuabs$sim_results

zhuabs$reset_sim_results()
trial_stim <- factor(sample(c('left', 'right'), 5, TRUE))
zhuabs$simulate(stopping_rule='relative',
   delta = 4, dec_bdry = 0,
   discrim = 1, trial_stim = trial_stim
)
zhuabs$sim_results


Method confidence_interval()

This function calculates the confidence interval of the simulate method's results when the "fixed" stopping rule was used.

Usage

Zhu23ABS$confidence_interval(conf_level)

Arguments

conf_level

the required confidence level.

Details

No values will be returned by this method. Instead, two new columns will be added to the sim_results:

  1. conf_interval_l: The lower bound of the confidence interval with the given level;

  2. conf_interval_u: The upper bound of the confidence interval with the given level;

Examples

zhuabs$confidence_interval(conf_level = 0.9)


Method reset_sim_results()

This function is for resetting the sim_results to run new simulations.

Usage

Zhu23ABS$reset_sim_results()


Method clone()

The objects of this class are cloneable with this method.

Usage

Zhu23ABS$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples


## ------------------------------------------------
## Method `Zhu23ABS$new`
## ------------------------------------------------

zhuabs <- Zhu23ABS$new(
    width = 1, n_chains = 5, nd_time = 0.3, s_nd_time = 0.5, 
    lambda = 10, distr_name = 'norm', distr_params = 1
)


## ------------------------------------------------
## Method `Zhu23ABS$simulate`
## ------------------------------------------------


trial_stim <- round(runif(5, 10, 50))
zhuabs$simulate(stopping_rule='fixed', n_sample = 5, trial_stim = trial_stim)
zhuabs$sim_results
#>   trial                                          samples stimulus        rt
#> 1     1 49.46205, 50.15568, 50.13782, 49.49812, 48.70987       49  1.323156
#> 2     2 46.37790, 46.37790, 46.37790, 46.10574, 44.83523       11  0.981617
#> 3     3 43.83680, 42.27428, 41.99898, 41.99898, 41.84585       37  1.264902
#> 4     4 39.38179, 38.99805, 38.99805, 38.99805, 38.87522       25 0.9102649
#> 5     5 47.69700, 47.69700, 47.69700, 46.86499, 46.39406       47  1.050115
#>   point_est
#> 1  48.70987
#> 2  44.83523
#> 3  41.84585
#> 4  38.87522
#> 5  46.39406

zhuabs$reset_sim_results()
trial_stim <- factor(sample(c('left', 'right'), 5, TRUE))
zhuabs$simulate(stopping_rule='relative', 
   delta = 4, dec_bdry = 0, 
   discrim = 1, trial_stim = trial_stim
)
zhuabs$sim_results
#>   trial
#> 1     1
#> 2     2
#> 3     3
#> 4     4
#> 5     5
#>                                                                                samples
#> 1                                   -1.55761552, -1.55761552, -0.92738114, -0.05299664
#> 2                                                -0.90371355, -0.06320349, -0.69308594
#> 3                            0.1998162, -0.2475284, -1.4510945, -1.8265552, -2.3712877
#> 4                                                   -1.0035810, -1.2238617, -0.2688994
#> 5 -0.09982374, 0.31810194, 1.38978580, 1.35273434, -0.08451240, 0.76244935, 0.76244935
#>   response stimulus accuracy       rt confidence
#> 1     left     left        1 1.201335  0.8333333
#> 2     left     left        1 1.004604  0.8333333
#> 3     left     left        1 1.230430  0.7500000
#> 4     left    right        0 1.413864  0.8333333
#> 5    right    right        1 1.140226  0.7000000


## ------------------------------------------------
## Method `Zhu23ABS$confidence_interval`
## ------------------------------------------------

zhuabs$confidence_interval(conf_level = 0.9)
#> Warning: The simulation results were geneated with the relative stopping rule.