statistics z-test for proportion

367 Views Asked by At

you own a casino and suspect that the employee who run the coin flipping game is cheating with an unfair coin. she reports that out of 200 flips, 120 of them are heads. assume a fair coin would come up heads 50% of the time. test your claim at a significance level of .01

H0(null hypothesis):p=.5 & H1(alternative hypothesis):p does not equal .5 (claim)

so N=200

x=120

p=.5

q=1-p=1-.5=.5

p(hat)=x/n= 120/200=.6

calculating the significance for the distribution drawing is the easy part o i will skip any calculations for that.

I've tried z=p(hat)-p/squareroot pq/n

after i plugged in the numbers....

.6-.5/squareroot (.5)(.5)/200

.1/squareroot.25/200

2.83

i feel like the answer is supposed to be closer to .50 than what it really is. Perhaps im using the wrong formula but the work should be correct otherwise

2

There are 2 best solutions below

1
On

The best way is to use an exact test: The p-value is equal to P(X>120), where X is the number of heads from 200 coin flips where the probability of a head is 0.5 for each flip. That is, the probability that a result at least as extreme as the one that was obtained (120 heads) would result if the null hypothesis (pr of head=0.5) is true. If p-value<0.01, you reject the null of a fair coin in favor of a biased one. The p-val I get is 0.001817474, so reject.

To use the normal approximation, note the mean is 0.5, variance of the mean pq/n (CLT) = pq = 0.5*(1-0.5)/200 = 0.00125. (pq is the variance of a single Bernoulli trial). So SD = 0.03535533905. Since the observed mean -- 0.6 -- is more than 3 SD's away from the mean, again, it's clear it's going to be significant at the 1% level, since 3 SD's away from the mean contain only 0.03% of the distribution when the distribution is normal, which is what we're assuming for this approximation.

0
On

The exact binomial test is what you need: it compares the number of successes that are observed in a given number of trials with a hypothesized probability of success.. the proportion test is an approximate.. I'll demonstrate methods in R..

Using the Exact Binomial Test... P-value ~ $.005685$

 binom.test(c(120,80),.5,conf=.99)

Using the Proportion Test... P value ~ $.00582$

 prop.test(120,200,.5,conf=.99)

Using pbinom... P value ~ $.005685$

 2*pbinom(119, 200, .5, lower.tail = FALSE)

NOTE the similarities and differences from the 3 methods I provide.

Lastly, there is a reason pbinom is multiplied by 2 but it is not just for no reason, it is the because expected value (under H0) is n*p = 200(.5) = $100$..Thus $120$ is $20$ units higher than this expected value..Now we calculate the probability of an outcome that is $20$ units less (or lower) than the expected value, so $100$ - $20$ is $80$

 pbinom(119, 200, .5, lower.tail=FALSE) + pbinom(80,200,.5) = .005685

Same results from above, as we would have expected

Slightly different results for the prop.test. If you CAN use exact (binom) then that is obviously much better than approximating (using normal) but since the CLT is obviously satisfied then approximating with normal is ok if that's what you want to do, but its always smarter to use the exact over the approximate (especially in research, etc.). If this is for class you could always supply both methods and talk about the exactness vs the approximation

Here is a density plot of binom(200,.5) where the 2 tailed p-value is the area to the left of 80 and to the right of 120.

enter image description here