Dear list! I would like to calculate "chisq.test" on simple data set with 70 observations, but the output is ''Warning message:'' Warning message: In chisq.test(tabele) : Chi-squared approximation may be incorrect Here is an example: tabele <- matrix(c(11, 3, 3, 18, 3, 6, 5, 21), ncol = 4, byrow = TRUE) dimnames(tabela) <- list( "SEX" = c("M","F"), "HAIR" = c("Brown", "Black", "Red", "Blonde")) addmargins(tabele) prop.table(tabele) chisq.test(tabele) Please, give me an advice / suggestion / recommendation. Thanks a lot to all, OV [[alternative HTML version deleted]]
Hi, The error is due to less than 5 observations in some cells. You can try, fisher.test(tabele) ??? Fisher's Exact Test for Count Data data:? tabele p-value = 0.0998 alternative hypothesis: two.sided A.K. ----- Original Message ----- From: Omphalodes Verna <omphalodes.verna at yahoo.com> To: "r-help at r-project.org" <r-help at r-project.org> Cc: Sent: Tuesday, June 26, 2012 2:27 PM Subject: [R] chisq.test Dear list! I would like to calculate "chisq.test" on simple data set with 70 observations, but the output is ''Warning message:'' Warning message: In chisq.test(tabele) : Chi-squared approximation may be incorrect Here is an example: ??? ??? tabele <- matrix(c(11, 3, 3, 18, 3, 6, 5, 21), ncol = 4, byrow = TRUE) ??? ??? dimnames(tabela) <- list( ??? ??? "SEX" = c("M","F"), ??? ??? "HAIR" = c("Brown", "Black", "Red", "Blonde")) ??? ??? addmargins(tabele) ??? ??? prop.table(tabele) ??? ??? chisq.test(tabele) Please, give me an advice / suggestion / recommendation. Thanks a lot to all, OV ??? [[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.
On 2012-06-26 11:27, Omphalodes Verna wrote:> Dear list! > > I would like to calculate "chisq.test" on simple data set with 70 observations, but the output is ''Warning message:'' > > Warning message: > In chisq.test(tabele) : Chi-squared approximation may be incorrect > > > Here is an example: > > tabele<- matrix(c(11, 3, 3, 18, 3, 6, 5, 21), ncol = 4, byrow = TRUE) > dimnames(tabela)<- list( > "SEX" = c("M","F"), > "HAIR" = c("Brown", "Black", "Red", "Blonde")) > addmargins(tabele) > prop.table(tabele) > chisq.test(tabele) > Please, give me an advice / suggestion / recommendation.Do this: ct <- chisq.test(tabele) ct$expected If that does not give you a sufficient hint, then you need to review the assumptions underlying the chisquare test. Peter Ehlers> > Thanks a lot to all, OV > > [[alternative HTML version deleted]]
The warning means that you have many cells with expected values less than 5 (4 of 8 cells in this case) so that the chi square estimate may be inflated. The good news is that the probability of the inflated chi square is .0978 which you probably would not consider to be significant anyway. If you want to get a simulated p value using Monte Carlo simulation (see the references in the manual page for chisq.test), just change the call to chisq.test(tabele, simulate.p.value=TRUE, B=2000) When I run this five times, I get probability estimates ranging from .09795 to .1089. Alternatively, get more data. ---------------------------------------------- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Omphalodes Verna > Sent: Tuesday, June 26, 2012 1:28 PM > To: r-help at r-project.org > Subject: [R] chisq.test > > Dear list! > > I would like to calculate "chisq.test" on simple data set with 70 > observations, but the output is ''Warning message:'' > > Warning message: > In chisq.test(tabele) : Chi-squared approximation may be incorrect > > > Here is an example: > > tabele <- matrix(c(11, 3, 3, 18, 3, 6, 5, 21), ncol = 4, byrow > = TRUE) > dimnames(tabela) <- list( > "SEX" = c("M","F"), > "HAIR" = c("Brown", "Black", "Red", "Blonde")) > addmargins(tabele) > prop.table(tabele) > chisq.test(tabele) > Please, give me an advice / suggestion / recommendation. > > Thanks a lot to all, OV > > [[alternative HTML version deleted]]
On Jun 26, 2012, at 2:27 PM, Omphalodes Verna wrote:> Dear list! > > I would like to calculate "chisq.test" on simple data set with 70 > observations, but the output is ''Warning message:'' > > Warning message: > In chisq.test(tabele) : Chi-squared approximation may be incorrect > > > Here is an example: > > tabele <- matrix(c(11, 3, 3, 18, 3, 6, 5, 21), ncol = 4, > byrow = TRUE) > dimnames(tabela) <- list( > "SEX" = c("M","F"), > "HAIR" = c("Brown", "Black", "Red", "Blonde")) > addmargins(tabele) > prop.table(tabele) > chisq.test(tabele) > Please, give me an advice / suggestion / recommendation.Read any introductory stats book regarding small cell sizes: [,1] [,2] [,3] [,4] [1,] 11 3 3 5 [2,] 3 18 6 21>-- David Winsemius, MD West Hartford, CT
Dear all! Thanks for clarification. OV ________________________________ To: Rolf Turner <rolf.turner@xtra.co.nz> Sent: Wednesday, June 27, 2012 1:33 PM Subject: Re: [R] chisq.test Hi Rolf, Thanks for spotting the mistake. A.K. ----- Original Message ----- From: Rolf Turner <rolf.turner@xtra.co.nz> .org> Sent: Wednesday, June 27, 2012 12:58 AM Subject: Re: [R] chisq.test On 27/06/12 08:54, arun wrote:> > Hi, > > The error is due to less than 5 observations in some cells.NO, NO, NO!!!! It's not the observations that matter, it is the ***EXPECTED COUNTS***. These must all be at least 5 in order for the null distribution of the test statistic to be adequately approximated by a chi-squared distribution. cheers, Rolf Turner> > You can try, > fisher.test(tabele) > Fisher's Exact Test for Count Data > > data: tabele > p-value = 0.0998 > alternative hypothesis: two.sided > > A.K. > > > > ----- Original Message -----> To: "r-help@r-project.org" <r-help@r-project.org> > Cc: > Sent: Tuesday, June 26, 2012 2:27 PM > Subject: [R] chisq.test > > Dear list! > > I would like to calculate "chisq.test" on simple data set with 70 observations, but the output is ''Warning message:'' > > Warning message: > In chisq.test(tabele) : Chi-squared approximation may be incorrect > > > Here is an example: > > tabele <- matrix(c(11, 3, 3, 18, 3, 6, 5, 21), ncol = 4, byrow = TRUE) > dimnames(tabela) <- list( > "SEX" = c("M","F"), > "HAIR" = c("Brown", "Black", "Red", "Blonde")) > addmargins(tabele) > prop.table(tabele) > chisq.test(tabele) > Please, give me an advice / suggestion / recommendation. > > Thanks a lot to all, OV > > [[alternative HTML version deleted]] > > > ______________________________________________ > 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. >[[alternative HTML version deleted]]