# Chapter 8:Hypothesis Testing for Population Proportions

## Testing a claim

we calculated a 95$$\%$$ confidence interval for the true population proportion of UCLA students who travelled outside the US. $(0.26,0.44)$ A 95$$\%$$ confidence interval of 26$$\%$$ to 44$$\%$$ means that

• We are 95$$\%$$ confident that the true population proportion of UCLA students who travelled outside the US is between 26$$\%$$ and 44$$\%$$.

• 95$$\%$$ of random samples of size n = 100 will produce confidence intervals that contain the true population proportion.

• The true population proportion,p, may be outside the interval,but we would expect it to be somehwat close to $$\hat{p}$$

• In our random sample of 100 students we had found that 35 of them have at some point in their lives travelled outside the US,$$\hat{p}$$= 0.35.

• It is difficult to decide how close is close enough, or how far is too far, and this decision should not be made subjectively.

# Hypothesis Testing

• In Statistics when testing claims we use an objective method called hypothesis testing

• Given a sample proportion, ￼ , and sample size, n, we can test claims about the population proportion, p.

• We call these claims hypotheses

• Our starting point, the status quo, is called the null hypothesis and the alternative claim is called the alternative hypothesis.

• If our null hypothesis was that p = 0.35 and our sample yields ￼ = 0.35, then the data are consistent with the null hypothesis, and we have no reason to not believe this hypothesis.

• This doesn’t prove the hypothesis but we can say that the data support it.

If our null hypothesis was different than p=0.35, lets say p=30 and our sample yields $$\hat{p}$$, then the data are not consistent with the hypothesis and we need to mke choices as to whethere this inconsistency is large enough to not believe the hypothesis.

• If the inconsistency is significant, we reject the null hypothesis

## Example for hypothesis testing for one proportion

Research conducted a few years ago showed that 35$$\%$$ of UCLA students had travelled outside the US. UCLA has recently implemented a new study abroad program and results of a new survey show that out of the 100 randomly sampled students 42 have travelled abroad. Is there significant evidence to suggest that the proportion of students at UCLA who have travelled abroad has increased after the implementation of the study abroad program?

• population proportion used to 0.35

• new sample proportion is 0.42

• Testing the claim that the population proportion is now greater than 0.35 .

• But is this difference statistically significant, i.e. are the data inconsistent enough?

• We do a formal hypothesis test to answer this question.

# Setting up Hypotheses

• Null hypothesis, denoted by Ho, specifies a population model parameter of interest and proposes a value for that parameter (p). $H_0: p=0.35$

• Alternative hypothesis, denoted by HA, is the claim we are testing for.$H_A :p > 0.35$

• Even though we are testing for the alternative hypothesis, we check to see whether or not the null hypothesis is plausible.

• If the null hypothesis is not plausible, we reject the null hypothesis and conclude that there is sufficient evidence to support the alternative. If the null hypothesis is plausible, we fail to reject the null hypothesis and conclude that there isn’t sufficient evidence to support the alternative.

## Why do we check if Ho is plausible and not if HA is plausible?

The same logic used in jury trials is used in statistical tests of hypothesis

• We begin by assuming that the null hypothesis is true.

• Next we consider whether the data are consistent with this hypothesis.

• If they are, all we can do is retain the hypothesis we started with. If they are not, then like a jury, we ask whether they are unlikely beyond a reasonable doubt.

• Hypothesis testing is very much like a court trial

• this doesnt prove the hypothesis but we can say that the data supports it

• H_0:Defendant is innocent
H_A:Defendant is guility

• We then present the evidence-collect data

• Then we judge the evidence - “Could these data plausibly have happened by chance if the null hypothesis were true?

• If they were very unlikely to have occurred, then the evidence raises more than a reasonable doubt in our minds about the null hypothesis.

• Ultimately we must make a decision. How unlikely is unlikely?

If the evidence is not strong enough to reject the presumption of innocent, the jury returns with a verdict of “not guilty”

• The jury does not say that the defendant is innocent.

• All it says is that there is not enough evidence to convict, to reject innocence.

• The defendant may, in fact, be innocent, but the jury has no way to be sure.

• Said statistically, we fail to reject the null hypothesis.

• We never declare the null hypothesis to be true, because we simply do not know whether it’s true or not.

• Therefore we never“accept the null hypothesis”

## How do we determine if H_0 is plausible?

• In Statistics we can quantify our level of doubt.

• How unlikely is it to get a random sample of 100 students where 42 have travelled abroad if in fact the true population proportion is 35$$\%$$?

• How unlikely is it to get a random sample of 100 students where 42 have travelled abroad if in fact the true population proportion is 35$$\%$$? To answer this question we use the model proposed by the null hypothesis as a given and calculate the probability that the event we have witnessed could happen.
Prob( Observed or more extreme outcome $$\vert$$ H_0 true)=Prob($$\hat{p}$$ > 0.42 $$\vert$$ p=0.35)

• This probability quantifies exactly how suprised we are to see our results and is called the $$\textbf{p-value}$$

## Calculating the p-value

• First we calculate the test statistic(Z-score)

• Test statistic used for hypothesis testing for proportions is a z-score $\frac{obs-mean}{SD}$

• Remember CLT: in calculating z-score we use the mean and SD by THE CLT, and observed value is $\hat{p} \approx N\left(mean=p,SD=\sqrt{\frac{p(1-p)}{n}}\right)$

$$\textbf{P comes from null hypothesis}$$

## Check the Conditions for the CLT

• Random and Independent: The sample is collected randomly and the trials are independent of each ot

• Large Sample:

• Sample has at least 10 successes, $$np \geq 10$$

• at least 10 failures $$n(1-p) \geq 10$$

• Large Population: If the sample is collected without replacement, then the population size is at least 10 times the sample size.

## Example of calculating p-value for study abroad stats

We have that $$H_0:p=0.35$$ and H_A:$$p>0.35$$ $z-score=\frac{\hat{p}-p}{\sqrt{\frac{p(1-p)}{n}}}=\frac{0.42-0.35}{\sqrt{\frac{0.35*0.65}{100}}}=1.47$ and p-value$Prob(\hat{p} > 0.42 \vert p=0.35=prob(z>1.47)=1-0.9292=0.0708$

## Decision based on the p-value

• When the data are consistent with the model from the null hypothesis, the p-value is high and we are unable to reject the null hypothesis.

• In that case, we have to“retain” the null hypothesis.

• We can’t claim to have proved it; instead we fail to reject the null hypothesis and conclude that the difference we observed between the null hypothesis (p = 0.35) and the observed outcome ($$\hat{p}$$￼ = 0.42) is due to natural sampling variability (or chance).

• If the p-value is low enough, we reject the null hypothesis since what we observed would be very unlikely if in fact the null model was true.

• We call such results statistically significant

## How low a p-value is low enough?

• we compare the p value to a give $$\alpha$$:
if pvalue < $$\alpha$$ $$\rightarrow$$ Reject H_0

• There is sufficient evidence to suggest to H_A is plausible
if p value > $$\alpha$$ $$\rightarrow$$ fail to reject H_0

• There is not sufficient evidence to suggest that HA is plausible. The difference we are seeing between the null model and the observed outcome is due to natural sampling variability.

• When p-value is low, it indicates that obtaining the observed $$\hat{p}$$ or even a more extreme outcome is highly unlikely under the assumption that Ho is true, therefore we reject that assumption. $$\alpha$$ level is the complement of the confidence level.

Remember: $$\textbf{When constructing confidence intervals if a confidence level is not specified use 95 percent confidence}$$

• Since 1 − 0.95 = 0.05, if a $$\alpha$$ level is not specified use $$\alpha$$= 0.05

## Decision based on the p-value

with a p-value of 0.0708, do we reject of fail to reject H_0?
Since p value is greater than $$\alpha$$ than we fail to reject H_0
What does the conclusion of the hypothesis mean in context of the research question?
Answer: The data do not provide convincing evidence to suggest that the true population proportion of UCLA students who have travelled outside the US has increased.

## Interpreting the p-value

• A p-value is a conditional probability - the probability of the observed or a more extreme outcome given that the null hypothesis is true.
Prob(observed or more extreme outcome $$\vert$$ H_0 true)

• the p value is $$\textbf{not}$$ the probability that null hypothesis is true

• It’s not even the conditional probability that the null hypothesis is true given the data

The following is the correct interpretation of the p value?
If in fact the true population proportion of UCLA students who have travelled outside the US is 0.35, the probability of getting a random sample where the sample proportion is 0.42 or higher would be 0.0708.

• When testing for population proportions, there are three possible alternative hypotheses:

• H_A: p<P_0

• H_A: p>p_0

• H_A:p $$\neq$$ p_0

• We decide on which alternative hypothesis to use based on we hypothesize (or what the wording of the question instructs as to hypothesize):

• Smaller, less, decreased, fewer

• Larger, greater, more, increased

• Different, not equal to, changed

• We DO NOT decide on which alternative hypothesis to use based on what the data suggest.

• HA: parameter ≠ hypothesized value is known as a two-sided alternative because we are equally interested in deviations on either side of the null hypothesis value.

• For two-sided alternatives, the p-value is the probability of deviating in either direction from the null hypothesis value.

• The other two alternative hypotheses are called

• A one-sided alternative focuses on deviations from the null hypothesis value in only one direction.

• Thus, the p-value for one-sided alternatives is the probability of deviating only in the direction of the alternative away from the null hypothesis value.

$$\textbf{THERES MORE TO DO HERE BUT FOR NOW SKIP TO CHAPTER 9}$$