To test a claim about a population proportion using a single sample from that population ...

**R**: One can use the following function to conduct an (exact) hypothesis test to decide if there is evidence the proportion of a population that has a certain characteristic differs from some assummed value, even when the sample size is small.binom.test(x, n, p, alternative = "two.sided", conf.level = 0.95)

To explain the paramaters:

`x`

is the observed number of "successes" (whatever that means),`n`

is the number of trials,`p`

is the hypothesized probability of "success" (i.e., the value of $p$ in the null hypothesis),`alternative`

is one of three strings: "less", "greater", or "two.sided", in accordance with the alternative hypothesis, and`conf.level`

is associated with the significance level for the test. (e.g., when the significance level is $0.01$ for a two-sided test, the confidence level will be $0.99$.)

Consider the following example:

Suppose in a presidential election, 308 out of 611 voters surveyed said that they voted for the candidate that was going to win. We wish to use a 0.01 significance level to test the claim that among all voters, the percentage who believe that they voted for the candidate that was going to win is 43%.

In R, this is quickly accomplished with

> binom.test(308,611,0.43,"two.sided",0.99)

which produces output:Exact binomial test data: 308 and 611 number of successes = 308, number of trials = 611, p-value = 0.0002324 alternative hypothesis: true probability of success is not equal to 0.43 99 percent confidence interval: 0.4513079 0.5568106 sample estimates: probability of success 0.5040917

We can see that the $p$-value reported (i.e., 0.0002324) is well under the significance level of $0.01$, and as such we reject the null hypothesis and conclude there is significant statistical evidence that the true percentage of all voters who believe they voted for the candidate that was going to win is not 43%.