Bayesian_Sampler: Bayesian Sampler Model

View source: R/Z_identities.R

Bayesian_SamplerR Documentation

Bayesian Sampler Model

Description

As described in \insertCitezhu2020BayesianSamplerGenericsamplr. Vectors can be provided for each parameter, allowing multiple estimates at once.

Usage

Bayesian_Sampler(
  a_and_b,
  b_and_not_a,
  a_and_not_b,
  not_a_and_not_b,
  beta,
  N,
  N2 = NULL,
  return = "mean",
  n_simulations = 1000
)

Arguments

a_and_b, b_and_not_a, a_and_not_b, not_a_and_not_b

True probabilites for the conjuctions and disjunctions of A and B. Must add to 1.

beta

Prior parameter.

N

Number of samples drawn

N2

Optional. Number of samples drawn for conjunctions and disjunctions. (called N' in the paper). If not given, it will default to N2=N. Must be equal or smaller than N.

return

Optional. Either "mean", "variance" or "simulation". Defaults to "mean".

n_simulations

Optional. if return="simulation", how many simulations per possible combination of A and B. Defaults to 1000.

Value

If return="mean" or return="variance", named list with predicted probabilities for every possible combination of A and B, or the expected variance of those predictions. If return="simulation", simulated predictions instead. Note that if return="simulation", the named list will contain vectors if the length of the true probabilities is 1; otherwise a matrix where each column is a queried probability and each row a simulation

References

\insertAllCited

Examples

Bayesian_Sampler(
    a_and_b = c(.4, .25),
    b_and_not_a = c(.4,  .25),
    a_and_not_b = c(.1, .25),
    not_a_and_not_b = c(.1, .25),
    beta = 1,
    N <- c(10, 12),
    N2 <- c(10, 10)
)
Bayesian_Sampler(
   a_and_b = c(0.05, .85),
   b_and_not_a = c(.85,  0.05),
   a_and_not_b = c(.05, 0.05),
   not_a_and_not_b = c(0.05, 0.05),
   beta = 1,
   N = 5,
   return="simulation"
)$a

samplr documentation built on April 4, 2025, 12:30 a.m.