Hi R Users This is a code I wrote and just want to confirm if the first 1000 values are raw gamma (z) and the next 1000 values are transformed gamma (k) or not. As I get 2000 rows once I import into excel, the p - values beyond 1000 dont look that good, they are very high. -- sink("a1.txt"); for (i in 1:1000) { x<-rgamma(10, 2.5, scale = 10) y<-rgamma(10, 2.5, scale = 10) z<-wilcox.test(x, y, var.equal = FALSE) print(z) x1<-log(x) y1<-log(y) k<-wilcox.test(x1, y1, var.equal = FALSE) print(k) } --- any suggestions are welcome thanks -devarshi
Hi I am a little bit confused. You create two sample (from a gamma distribution) and you do a wilcoxon test with this two samples. Then you use the same monotone transformation (log) for both samples and redo the wilcoxon test. But since the transformations keeps the order of your samples the second wilcoxon test is identical to the first one: x<-rgamma(10, 2.5, scale = 10) y<-rgamma(10, 2.5, scale = 10) wilcox.test(x, y, var.equal = FALSE) x1<-log(x) y1<-log(y) wilcox.test(x1, y1, var.equal = FALSE) Maybe you can give some more details about the hypothesis you'd like to test. Regards, Christoph Buser -------------------------------------------------------------- Christoph Buser <buser at stat.math.ethz.ch> Seminar fuer Statistik, LEO C13 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-44-632-4673 fax: 632-1228 http://stat.ethz.ch/~buser/ -------------------------------------------------------------- pantd at unlv.nevada.edu writes: > Hi R Users > > > This is a code I wrote and just want to confirm if the first 1000 values are raw > gamma (z) and the next 1000 values are transformed gamma (k) or not. As I get > 2000 rows once I import into excel, the p - values beyond 1000 dont look that > good, they are very high. > > > -- > sink("a1.txt"); > > for (i in 1:1000) > { > x<-rgamma(10, 2.5, scale = 10) > y<-rgamma(10, 2.5, scale = 10) > z<-wilcox.test(x, y, var.equal = FALSE) > print(z) > x1<-log(x) > y1<-log(y) > k<-wilcox.test(x1, y1, var.equal = FALSE) > print(k) > } > > --- > any suggestions are welcome > > thanks > > -devarshi > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
pantd at unlv.nevada.edu wrote:> Hi R Users > > > This is a code I wrote and just want to confirm if the first 1000 values are raw > gamma (z) and the next 1000 values are transformed gamma (k) or not. As I get > 2000 rows once I import into excel, the p - values beyond 1000 dont look that > good, they are very high.He? - log() transforming the data does not change the Wilcoxon statistics (based on ranks!)! - Why is this related to Excel? - What are you going to show? I get erg <- replicate(1000, { x<-rgamma(10, 2.5, scale = 10) y<-rgamma(10, 2.5, scale = 10) wilcox.test(x, y, var.equal = FALSE)$p.value }) sum(erg < 0.05) # 45 which seems plausible to me. Uwe Ligges> > -- > sink("a1.txt"); > > for (i in 1:1000) > { > x<-rgamma(10, 2.5, scale = 10) > y<-rgamma(10, 2.5, scale = 10) > z<-wilcox.test(x, y, var.equal = FALSE) > print(z) > x1<-log(x) > y1<-log(y) > k<-wilcox.test(x1, y1, var.equal = FALSE) > print(k) > } > > --- > any suggestions are welcome > > thanks > > -devarshi > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Hi I ran your code. I think it should give me the number of p values below 0.05 significance level (thats what i could understand from your code), but after running your code there is neither any error that shows up nor any value that the console displays. thanks in advance -dev. Quoting Uwe Ligges <ligges at statistik.uni-dortmund.de>:> pantd at unlv.nevada.edu wrote: > > > Hi R Users > > > > > > This is a code I wrote and just want to confirm if the first 1000 values > are raw > > gamma (z) and the next 1000 values are transformed gamma (k) or not. As I > get > > 2000 rows once I import into excel, the p - values beyond 1000 dont look > that > > good, they are very high. > > He? > - log() transforming the data does not change the Wilcoxon statistics > (based on ranks!)! > - Why is this related to Excel? > - What are you going to show? > > I get > > erg <- replicate(1000, { > x<-rgamma(10, 2.5, scale = 10) > y<-rgamma(10, 2.5, scale = 10) > wilcox.test(x, y, var.equal = FALSE)$p.value > }) > sum(erg < 0.05) # 45 > > which seems plausible to me. > > > Uwe Ligges > > > > > > > -- > > sink("a1.txt"); > > > > for (i in 1:1000) > > { > > x<-rgamma(10, 2.5, scale = 10) > > y<-rgamma(10, 2.5, scale = 10) > > z<-wilcox.test(x, y, var.equal = FALSE) > > print(z) > > x1<-log(x) > > y1<-log(y) > > k<-wilcox.test(x1, y1, var.equal = FALSE) > > print(k) > > } > > > > --- > > any suggestions are welcome > > > > thanks > > > > -devarshi > > > > ______________________________________________ > > R-help at stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >
Answering both messges here: 1. pantd at unlv.nevada.edu wrote: > Hi I appreciate your response. This is what I observed..taking > the log transform of the raw gamma does change the p value of > the test. That is what I am importing into excel (the p - values) Well, so you made a mistake! And I still do not know why anybody realy want to import data to Excel, if the data is already in R. For me, the results are identical (and there is no reason why not). > and then calculating the power of the test (both raw and > transformed). > > can you tell me what exactly your code is doing? See below. 2. pantd at unlv.nevada.edu wrote:> Hi > I ran your code. I think it should give me the number of p values below 0.05 > significance level (thats what i could understand from your code), but after > running your code there is neither any error that shows up nor any value that > the console displays.You are right in the point what the code I sent does: erg <- replicate(1000, { x<-rgamma(10, 2.5, scale = 10) y<-rgamma(10, 2.5, scale = 10) wilcox.test(x, y, var.equal = FALSE)$p.value }) sum(erg < 0.05) # 45 and it works for me. It results in a random number close to 50, hopefully. Since both points above seem to be very strange on your machine: Which version of R are you using? We assume the most recent one which is R-2.1.1. Uwe Ligges
thanks for your response. btw i am calculating the power of the wilcoxon test. i divide the total no. of rejections by the no. of simulations. so for 1000 simulations, at 0.05 level of significance if the no. of rejections are 50 then the power will be 50/1000 = 0.05. thats y im importing in excel the p values. is my approach correct?? thanks n regards -dev Quoting Uwe Ligges <ligges at statistik.uni-dortmund.de>:> Answering both messges here: > > > 1. pantd at unlv.nevada.edu wrote: > > Hi I appreciate your response. This is what I observed..taking > > the log transform of the raw gamma does change the p value of > > the test. That is what I am importing into excel (the p - values) > > Well, so you made a mistake! And I still do not know why anybody realy > want to import data to Excel, if the data is already in R. > > For me, the results are identical (and there is no reason why not). > > > > and then calculating the power of the test (both raw and > > transformed). > > > > can you tell me what exactly your code is doing? > > See below. > > > 2. pantd at unlv.nevada.edu wrote: > > Hi > > I ran your code. I think it should give me the number of p values below > 0.05 > > significance level (thats what i could understand from your code), but > after > > running your code there is neither any error that shows up nor any value > that > > the console displays. > > You are right in the point what the code I sent does: > > erg <- replicate(1000, { > x<-rgamma(10, 2.5, scale = 10) > y<-rgamma(10, 2.5, scale = 10) > wilcox.test(x, y, var.equal = FALSE)$p.value > }) > sum(erg < 0.05) # 45 > > > and it works for me. It results in a random number close to 50, hopefully. > > Since both points above seem to be very strange on your machine: Which > version of R are you using? We assume the most recent one which is R-2.1.1. > > Uwe Ligges > >
pantd at unlv.nevada.edu wrote:> thanks for your response. btw i am calculating the power of the wilcoxon test. i > divide the total no. of rejections by the no. of simulations. so for 1000 > simulations, at 0.05 level of significance if the no. of rejections are 50 then > the power will be 50/1000 = 0.05. thats y im importing in excel the p values.No, since H1 is NOT true in your case (the power is undefined under H0). In this case it is an estimator for the alpha error, but not the power. You might want to reread some basic textbook on testing theory. BTW: Why do you think R cannot calculate 50/1000 and Excel does better?> is my approach correct??No. Uwe Ligges> thanks n regards > -dev > > > Quoting Uwe Ligges <ligges at statistik.uni-dortmund.de>: > > >>Answering both messges here: >> >> >>1. pantd at unlv.nevada.edu wrote: >> > Hi I appreciate your response. This is what I observed..taking >> > the log transform of the raw gamma does change the p value of >> > the test. That is what I am importing into excel (the p - values) >> >>Well, so you made a mistake! And I still do not know why anybody realy >>want to import data to Excel, if the data is already in R. >> >>For me, the results are identical (and there is no reason why not). >> >> >> > and then calculating the power of the test (both raw and >> > transformed). >> > >> > can you tell me what exactly your code is doing? >> >>See below. >> >> >>2. pantd at unlv.nevada.edu wrote: >> >>>Hi >>>I ran your code. I think it should give me the number of p values below >> >>0.05 >> >>>significance level (thats what i could understand from your code), but >> >>after >> >>>running your code there is neither any error that shows up nor any value >> >>that >> >>>the console displays. >> >>You are right in the point what the code I sent does: >> >> erg <- replicate(1000, { >> x<-rgamma(10, 2.5, scale = 10) >> y<-rgamma(10, 2.5, scale = 10) >> wilcox.test(x, y, var.equal = FALSE)$p.value >> }) >> sum(erg < 0.05) # 45 >> >> >>and it works for me. It results in a random number close to 50, hopefully. >> >>Since both points above seem to be very strange on your machine: Which >>version of R are you using? We assume the most recent one which is R-2.1.1. >> >>Uwe Ligges >> >> > > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Hi Again to come back on the question why you don't get identical p.values for the untransformed and the transformed data. I ran your script below and I get always 2 identical test per loop. In your text you are talking about the first 1000 values for the untransformed and the next 1000 values for the transformed. But did you consider that in each loop there is a test for the untransformed and the transformed, so the tests are printed alternating. This might be a reason why you did not get equal results. Hope this helps, Christoph -------------------------------------------------------------- Christoph Buser <buser at stat.math.ethz.ch> Seminar fuer Statistik, LEO C13 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-44-632-4673 fax: 632-1228 http://stat.ethz.ch/~buser/ -------------------------------------------------------------- pantd at unlv.nevada.edu writes: > Hi R Users > > > This is a code I wrote and just want to confirm if the first 1000 values are raw > gamma (z) and the next 1000 values are transformed gamma (k) or not. As I get > 2000 rows once I import into excel, the p - values beyond 1000 dont look that > good, they are very high. > > > -- > sink("a1.txt"); > > for (i in 1:1000) > { > x<-rgamma(10, 2.5, scale = 10) > y<-rgamma(10, 2.5, scale = 10) > z<-wilcox.test(x, y, var.equal = FALSE) > print(z) > x1<-log(x) > y1<-log(y) > k<-wilcox.test(x1, y1, var.equal = FALSE) > print(k) > } > > --- > any suggestions are welcome > > thanks > > -devarshi > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html