SSDttest: Sample Size Determination for the Bayesian t-test and...

View source: R/Autosampleoptimization.R

SSDttestR Documentation

Sample Size Determination for the Bayesian t-test and Bayesian Welch's test

Description

The function SSDttest in the R package SSDbain computes the sample size for the Bayesian t-test and Welch's test using Bayes factors implemented in bain. SSDbain can be found at https://github.com/Qianrao-Fu/SSDbain. In Fu, Hoijtink, and Moerbeek (2021), it is elaborated how to use SSDttest. Users are well advised to read this paper before using SSDttest. Users are required to install package bain from CRAN before using SSDbain package.

Usage

SSDttest(type='equal',Population_mean=c(0.5,0),var=NULL,BFthresh=3,eta=0.8,Hypothesis='two-sided',T=10000)

Arguments

type

a string that specifies the type of the test. If type='equal', the t-test is used; if type='unequal', Welch's test is used.

Population_mean

vector of length 2 specifying the population means of the two groups under the alternative hypothesis H1 or H2. The default setting is Population_mean=c(0.5,0) when the effect size is d=0.5. Note that, if var=NULL and the population mean in Group 2 equals 0, the population mean in Group 1 is identical to Cohen's d.

var

vector of length 2 giving the two within-group variances. If type='equal', the default is var=c(1,1); if type='unequal', the default is var=c(4/3,2/3). Of course, any values of the variances can be used as input for the argument var.

BFthresh

a numeric value that specifies the magnitude of the Bayes factor, e.g. 1, 3, 5 or 10. The default setting is BFthresh=3.

eta

a numeric value that specifies the probability that the Bayes factor is larger than the BFthresh if either the null hypothesis or the alternative hypothesis is true, e.g., 0.80, 0.90. That is, P(BF0i>BFthresh|H0) and P(BFi0>BFthresh|Hi) reach at least eta. The default setting is eta=0.80.

Hypothesis

a string that specifies the hypothesis. Hypothesis='two-sided' when the competing hypotheses are H0:mu1=mu2, H1:mu1,mu2; Hypothesis='one-sided' when the competing hypotheses are H0:mu1=mu2, H2: mu1>mu2.

T

a postive integer that indicating the number of data sets sampled from the null and alternative populations to determine the required sample size. The default setting is T=10000. Note: a minimum value of 10000 is recommended.

Value

The output resulting from analyses with SSDttest contains:

1) required sample size N

2) the probability P(BF0i>BFthresh|H0)

3) the probability P(BFi0>BFthresh|Hi)

Note: To perform the sensitive analysis, the results are provided for three different fractions b, 2b, and 3b, where b corresponds to fraction = 1 in the call to bain.

Author(s)

Qianrao Fu

References

Fu, Q., Hoijtink, H. & Moerbeek, M. (2021). Sample-size determination for the Bayesian t test and Welch's test using the approximate adjusted fractional Bayes factor. Behavior Research Methods, 53, 139-152. doi:https://doi.org/10.3758/s13428-020-01408-1.

Gu, X., Mulder, J., and Hoijtink, H. (2017). Approximated adjusted fractional Bayes factors: A general method for testing informative hypotheses. British Journal of Mathematical and Statistical Psychology. British Journal of Mathematical and Statistical Psychology, 71(2), 229-261. doi:https://doi.org/10.1111/bmsp.12110.

Hoijtink, H., Gu, X., and Mulder, J. (2018). Bayesian evaluation of informative hypotheses for multiple populations. British Journal of Mathematical and Statistical Psychology, 72(2), 219-243. doi:https://doi.org/10.1111/bmsp.12145.

Examples

#Example 1: for the two-sided t-test, effect size d=0.5, BFthresh=3, and eta=0.8.

Res<-SSDttest(type='equal',Population_mean=c(0.5,0),var=NULL,BFthresh=3,eta=0.8,Hypothesis='two-sided',T=10000)


#Example 2: for the one-sided t-test, effect size d=0.2, BFthresh=1, and eta=0.9.

Res<-SSDttest(type='equal',Population_mean=c(0.2,0),var=NULL,BFthresh=1, eta=0.9,Hypothesis='one-sided',T=10000)


#Example 3: for the two-sided Welch's test, effect size d=0.5, BFthresh=3,and eta=0.8.

Res<-SSDttest(type='unequal',Population_mean=c(0.5,0),var=NULL,BFthresh=3,eta=0.8,Hypothesis='two-sided',T=10000)


Qianrao-Fu/SSDbain documentation built on Oct. 23, 2023, 10:30 p.m.