[R] ?Accuracy of prop.test
Greg.Snow at imail.org
Mon Jul 18 22:51:23 CEST 2011
Others have explained why R gives a different answer based on a different approximation, but if you want to get the same answer as the book/minitab/... for your own understanding (or so the grader doesn't get confused by superior answers, or other reasons) here is one way to do it:
> x <- c( rep(1,202), rep(0, 1010-202) )
> p <- 202/1010
> sd <- sqrt( p*(1-p) )
> z.test( x, 0.5, sd )
One Sample z-test
z = -23.8354, n = 1010.000, Std. Dev. = 0.400, Std. Dev. of the sample
mean = 0.013, p-value < 2.2e-16
alternative hypothesis: true mean is not equal to 0.5
95 percent confidence interval:
mean of x
Which matches the others you reported below.
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
greg.snow at imail.org
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Jack Sofsky
> Sent: Sunday, July 17, 2011 10:27 AM
> To: r-help at r-project.org
> Subject: [R] ?Accuracy of prop.test
> I have just joined this list (and just started using R), so please
> excuse any etiquette breaches as I do not yet have a feel for how the
> list operates.
> I am in the process of teaching myself statistics using R as my utility
> as my ultimate goals cannot be satisfied by Excel or any of the plug-
> I could afford.
> I am currently looking at chap12 page 552 of Weiss's Introductory
> Statistics 9th edition. Example 12.5 demonstrates using "Technology"
> obtain a One-Proportion z-Interval.
> confidence interval = .95.
> Answer given by Minitab
> 0.175331, .224669
> Answer given by TI-83/84
> .17533, .22467
> Answer given by Weiss's Excel Plug-in
> 0.175 < p < 0.225
> Here is what I got with R
> 1-sample proportions test without continuity correction
> data: 202 out of 1010, null probability 0.5
> X-squared = 363.6, df = 1, p-value < 2.2e-16
> alternative hypothesis: true p is not equal to 0.5
> 95 percent confidence interval:
> 0.1764885 0.2257849
> sample estimates:
> I'm also getting slight differences in the answers for exercises and
> find this disconcerting.
> Why are these differences present (or am I doing something wrong)?
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help