Re: [R] Please find the error in my code

From: <ArthurLi2001_at_aol.com>
Date: Sat, 15 Mar 2008 12:46:40 -0400 (EDT)


## 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]]

______________________________________________
R-help_at_r-project.org 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. Received on Sat 15 Mar 2008 - 16:51:28 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 15 Mar 2008 - 17:30:22 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive