b_success_rate: b_success_rate

View source: R/b_success_rate.R

b_success_rateR Documentation

b_success_rate

Description

Bayesian model for comparing test success rate.

Usage

b_success_rate(
  r,
  s,
  priors = NULL,
  warmup = 1000,
  iter = 2000,
  chains = 4,
  seed = NULL,
  refresh = NULL,
  control = NULL,
  suppress_warnings = TRUE
)

Arguments

r

a vector containing test results (0 - test was not solved successfully, 1 - test was solved successfully).

s

a vector containing subject indexes. Starting index should be 1 and the largest subject index should equal the number of subjects.

priors

List of parameters and their priors - b_prior objects. You can put a prior on the p (mean probability of success) and tau (variance) parameters (default = NULL).

warmup

Integer specifying the number of warmup iterations per chain (default = 1000).

iter

Integer specifying the number of iterations (including warmup, default = 2000).

chains

Integer specifying the number of parallel chains (default = 4).

seed

Random number generator seed (default = NULL).

refresh

Frequency of output (default = NULL).

control

A named list of parameters to control the sampler's behavior (default = NULL).

suppress_warnings

Suppress warnings returned by Stan (default = TRUE).

Value

An object of class 'success_rate_class'.

Examples


# priors
p_prior <- b_prior(family="beta", pars=c(1, 1))
tau_prior <- b_prior(family="uniform", pars=c(0, 500))

# attach priors to relevant parameters
priors <- list(c("p", p_prior),
               c("tau", tau_prior))

# generate data
s <- rep(1:5, 20)
data <- rbinom(100, size=1, prob=0.6)

# fit
fit <- b_success_rate(r=data, s=s, priors=priors, chains=1)



bayes4psy documentation built on Sept. 29, 2023, 5:08 p.m.