The Binomial Test

5.1.2 The Binomial Test

The binomial or proportion test is used to assess whether there is evidence from the sample that one category of a dichotomised population occurs in a certain

5.1 Inference on One Population

proportion of times. Let us denote the categories or classes of the population by ω, coded 1 for the category of interest and 0 for the complement. The two-tailed test can be then formalised as:

Given a data sample with n i.i.d. cases, k of which correspond to ω =1, we know from Chapter 3 (see also Appendix C) that the point estimate of p is pˆ = k/n. In order to establish the critical region of the test, we take into account that the probability of obtaining k events of ω =1 in n trials is given by the binomial law. Let K denote the random variable associated to the number of times that ω=1 occurs in a sample of size n. We then have the binomial sampling distribution (section A.7.1):

k n −  k  p q ;

 k  When n is small (say, below 25), the non-critical region is usually quite large

and the power of the test quite low. We have also found useless large confidence intervals for small samples in section 3.3, when estimating a proportion. The test yields useful results only for large samples (say, above 25). In this case (especially when np or nq are larger than 25, see A.7.3), we use the normal approximation of the standardised sampling distribution:

K − np Z =

~ N 0 , 1 5.3 npq

Notice that denoting by P the random variable corresponding to the proportion of successes in the sample (with observed value pˆ = k/n), we may write 5.3 as:

The binomial test is then performed in the same manner as the test of a single mean described in section 4.3.1. The approximation to the normal distribution becomes better if a continuity correction is used, reducing by 0.5 the difference between the observed mean ( nˆ p ) and the expected mean (np).

As shown in Commands 5.3, SPSS and R have a specific command for carrying out the binomial test. SPSS uses the normal approximation with continuity correction for n > 25. R uses a similar procedure. In order to perform the binomial test with STATISTICA or MATLAB, one uses the single sample t test command.

176 5 Non-Parametric Tests of Hypotheses

Example 5.3

Q: According to Mendel’s Heredity Theory, a cross breeding of yellow and green peas should produce them in a proportion of three times more yellow peas than green peas. A cross breeding of yellow and green peas was performed and produced 176 yellow peas and 48 green peas. Are these experimental results explainable by the Theory?

A: Given the theoretically expected values of the proportion of yellow peas, the test is formalised as:

H 0 : P( ω =1) = ¾ ;

H 1 : P( ω =1) ≠ ¾.

In order to apply the binomial test to this example, using SPSS, we start by filling in a datasheet as shown in Table 5.2. Next, in order to specify that category 1 of pea-type occurs 176 times and the category 0 occurs 48 times, we use the “weight cases” option of SPSS, as shown in Commands 5.2. In the Weight Cases window we specify that the weight variable is n.

Finally, with the binomial command of SPSS, we obtain the results shown in Table 5.3, using 0.75 (¾) as the tested proportion. Note the “Based on Z Approximation” foot message displayed by SPSS. The two-tailed significance is 0.248, so therefore, we do not reject the null hypothesis P( ω =1) = 0.75.

Table 5.2. Datasheet for Example 5.3.

group pea-type n

Table 5.3. Binomial test results obtained with SPSS for the Example 5.3.

Observed

Asymp. Sig.

Test Prop. (1-tailed) PEA_TYPE Group 1

0.79 0.75 0.124 a Group 2 0 48 0.21 Total 224 1.00

a Based on Z approximation.

Let us now carry out this test using the values of the standardised normal distribution. The important values to be computed are:

np = 224 ×

5.1 Inference on One Population 177

s = npq = 224 × 0 . 75 × 0 . 25 = 6.48.

Hence, using the continuity correction, we obtain z = (168 – 176 + 0.5)/6.48 = −1.157, to which corresponds a one-tailed probability of 0.124 as reported in Table 5.3.

Example 5.4

Q: Consider the Freshmen dataset, relative to the Porto Engineering College. Assume that this dataset represents a random sample of the population of freshmen in the College. Does this sample support the hypothesis that there is an even chance that a freshman in this College can be either male or female?

A: We formalise the test as:

H 0 : P( ω =1) = ½;

H 1 : P( ω =1) ≠ ½.

The results obtained with SPSS are shown in Table 5.4. Based on these results, we reject the null hypothesis with high confidence.

Note that SPSS always computes a two-tailed significance for a test proportion of 0.5 and a one-tailed significance otherwise.

Table 5.4. Binomial test results, obtained with SPSS, for the freshmen dataset.

Asymp. Sig. Category n

Observed

Test Prop.

(2-tailed) SEX Group 1 female

Prop.

35 0.27 0.50 0.000 Group 2 male

Commands 5.2. SPSS and STATISTICA commands used to specify case weighing.

SPSS Data; Weight Cases STATISTICA

Tools; Weight

These commands pop up a window where one specifies which variable to use as weight variable and whether weighing is “On” or “Off”. Many STATISTICA commands also include a weight button (

) in connection with the weight specification window. Case weighing is useful whenever the datasheet presents the

178 5 Non-Parametric Tests of Hypotheses

data in a compact way, with a specific column containing the number of occurrences of each case.

Commands 5.3. SPSS, STATISTICA, MATLAB and R commands used to perform the binomial test.

SPSS Analyze; Nonparametric Tests; Binomial

STATISTICA Statistics; Basic Statistics and Tables; t-test, single sample MATLAB

[h,sig,ci]=ttest(x,m,alpha,tail)

R binom.test(x,n,p,conf.level=0.95)

When performing the binomial test with STATISTICA or MATLAB using the single sample t test, a somewhat different value is obtained because no continuity correction is used and the standard deviation is estimated from pˆ . This difference is frequently of no importance. With MATLAB the test is performed as follows:

» x = [ones(176,1); zeros(48,1)]; » [h, sig, ci]=ttest(x,0.75,0.05,0) h=

sig = 0.195 ci = 0.7316 0.8399

Note that x is defined as a column vector filled in with 176 ones followed by 48 zeros. The commands ones(m,n) and zeros(m,n) define matrices with m rows and n columns filled with ones and zeros, respectively. The notation [A; B] defines a matrix by juxtaposition of the matrices

A and B side by side along the columns (along the rows when omitting the semicolon).

The results of the test indicate that the null hypothesis cannot be rejected ( h=0). The two-tailed significance is 0.195, somewhat lower than previously found (0.248), for the above mentioned reasons.

The arguments x, n and p of the R binom.test function represent the number of successes, the number of trials and the tested value of p, respectively. Other details can be found with help(binom.test). For the Example 5.3 we run binom.test(176,176+48,0.75), obtaining a two-tailed significance of 0.247, nearly the double of the value published in Table 5.3 as it should. A 95% confidence interval of [0.726, 0.838] is also published, containing the observed proportion of 0.786.

5.1 Inference on One Population