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

From: Uwe Ligges <ligges_at_statistik.tu-dortmund.de>
Date: Sat, 15 Mar 2008 17:35:30 +0100

kasturi bardhan wrote:
> hello everybody
> I use the following code for my programming & it runs with the error as specified below.Any help that would disolve the error will be highly appreciated.
> Thanks in advance
> my code looks like this
> #### R programme for simulating the power of the two sample t test vs various
> #### non-parametric alternatives
> sim.size <- 200
> sample.size <- 10
> set.seed(231)
> mu1 <- 0
> delta <- seq(-2,2, length=50)
> for (j in 1:length(delta))
> {
> mu2 <- mu1 + delta[j]
> 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
>
> Error in pt.test[i] <- (test1$p.value < 0.05) :
> object "pt.test" not found

Please do your homework yourself, read the psoting guide to this list and read the error message carefully, it tells you exactly what went wrong. Additionally, R provides some useful tools for debugging that you could your prior to spending others' time.

Best wishes,
Uwe Ligges

>
> Chat on a cool, new interface. No download required. Go to http://in.messenger.yahoo.com/webmessengerpromo.php
> [[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.



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:35 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