Sample and compute BF for various models using Stan.

compute_BF_Stan(
  data,
  model,
  hyperpriors,
  n.iter = 1000,
  n.burnin = 200,
  n.chains = 1,
  n.cores = 1,
  data_other = NULL,
  silent = FALSE,
  ...
)

Arguments

data

a list containing mtx, idx.ref, idx.quest

model

the model shortname (e.g. 'DirDir', 'DirFNorm')

hyperpriors

a list containing hyperparameter definitions

n.iter

number of HMC iterations (default: 1000)

n.burnin

number of HMC burn-in iterations (default: 200)

n.chains

number of HMC chains (default: 1)

n.cores

number of cores to use for HMC and bridge sampling (default: 1)

data_other

a list containing additional data for \(H_1\) and \(H_2\) models (default: NULL)

silent

if TRUE, do not print any progress

...

list of additional parameters to pass to rstan::sampling() method

Value

a stanBF object

Details

Two-sample model:

  • samples are stored as matrix mtx

  • reference items are indexed in mtx by idx.ref

  • questioned items are indexed in mtx by idx.quest

  • other items, non indexed, are discarded.

Hypotheses:

  • \(H_1\): samples in idx.ref and idx.quest come from the same source

  • \(H_2\): samples in idx.ref and idx.quest come from different sources

Return a stanBF object with these properties:

  • model_name

  • stanmodel (named list of Stan models)

  • stanfit (named list of stanfit objects)

  • stanbridge (named list of bridgesampler objects)

  • BF (a double: the Bayes Factor)

For Dirichlet likelihoods, the returned object is a stanBF_turn, inheriting from stanBF. These objects contain also:

  • df_samples (data.frame with posterior samples)

  • custom plot methods

The object contains methods to plot and to extract samples.