Good that you got it to work somehow! Faiz: can you report the result, exactly as returned by R, of
sum(c(1,1,1,1,1,1)/6) - 1 ?? On my Linux with R version 2.10.0 (2009-10-26) this gives 0. (And, by the way, did you really mean to say you were using "R 2.1.01"? Was this a typing error for "R 2.10.1"?) Ted. On 14-Feb-10 09:26:00, Faiz Rasool wrote: > Hi all, > > Following Denis's code, I am able to carry out goodness of fit test. > > However the responses I have received, indicate that the code I > mentioned in > a prior email was not incorrect. inclusion of rep(1,6)/6 made a > difference > for me. I am using windows xp and R 2.1.01. Does difference of > operating > system makes a difference? As without rep(1,6)/6 R would not carry out > chisq.test on my computer. The code I got it to work follows. > >> freq=c(22,21,22,27,22,36)#frequencies obtained after rolling the dice >> 150 >> times. >> prob=rep(1,6)/6#change made after Dennis's suggestion. >> chisq.test(freq,p=prob)#no error message received now. > > Chi-squared test for given probabilities > > data: freq > X-squared = 6.72, df = 5, p-value = 0.2423 > > thanks everyone, > Faiz. > > ----- Original Message ----- > From: "Ted Harding" <ted.hard...@manchester.ac.uk> > To: <R-help@r-project.org> > Cc: "Faiz Rasool" <fai...@gmail.com> > Sent: Sunday, February 14, 2010 2:02 PM > Subject: RE: [R] Problem in performing goodness of fit test in R. > > >> On 14-Feb-10 07:42:12, Faiz Rasool wrote: >>> I am trying to perform goodness of fit test using R. I am using this >>> website >>> http://wiener.math.csi.cuny.edu/Statistics/R/simpleR/stat013.html >>> for help. However, I am unable to carry out the test successfully. My >>> code follows. It is taken from the website just mentioned. >>> >> freq=c(22,21,22,27,22,36) # frequencies obtained after >> # rolling the dice 150 times. >> prob=c(1,1,1,1,1,1)/6 # specify expected frequency for each category. >> chisq.test(freq,p=prob) # I do not know what this line means. >> # I just followed instructions on the >> # website. >>> >>> The erorr I receive is "erorr in chisq.test(freq,p=prob)/6 >>> probabilities must sum to 1" >>> >>> I am very new to R, so any help would be appreciated. >>> Faiz. >> >> I suspect that you must have made an error in entering the commands >> into R. Prime suspect: You did not have 6 1's in p -- for example >> you may have put >> >> prob=c(1,1,1,1,1)/6 >> >> (with only five). I copied your code (as trivially reformatted above) >> straight into R using copy&paste with the mouse, with results: >> >> freq=c(22,21,22,27,22,36) # frequencies obtained after >> # rolling the dice 150 times. >> prob=c(1,1,1,1,1,1)/6 # specify expected frequency for each category. >> chisq.test(freq,p=prob) # I do not know what this line means. >> >> # Chi-squared test for given probabilities >> # data: freq >> # X-squared = 6.72, df = 5, p-value = 0.2423 >> # I just followed instructions on the >> # website. >> >> So it worked as it should work. Therefore something went wrong >> when you entered the code. Check your input! >> >> Hoping this helps, >> Ted. >> >> -------------------------------------------------------------------- >> E-Mail: (Ted Harding) <ted.hard...@manchester.ac.uk> >> Fax-to-email: +44 (0)870 094 0861 >> Date: 14-Feb-10 Time: 09:02:01 >> ------------------------------ XFMail ------------------------------ > -------------------------------------------------------------------- E-Mail: (Ted Harding) <ted.hard...@manchester.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 14-Feb-10 Time: 10:53:34 ------------------------------ XFMail ------------------------------ ______________________________________________ R-help@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.