An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120626/975c9df4/attachment.pl>
chisq.test
8 messages · Omphalodes Verna, arun, Peter Ehlers +4 more
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
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 -----
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. ______________________________________________ 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 Wed, 27 Jun 2012 16:58:29 +1200
Rolf Turner <rolf.turner at xtra.co.nz> wrote:
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
Pretty sure the point was that in a situation where the expected counts are too low for a reliable chi-square, that an alternate test such as the nonparametric Fisher's Exact Test may be the way to go, especially if there isn't nay more data to get. That way you don't have to worry about expected counts. JDougherty
On 2012-06-26 23:02, John wrote:
On Wed, 27 Jun 2012 16:58:29 +1200 Rolf Turner<rolf.turner at xtra.co.nz> wrote:
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
Pretty sure the point was that in a situation where the expected counts are too low for a reliable chi-square, that an alternate test such as the nonparametric Fisher's Exact Test may be the way to go, especially if there isn't nay more data to get. That way you don't have to worry about expected counts. JDougherty
That may well be; nevertheless, the post included the statement Rolf quotes: "... less than 5 _observations_ in some cells" (my emphasis). And Rolf's point is quite correct - it's the _expected_ counts that the approximation cares about. Peter Ehlers