In this chapter we compared the weights of male and female penguins and computed a confidence interval for the difference. Now let’s do the same for flipper length. The observed difference is about 4.6 mm.
Use sampling_dist_mean to make Normal objects that represent sampling distributions for the mean flipper length in the two groups—noting that the groups are not the same size. Then compute the sampling distribution of the difference and a 90% confidence interval.
Using the NSFG data, we computed the correlation between a baby’s birth weight and the mother’s age, and we used a \(t\) distribution to compute a p-value. Now let’s do the same with birth weight and father’s age, which is recorded in the hpagelb column.
$ data = valid["hpagelb"].values, valid["totalwgt_lb"].values
r_actual = correlation(data)
r_actual
np.float64(0.06468629895432174)
Compute the transformed correlation, t_actual. Use the CDF of the \(t\) distribution to compute a p-value—is this correlation statistically significant? Use the SciPy function pearsonr to check your results.
In one of the exercises in Chapter 9 we considered the Trivers-Willard hypothesis, which suggests that for many mammals the sex ratio depends on “maternal condition”—that is, factors like the mother’s age, size, health, and social status. Some studies have shown this effect among humans, but results are mixed.
As an example, and a chance to practice a chi-squared test, let’s see if there’s a relationship between the sex of a baby and the mother’s marital status. The notebook for this chapter has instructions to help you get started.
Use observed and expected to compute a chi-squared statistic. Then use the CDF of the chi-squared distribution to compute a p-value. The degrees of freedom should be n-1, where n is the number of values in the observed DataFrame. Then use the SciPy function chisquared to compute the chi-squared statistic and p-value. Hint: use the argument axis=None to treat the entire DataFrame as a single test rather than one test for each column.
The method we used in this chapter to analyze differences between groups can be extended to analyze “differences in differences”, which is a common experimental design. As an example, we’ll use data from a 2014 paper that investigates the effects of an intervention intended to mitigate gender-stereotypical task allocation within student engineering teams.
Stein, L. A., Aragon, D., Moreno, D., Goodman, J. (2014, October). Evidence for the persistent effects of an intervention to mitigate gender-stereotypical task allocation within student engineering teams. In 2014 IEEE Frontiers in Education Conference (FIE) Proceedings (pp. 1-9). IEEE. Available from ieeexplore.ieee.org.
Before and after the intervention, students responded to a survey that asked them to rate their contribution to each aspect of class projects on a 7-point scale.
Before the intervention, male students reported higher scores for the programming aspect of the projects than female students: men reported an average score of 3.57 with standard error 0.28; women reported an average score of 1.91 with standard error 0.32.
Make four Normal objects to represent the sampling distributions of the estimated means before and after the intervention, for both male and female students. Because we have standard errors for the estimated means, we don’t need to know the sample size to get the parameters of the sampling distributions.
Then compute the sampling distribution of the difference in differences—that is, the change in the size of the gap. Compute a 95% confidence interval and a p-value.