Re: [R] need help for chi-squared test
David, I think the poster wants to use one of the columns as x and the other as y, ignoring the remaining columns. If that is the case then he/she needs to read the section in "Introduction to R" on subsetting data frames. I agree that the output so far is meaningless, from the degrees of freedom it looks like chisq.test is interpreting the data frame as a 1245 by 4 contingency table. The thing that concerns me is the lack of any warnings or errors, if there truly were not any warnings then how is it interpreting counts of 0.25? and I would expect the number of 0's in the part shown to generate the warning about cell sizes too small. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of David Winsemius > Sent: Thursday, January 06, 2011 1:14 PM > To: kiotoqq > Cc: r-help@r-project.org > Subject: Re: [R] need help for chi-squared test > > > On Jan 6, 2011, at 2:34 PM, kiotoqq wrote: > > > > > I used chisq.test(read.table("C:/Users/Maggy/Downloads/dust.asc", > > header=TRUE)) > > So, where did you download this data and when is your homework due? > > > > > and got this > > > >Pearson's Chi-squared test > > > > data: read.table("C:/Users/Maggy/Downloads/dust.asc", header = TRUE) > > X-squared = 5226.164, df = 3735, p-value < 2.2e-16 > > > > and I think it should be right for the whole set, > > I, on the other hand. now suspect it is a meaningless set of numbers. > > > > but that's not what I > > need, because I only have to use it for "cbr" and "smoking" > > Do you mean you have an understanding of the potential values of cbr > and smoking in that data and that you want to restrict your analysis > to some subset defined by particular values of those variables? > > > > -- > > View this message in context: http://r.789695.n4.nabble.com/need- > help-for-chi-squared-test-tp3177925p3178052.html > > Sent from the R help mailing list archive at Nabble.com. > > > > __ > > 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. > > David Winsemius, MD > West Hartford, CT > > __ > 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. __ 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.
Re: [R] need help for chi-squared test
On Jan 6, 2011, at 2:34 PM, kiotoqq wrote: I used chisq.test(read.table("C:/Users/Maggy/Downloads/dust.asc", header=TRUE)) So, where did you download this data and when is your homework due? and got this Pearson's Chi-squared test data: read.table("C:/Users/Maggy/Downloads/dust.asc", header = TRUE) X-squared = 5226.164, df = 3735, p-value < 2.2e-16 and I think it should be right for the whole set, I, on the other hand. now suspect it is a meaningless set of numbers. but that's not what I need, because I only have to use it for "cbr" and "smoking" Do you mean you have an understanding of the potential values of cbr and smoking in that data and that you want to restrict your analysis to some subset defined by particular values of those variables? -- View this message in context: http://r.789695.n4.nabble.com/need-help-for-chi-squared-test-tp3177925p3178052.html Sent from the R help mailing list archive at Nabble.com. __ 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. David Winsemius, MD West Hartford, CT __ 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.
Re: [R] need help for chi-squared test
I used chisq.test(read.table("C:/Users/Maggy/Downloads/dust.asc", header=TRUE)) and got this Pearson's Chi-squared test data: read.table("C:/Users/Maggy/Downloads/dust.asc", header = TRUE) X-squared = 5226.164, df = 3735, p-value < 2.2e-16 and I think it should be right for the whole set, but that's not what I need, because I only have to use it for "cbr" and "smoking" -- View this message in context: http://r.789695.n4.nabble.com/need-help-for-chi-squared-test-tp3177925p3178052.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] need help for chi-squared test
On Jan 6, 2011, at 1:23 PM, kiotoqq wrote: I've got a dataset which looks like this in the beginning: cbr dust smoking expo 1 0 0.20 15 2 0 0.25 14 3 0 0.25 18 4 0 0.25 14 5 0 0.25 14 (till no. 1240, anyway, a huge set) I have to analyse cbr and smoking, I know it works with chisq.test() for the whole set, but I only need cbr and smoking, and I have no idea how to extract them. This is not a sufficiently complex example on which to offer a solution, nor is it even clear enough to understand definitively what you want. So here is a guess: dfrm[which(dfrm$cbr==1 & dfrm$smoking==1), ] ... which would return a dataframe (or matrix depending on what form that data exists in) with only those cases where thos two conditions hold. You can either assign this value to an R object or you can apply the chisq.test() in what ever (unstated) manner you think has been "working" to the returned value as a whole. Please read the message at the bottom and follow its encouragement to read the Posting Guide. -- View this message in context: http://r.789695.n4.nabble.com/need-help-for-chi-squared-test-tp3177925p3177925.html Sent from the R help mailing list archive at Nabble.com. __ 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. David Winsemius, MD West Hartford, CT __ 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.