# [R] one-sample binomial test

Tim Wilson wilson at visi.com
Sat Jul 6 06:05:07 CEST 2002

```Hi everyone,

Here's how I solved a problem for my stats class. I'm pretty sure I
understand what's going on, but I wonder if there's a more direct way to
solve it.

Problem summary:

A recent poll indicated that Candidate A is leading B with 55% of the
vote. How many voters need to be surveyed to ensure a margin of error of
+/- 2.5% with 99% confidence.

Here's what I did:

> binom.test(55, 100, 0.5, alternative='t', conf.level=0.99)

Exact binomial test

data:  55 and 100
number of successes = 55, number of trials = 100, p-value =
0.3682
alternative hypothesis: true probability of success is not equal
to 0.5
99 percent confidence interval:
0.4170382 0.6780727
sample estimates:
probability of success
0.55

After some trial and error I got:

> binom.test(1100, 2000, 0.5, alternative='t', conf.level=0.99)

Exact binomial test

data:  1100 and 2000
number of successes = 1100, number of trials = 2000, p-value =
8.457e-06
alternative hypothesis: true probability of success is not equal
to 0.5
99 percent confidence interval:
0.5210033 0.5787563
sample estimates:
probability of success
0.55

So my answer is that you would need to survey more than 2000 persons. Is
there a way other than trial and error to solve this?

-Tim

--
Tim Wilson      |   Visit Sibley online:   | Check out:
Henry Sibley HS |  http://www.isd197.org   | http://www.zope.com
W. St. Paul, MN |                          | http://slashdot.org
wilson at visi.com |  <dtml-var pithy_quote>  | http://linux.com
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

```