Diff for "FAQ/power/Runpeg" - CBU statistics Wiki
location: Diff for "FAQ/power/Runpeg"
Differences between revisions 1 and 2
Revision 1 as of 2008-01-21 15:38:44
Size: 567
Editor: PeterWatson
Comment:
Revision 2 as of 2008-01-21 15:39:26
Size: 598
Editor: PeterWatson
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
= Unpaired t-tests : code in R = = Sample size for unequal sized groups in an unpaired t-tests =

Sample size for unequal sized groups in an unpaired t-tests

Delta is the ratio of group 2 to group 1, pow is the power, alpha is the (two-tailed) type I error, the difference between the means is mdiff with common sd. Group 1 is outputted. NoteL: the power.t.test R function only handles equal sized groups.

delta <- 1
pow <- 0.8
alpha <- 0.05
mdiff <- 2
sd <- 4

fn <- function(n1) {
(pow - (1 - pt(abs(qt(alpha/2,n1+(delta*n1)-2)), n1+(delta*n1)-2,
mdiff/sqrt((sd*sd)/n1+(sd*sd)/(n1*delta)))) )^2
 }

nout<- nlm(fn,2)
nout<- trunc(nout$estimate+1)
print(nout)

None: FAQ/power/Runpeg (last edited 2013-03-08 10:17:13 by localhost)