FAQ/power/nrpt - CBU statistics Wiki

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name
Comment
Finzd thee wrang lelters ino eacuh wosrd

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