FAQ/power/runpegn - 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 missing letters from: He's no ded, he's jus resing hs eys

location: FAQ / power / runpegn

R code Power for unequal groups unpaired t-test

Delta is the ratio of group 2 to group 1, alpha is (two-tailed) type I error, group means, mean1 and mean2, with standard deviations, sd1 and sd2, and n1 is the number in group 1. Power is outputted.

[COPY AND PASTE INTO R]

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

[THEN ENTER INPUTS IN FORM BELOW]

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

AND RUN

fn(alpha,delta,mean1,mean2,sd1,sd2,n1)