ANOVAreplication (version 1.1.3)

sample.size.calc: Sample size calculator for the prior.predictive.check function

Description

Calculates the required sample size for a new study to conduct the prior predictive check with sufficient statistical power.

Usage

sample.size.calc(start_n,itmax=10,nmax=600,powtarget=.825,powmargin=.025,
                 posterior,g.m,p.sd,
                 statistic,Amat=0L,exact=0L,difmin=0L,effectsize=FALSE,alpha=.05)

Arguments

start_n

integer; the starting value for the sample size per group.

itmax

integer; the maximum number of iterations for the function.

nmax

integer; the maximum total sample size to evaluate.

powtarget

integer; the target power for which the sample size is to be obtained.

powmargin

integer; the margin around the target power for which results are to be returned.

posterior

a matrix (e.g., the output of Gibbs.ANOVA) with samples from the posterior based on the original data (i.e., y_o).

g.m

integer; the population value for the equal means in the alternative distribution. We advice to specify the grand mean of the study variables in the original dataset.

p.sd

integer; the population value for the pooled standard deviation in the alternative distribution. We advice to specify the pooled standard deviation for the study variables in the original dataset.

statistic

the type of hypothesis to be calculated: "ineq" for inequality constrained means, "dif" for inequality constraints plus minimum differences between means, "exact" for specific values for the means.

Amat

a p by q matrix, where p is the number of means in the ANOVA model, and q is the number of constraints to be imposed on the model. Each row represents one constraint where the parameter with the lower value according to the constraint receives the value -1, and the parameter with the higher value according to the constraint receives the value 1. Other parameters within the same row obtain the value 0.

exact

a vector of length p, where p is the number of means in the ANOVA model, with the exact values of the constrained hypothesis.

difmin

a vector of length q with the minimum difference per constraint as specified in Amat.

effectsize

logical; If TRUE the values in difmin are interpreted as Cohen's d.

alpha

integer; the level of alpha that should be taken into account while calculating the required sample size.

Value

Prints iterations while calculating. Prints a matrix with two columns. The first column contains the sample size per group and the second column the associated power. Furthermore, sample.size.calc produces a histogram with the null (i.e., the red distribution) and alternative distribution (i.e., the blue distribution) for the last iteration afterwards. The vertical line indicates rej.value (i.e., the 1-alpha'th percentile of the null distribution). The proportion of the alternative distribution on the right side of rej.value constitutes the statistical power.

References

Zondervan-Zwijnenburg, M.A.J., Van de Schoot, R., & Hoijtink, H. (2017). Testing ANOVA replication by means of the prior predictive p-value.

See Also

See also runShiny, prior.predictive.check, power.calc, Fbar.ineq, Fbar.dif, and Fbar.exact.

Examples

Run this code
# NOT RUN {
#analysis original data
data_o <- data.frame(y=ChickWeight$weight,g=ChickWeight$Diet)
#compute pooled sd
sd.g <- aggregate(data_o$y,by=list(data_o$g),sd)[,2]
n.g <- table(data_o$g)
p.sd <- ((n.g[1]-1)*sd.g[1]+(n.g[2]-1)*sd.g[2]+(n.g[3]-1)*sd.g[3]+(n.g[4]-1)*sd.g[4])/(sum(n.g)-4)

Gibbs.ANOVA(data_o,it=75,burnin=50) #we advise >1000 iterations, >500 burnin for reliable results
Amat <- (rbind(c(-1,0,0,1),c(0,-1,0,1),c(0,0,1,-1)))
difmin=c(0.8,0.5,0.2)

#sample size calculator
sample.size.calc(start_n=60, powtarget=.825,powmargin=.025,posterior=output_m,
                 g.m=mean(data_o$y),p.sd=p.sd,
                 statistic="dif",effectsize=TRUE,Amat=Amat,difmin=difmin)
# }

Run the code above in your browser using DataLab