Diff for "FAQ/power/nrpt" - CBU statistics Wiki
location: Diff for "FAQ/power/nrpt"
Differences between revisions 1 and 2
Revision 1 as of 2008-01-21 16:53:52
Size: 526
Editor: PeterWatson
Comment:
Revision 2 as of 2008-01-21 16:55:27
Size: 527
Editor: PeterWatson
Comment:
Deletions are marked like this. Additions are marked like this.
Line 20: Line 20:
(pow - (1 - pt(abs(qt(alph/2,(2*n)-2)),mdiff/sqrt((2*sd*sd)/n*(1-rho))) )^2 (pow - (1 - pt(abs(qt(alph/2,(2*n)-2)),mdiff/sqrt((2*sd*sd)/n*(1-rho)))) )^2

Sample sizes for paired t in R

mdiff is the difference between the two variables with correlation, rho, type I error, alpha, and (common) sd.

[COPY AND PASTE INTO R AND ADJUST INPUTS AS DESIRED]

pow <- 0.8
alpha <- 0.05
mdiff <- 2
sd <- 4
rho <- 0.5

[THEN COPY AND PASTE THE BELOW INTO R] [OUTPUTS NUMBER OF PAIRS]

fn <- function(n) {
(pow - (1 - pt(abs(qt(alph/2,(2*n)-2)),mdiff/sqrt((2*sd*sd)/n*(1-rho)))) )^2
 }

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

None: FAQ/power/nrpt (last edited 2013-03-08 10:18:09 by localhost)