FAQ/power/nrpt - CBU statistics Wiki

You can't save spelling words.

Clear message
location: FAQ / power / nrpt

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
beta <- 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(beta/2,(2*n)-2)),2*n-2, 
mdiff/sqrt((2*sd*sd)/n*(1-rho)))) )^2
 }

nout<- nlm(fn,2)
nout<- trunc(nout$estimate+1)
print(nout)
pow <- 0.8
alpha <- 0.05
mdiff <- 2
sd <- 4
rho <- 0.5

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