[R] prop.test or chisq.test ..?
Christoph Buser
buser at stat.math.ethz.ch
Wed Feb 28 10:07:22 CET 2007
Hi
Some comments are inside.
Dylan Beaudette writes:
> Hi everyone,
>
> Suppose I have a count the occurrences of positive results, and the total
> number of occurrences:
>
>
> pos <- 14
> total <- 15
>
> testing that the proportion of positive occurrences is greater than 0.5 gives
> a p-value and confidence interval:
>
> prop.test( pos, total, p=0.5, alternative='greater')
>
> 1-sample proportions test with continuity correction
>
> data: 14 out of 15, null probability 0.5
> X-squared = 9.6, df = 1, p-value = 0.0009729
> alternative hypothesis: true p is greater than 0.5
> 95 percent confidence interval:
> 0.706632 1.000000
> sample estimates:
> p
> 0.9333333
>
First of all by default there is a continuity correction in
prop.test(). If you use
prop.test(pos, total, p=0.5, alternative="greater", correct = FALSE)
1-sample proportions test without continuity correction
data: pos out of total, null probability 0.5
X-squared = 11.2667, df = 1, p-value = 0.0003946
alternative hypothesis: true p is greater than 0.5
95 percent confidence interval:
0.7492494 1.0000000
sample estimates:
p
0.9333333
Remark that know the X-squared is identical to your result from
chisq.test(), but the p-value is 0.0007891/2
The reason is that you are testing here the against the
alternative "greater"
If you use a two sided test
prop.test(pos, total, p=0.5, alternative="two.sided", correct = FALSE)
then you reporduce the results form chisq.test().
>
> My question is how does the use of chisq.test() differ from the above
> operation. For example:
>
> chisq.test(table( c(rep('pos', 14), rep('neg', 1)) ))
>
> Chi-squared test for given probabilities
>
> data: table(c(rep("pos", 14), rep("neg", 1)))
> X-squared = 11.2667, df = 1, p-value = 0.0007891
>
> ... gives slightly different results. I am corrent in interpreting that the
> chisq.test() function in this case is giving me a p-value associated with the
> test that the probabilities of pos are *different* than the probabilities of
> neg -- and thus a larger p-value than the prop.test(... , p=0.5,
> alternative='greater') ?
>
Yes. In your example chisq.test() tests the null hypothesis if
all population probabilities are equal
?chisq.test says:
"In this case, the hypothesis tested is whether the population
probabilities equal those in 'p', or are all equal if 'p' is not
given."
which means p1 = p2 = 0.5 in your two population case against
the alternative p1 != p2.
This is similar to the test in prop.test() p=0.5 against p!=0.5
and therefore you get identical results if you choose
alternative="two.sided" in prop.test().
> I realize that this is a rather elementary question, and references to a text
> would be just as helpful. Ideally, I would like a measure of how much I
> can 'trust' that a larger proportion is also statistically meaningful. Thus
> far the results from prop.test() match my intuition, but
> affirmation would be
Your intuition was correct. Nevertheless in your original
results (with the continuity correction), the p-value of
prop.test() (0.0009729) was larger than the p-value of
chisq.test() (0.0007891) and therefore against your intuition.
> great.
>
> Cheers,
>
>
> --
> Dylan Beaudette
> Soils and Biogeochemistry Graduate Group
> University of California at Davis
> 530.754.7341
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
Hope this helps
Christoph Buser
--------------------------------------------------------------
Credit and Surety PML study: visit our web page www.cs-pml.org
--------------------------------------------------------------
Christoph Buser <buser at stat.math.ethz.ch>
Seminar fuer Statistik, LEO C13
ETH Zurich 8092 Zurich SWITZERLAND
phone: x-41-44-632-4673 fax: 632-1228
http://stat.ethz.ch/~buser/
More information about the R-help
mailing list