FAQ/eqtR - 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 / eqtR

Power for equal samples t test in R

For a two-tailed test with type I error, alpha, with samples each of size, n, with means and standard deviations we compute the power.

[COPY AND PASTE THE BELOW INTO R]

fn <- function (alpha,mean1,mean2,sd1,sd2,n) {
mdiff <- mean1 - mean2
pow <- 1 - pt(abs(qt(alpha/2, 2*n-2)), 2*n-2,
mdiff/sqrt((sd1*sd1)/n+(sd2*sd2)/n))
cat("Power for (two-tailed) unequal sized groups unpaired t-test =")
print(pow)
 }

[TYPE INTO R THE DESIRED INPUTS].

alpha <- 0.05
mean1 <- 2
mean2 <- 0
sd1 <- 4
sd2 <- 5
n <- 45

AND RUN

fn(alpha,mean1,mean2,sd1,sd2,n)