# Statistical Inference

Revisit statistical inference with a new dataset.

We'll cover the following

The key to the substantive question asked earlier is whether the male and happy variables are statistically independent of each other in the population. If they are independent of each other, then there’s no gender difference in self-reported happiness. If they aren’t independent of each other, then there is a gender difference in self-reported happiness. For a two-way contingency table of two discrete variables, statistical independence means that the joint probabilities are equal to the product of the marginal probabilities. In light of this information, the null and alternative hypotheses can be rephrased as follows:

• Null hypothesis: The male and happy variables are statistically independent of each other. (Technically, the joint probability for each cell is equal to the product of the corresponding marginal probabilities, which holds for all four cells.)

• Alternative hypothesis: The male and happy variables aren’t statistically independent of each other. (Technically, the joint probability for at least one cell does not is equal to the product of the corresponding marginal probabilities.)

## Chi-squared test#

A commonly used test is the Chi-squared testA chi-square test is a statistical test used to compare observed results with expected results. of independence, Following the procedures of statistical inference in previous sections, we compare the p value of the test statistic with the acceptable Type I error rate, $\alpha$, and draw our conclusion. The R code and output are as follows:

Get hands-on with 1200+ tech skills courses.