SSDANOVA: Sample size determination for the Bayesian ANOVAs with bain

View source: R/cal_N_anova.R

SSDANOVAR Documentation

Sample size determination for the Bayesian ANOVAs with bain

Description

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

Usage

Res<-SSDANOVA(hyp1,hyp2,type,f1,f2,var,BFthresh,eta,T,seed)

Arguments

hyp1

strings that specify the former hypothesis of a pair of interested hypotheses. For example, if H0: mu1=mu2=mu3 vs H1: mu1>mu2>mu3, then hyp1="mu1=mu2=mu3".

hyp2

strings that specify the latter hypothesis. For example, as the previous example, then hyp2="mu1>mu2>mu3". Note: when hyp2 is an unconstrained hypothesis, then hyp2="Ha"; when hyp2 is the complement hypothesis of hyp1, then hyp2="Hc".

type

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

f1

parameter used to specify the populations corresponding to hyp1. It can be specified as a number denoting the effect size or a vector denoting the means for each of group. f1 is Cohen's f=sigma1/sigma, where sigma1 denotes the standard deviation of the means, and sigma denotes the common within-group standard deviation.

f2

parameter used to specify the populations corresponding to hyp2. It can be specified as a number denoting the effect size or a vector denoting the means for each of group.

var

a vector that specifies the within-group variances for each of the group. If type = "equal" and f1 and f2 are Cohen's f, the specification var = NULL implies that each within-group variance is set to 1. In case of type = "unequal", the user need to input Cohen's f and the variances for each group. If f1 and f2 are vectors of means, the user need to input the variances for each group.

BFthresh

numeric value not less than 1 that specifies the required size of the Bayes factor. 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 of the competing hypotheses is true. The default setting is eta=0.80.

T

a positive integer that specifies the number of data sets sampled from the populations corresponding to the two hypotheses of interest. The default setting is T=10000.

seed

a positive integer that specifies the seed of R's random number generator. The default setting is seed=10.

Value

The output resulting from analyses with SSDANOVA contains:

1) required sample size N

2) the probability P(BFsv>BFthresh|Hs)

3) the probability P(BFvs>BFthresh|Hv)

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., Mirjam, M., and Hoijtink, H. (unpublished). Sample size determination for the Bayesian ANOVAs with Informative hypotheses. doi:10.31234/osf.io/ymvb9. Research Archive on Github. 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: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. doi:10.1111/bmsp.12145

Examples

#Example 1: using Cohen's f to specify the populations of interest for regular ANOVA.

Res<-SSDANOVA(hyp1="mu1=mu2=mu3",hyp2="Ha",type="equal",f1=0,f2=0.25,var=NULL,BFthresh=3,eta=0.80,T=10000,seed=10)

#Example 2: using Cohen's f and withing-group variances to specify the populations for Welch's ANOVA.

Res<-SSDANOVA(hyp1="mu1>mu2>mu3",hyp2="Hc",type="unequal",f1=0.25,f2=0.25,var=c(1.5,0.75,0.75),BFthresh=1,eta=0.9,T=10000,seed=10)

#Example 3: using means and within-group variances to specify the populations of interest.

Res<-SSDANOVA(hyp1="mu1=mu2=mu3",hyp2="mu3>mu2>mu1",type="equal",f1=c(0,0,0),f2=c(550,560,580),var=c(2500,2500,2500),BFthresh=3,eta=0.8,T=10000,seed=10)


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