Lecture #2: Hypothesis Testing in our Coin Flipping Example

We have seen how that we can estimate the probability of getting a head by flipping a coin. We simply set up the theoretical model

where = unknown constant (parameter) and where and thus are random variables, with Yt = 1 if a Head (probability = p) and Yt = 0 if a Tail (probability = 1-p). We then used OLS, or ordinary least squares, to estimate the parameter. We found that the OLS estimator for was just the mean of , which we wrote as

In the last lecture, I proved that

(*)

and also

.

Remember that we have taken a random sample by flipping the coin N times. Note how that the as . This means that if we flip the coin many, many times, the estimate for p will be very close to the actual value of p. This is what is known as a consistent estimator. That is, if (*) is true, and also the variance goes to zero as the sample size increases, then the estimator is consistent. Consistency is a very important and welcomed property for estimators. Most estimators are not consistent. However, in our coin flipping example, , is consistent.

How can we statistically test for a fair coin?

We can do this very precisely using the binomial pdf. However, I would prefer to show you how to use an approximate method which employs the Central Limit Theorem.

The Central Limit Theorem tells us that

as the sample size N gets very large. This means that if we flip the coin many, many times, the Z statistic above is approximately a standard normal random variable. The standard normal variable is shown below

Next, we set up the hypothesis we want to test. The first hypothesis is called the NULL hypothesis and is denoted Ho. We write this as

Ho: p = 1/2

The second hypothesis is called the ALTERNATIVE hypothesis and is written

Ha: p≠1/2

If we reject Ho, then we are deciding that the coin is NOT fair. By the way, we cannot say that we accept Ho regardless of the outcome of the test. The reason for this is that the test cannot distinguish between p = 0.5 and p = 0.4999 for most sample sizes. If we ran the test on both p = 0.5 and p = 0.4999, we would have to accept both, which is mathematically impossible since 0.5 ≠0.4999. Therefore, we have two choices. We can reject Ho---OR---we can decide not to reject Ho. We can never accept Ho. We can never know for certain that p = 1/2. That is all.

As we have stated above, the Central Limit Theorem tells us that

But, what is the value of p? In the above formula, we need the value of p to evaluate the Z statistic, which is our test statistic. The trouble is that we do not know p. The usual way that we get around this problem is that we first assume that Ho is true. This means that p = 0.5. Next we need data. Suppose that we flip our coin 10 times, which is clearly not enough. We should flip it 100 times. Or, maybe we should flip it 1000 times. The more we flip the coin the better our test will be. Well, to hurry things along, let’s flip it 10 times. The outcomes (data) are below.

Data: Use yt for you flip data

t yt

1 1

2 0

3 0

4 1

5 0

6 0

7 1

8 0

9 0

10 0

Given this data, can you say the coin is fair?

Our estimate of p will be the sample mean of our data which we can write as

We can calculate this as . Now, we can state our decision rule.

Decision Rule: We will reject Ho if .

Let’s see if we reject Ho given our data. First, we assume Ho is true. This means that we assume p = 0.5 in the formula for z. Next, we note that N = 10, which is our sample size. Finally, our estimate of p = 0.3. Putting these all together results in

1.265

and therefore we do not reject Ho. We cannot reject the hypothesis that the coin is fair.

The biggest criticism of our method above is that we only flipped the coin 10 times.

Problem: Choose a $10 NT coin and flip it 25 times. Collect your data, enter it into GRETL, and then use GRETL to estimate p. Then, test the hypothesis that p = 0.6 using the Central Limit Theorem, as we did above. I will show you how to use GRETL next time in class.