⇤ ← Revision 1 as of 2008-01-21 16:53:52
Size: 526
Comment:
|
Size: 527
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)