# When to use Chi-squared and when Z test for categorical variables?

The problem is:

There was a survey conducted among 1137 adults from California, Nevada, and Oregon. They were chosen randomly and they answered to the following question “Do you think Marijuana should be legalized? Below is the summary of responses.

Answer/Region Calfornian Nevadan Oregonian
Should               264      299     351
Should not           38       55      77
Don't know/No answer 16       15      22
Total                318      369     450

• a. Conduct an appropriate hypothesis test evaluating whether there is a difference in the proportion of Californian and Nevadan who think Marijuana should be legalized.

• b. Calculate a 95% confidence interval for the difference between the proportions of Californian and Nevadan who think Marijuana should be legalized and interpret it in the context of the data.

• c. The conclusion of the test in part (a) may be incorrect, meaning a testing error was made. If an error was made, was it a Type 1 or a Type 2 Error? Explain.

I know how to use normal distribution to calculate the p-value for two binary variables. It is my solution:

$$p ̂_{pool}=(264+299)/(316+369)=0.821$$

$$H_0:p ̂_c-p ̂_n=0 \\ H_1:p ̂_c-p ̂_n≠0 \\ SE=\sqrt{(0.82*0.18)/316+(0.82*0.18)/369}=0.03 \\ p ̂_c-p ̂_n=0.83-0.81=0.02 \\ z=(0.02-0)/0.03=0.66 \\ P(Zz)≈0.51⇒ \text{Fail to Reject } H_0$$

For (b), I use a similar apporach but I use $$p ̂_c$$ nad $$p ̂_n$$ instead of $$p ̂_{pool}$$ to calculate $$SE$$. For (c), I think it's Type II error because we "failed to reject H0".

However, I suspect if I had to use Chi-squared for this problem because I have three columns. Could you please guide me if my solution is correct and when to use this solution and when Chi-squired. Could both approach be applicable here?

• If you have a normal random variable $X \sim \mathcal N(0,1)$, then $X^2$ is $\chi^2_1$ distributed. Thus the $\chi^2$ and $z$-test are essentially the same. See also: stats.stackexchange.com/questions/2391/… May 13 '19 at 9:26