# Week 9: The Binomial Sign Test for a Single Sample

Today we’re going to look at another nonparametric test: the binomial sign test for a single sample!

When Would You Use It?
The binomial sign test is used in a single sample situation to determine, in a population comprised of two categories, if the proportion of observations in one of the two categories is equal to a specific value.

What Type of Data?
The binomial sign test requires categorical (nominal) data.

Test Assumptions
None listed.

Test Process
Step 1: Formulate the null and alternative hypotheses. The null hypothesis claims that the true proportion of observations in one of the two categories, in the population, is equal to a specific value. The alternative hypothesis claims otherwise (the proportion is either greater than, less than, or not equal to the value claimed in the null hypothesis.

Step 2: Compute the test statistic, a probability value. The test statistic is calculated as follows: That is, your test statistic is the probability of attaining ≥ r observations from “category 1” in a sample of size n, where r is the number of observations from “category 1” in your original sample.

While you can calculate this value by hand, it may be easier to either use a table or an online calculator.

Step 3: Obtain the p-value. If your alternative hypothesis is non-directional (that is, uses “≠”), your p-value is equal to α/2. If your alternative hypothesis is directional (uses “>” or “<”, your p-value is simply equal to α.

Step 4: Determine your conclusion. This depends on your alternative hypothesis. Let p1 denote the sample proportion of observations falling into “category 1”, and let P denote the test statistic value, as calculated above.

If it is nondirectional (≠) reject H0 if P < α/2.
If the alternative hypothesis is directional (>), reject H0 if p1 > π1 and P < α.
If the alternative hypothesis is directional (<), reject H0 if p1 < π1 and P < α.

Example
For this example, I decided to see if the coin flips from the website Just Flip a Coin were, binomially distributed with π1 = π2 = 0.5. I “flipped” the coin a total of 30 times and recorded my results for “category 1” (heads) and “category 2” (tails). The outcomes are displayed in the table below.

H0: π1 = 0.5
Ha: π1 ≠ 0.5

Set α = 0.05.

Computations:  Since P = 0.1002 > 0.025 (α/2 = 0.05/2 = 0.025), we fail to reject H0, the claim that proportion of the number of heads is equal to 0.5 in the population.

Example in R

```x = read.table('clipboard', header=F)
pi1= 0.5                                 #hypothesized probability for "heads"
n = length(as.matrix(x))
tab = as.data.frame(table(x))            #observed frequencies
p1 = tab[1,2]
P = 1 - pbinom(p1, size = n, prob = pi1) #test statistic```