## Corrected code:
sim.size <- 200
sample.size <- 10
set.seed(231)
mu1 <- 0
delta <- seq(-2,2, length=50)
pow.ttest<- numeric(50)
pow.kstest<- numeric(50)
pow.wtest<- numeric(50)
for (j in 1:length(delta))
{
mu2 <- mu1 + delta[j]
pt.test <- numeric(sim.size)
pw.test <- numeric(sim.size)
pks.test <- numeric(sim.size)
for (i in 1:sim.size)
{
# Generate ith sample
samp1 <- rnorm(mean=mu1,sample.size)
samp2 <- rnorm(mean=mu2,sample.size)
# Perform ith set of tests
test1 <- t.test(samp1, samp2,alternative = c("two.sided"))
pt.test[i] <- (test1$p.value < 0.05)
test2 <- wilcox.test(samp1, samp2,alternative = c("two.sided"),
exact = TRUE)
pw.test[i] <- (test2$p.value < 0.05)
test3 <- ks.test(samp1, samp2,alternative = c("two.sided"),
exact = TRUE)
pks.test[i] <- (test3$p.value < 0.05)
}
pow.ttest[j] <- sum(pt.test)/sim.size # Calculate powers for jth setting
pow.wtest[j] <- sum(pw.test)/sim.size
pow.kstest[j] <- sum(pks.test)/sim.size
} # End of j loop
**************It's Tax Time! Get tips, forms, and advice on AOL Money &
Finance. (http://money.aol.com/tax?NCID=aolprf00030000000001)
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.