FAQ/unpinR - 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
Type the odd letters out: ONlY twO thinGs aRE infiNite

location: FAQ / unpinR

Equal samples t test for a given power in R

For a two-tailed test with type I error, alp, with inputted mean and average group sd will have power equal to pow.

[TYPE INTO R THE DESIRED INPUTS ALPHA, MEAN, SD AND N USING VALUES IN FORM BELOW].

The R syntax below

pow <- 0.8
beta <- 0.05
mdiff <- 2
sd <- 4

the the below will give the equal samples in nout.

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

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

This can be run in SPSS 16 using R integrator plug-in (see here).