bayes_sampsize {BayesianPower}R Documentation

Determine the required sample size for a Bayesian hypothesis test

Description

Determine the required sample size for a Bayesian hypothesis test

Usage

bayes_sampsize(h1, h2, m1, m2, type = 1, cutoff, bound1 = 1,
  bound2 = 1/bound1, datasets = 1000, nsamp = 1000, minss = 2,
  maxss = 1000, seed = 31)

Arguments

h1

A constraint matrix defining H1.

h2

A constraint matrix defining H2.

m1

A vector of expected population means under H1 (standardized).

m2

A vector of expected populations means under H2 (standardized). m2 must be of same length as m1

type

A character. The type of error to be controlled options are: "1", "2", "de", "aoi", "med.1", "med.2"

cutoff

A number. The cutoff criterion for type. If type is "1", "2", "de", "aoi", cutoff must be between 0 and 1 If type is "med.1" or "med.2", cutoff must be larger than 1

bound1

A number. The boundary above which BF12 favors H1

bound2

A number. The boundary below which BF12 favors H2

datasets

A number. The number of datasets to compute the error probabilities

nsamp

A number. The number of prior or posterior samples to determine the fit and complexity

minss

A number. The minimum sample size to consider

maxss

A number. The maximum sample size to consider

seed

A number. The random seed to be set

Value

The sample size for which the chosen type of error probability is at the set cutoff, and the according error probabilities and median Bayes factors

Examples

# Short computation example NOT SUFFICIENT SAMPLES
h1 <- matrix(c(1,-1), nrow= 1, byrow= TRUE)
h2 <- 'c'
m1 <- c(.4, 0)
m2 <- c(0, .1)
bayes_sampsize(h1, h2, m1, m2, "de", .125, nsamp = 50, datasets = 50,
minss = 40, maxss = 70)

# Example 1 Decision error and Hc
h1 <- matrix(c(1,-1,0,0,1,-1), nrow= 2, byrow= TRUE)
h2 <- 'c'
m1 <- c(.4,.2,0)
m2 <- c(.2,0,.1)
bayes_sampsize(h1, h2, m1, m2, "de", .125)

# Example 2 Indecision error and H2
h1 <- matrix(c(1,-1,0,0,0,1,-1,0,0,0,1,-1), nrow= 3, byrow= TRUE)
h2 <- matrix(c(0,-1,1,0,0,1,0,-1,-1,0,0,1), nrow = 3, byrow= TRUE)
m1 <- c(.7,.3,.1,0)
m2 <- c(0,.4,.5,.1)
bayes_sampsize(h1, h2, m1, m2, type = "aoi", cutoff = .2, minss = 2,
maxss = 500)


[Package BayesianPower version 0.1.6 Index]