Inferential statistics
To get vital health data in tracking for youth body mass index, health officials sent out a youth survey to a nationally representative sample of youths between 14 to 20 years of age as of December 31, 1999. The dataset tracks the age Age
, height in inchesHeight_in
, weight in pounds Weight_lbs
, gender Gender
, and the self reported multiple choice answer to the question, 'How would you describe your weight?' describe_weight
.
The cleaned up dataset of the survey has been loaded as youth_survey_clean
. In this exercise, you will calculate confidence intervals.
pandas, NumPy, and SciPy's statistics package have been loaded as pd
, np
and st
, respectively.
This exercise is part of the course
Analyzing Survey Data in Python
Exercise instructions
- Calculate the confidence interval for the true population mean height,
Height_in
, using a 95% confidence level. - Calculate the confidence interval for the true population mean height,
Height_in
, using a 99% confidence level.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Find confidence interval for mean height with 95% confidence level
conf_95 = st.norm.interval(alpha = ____,
loc = np.mean(____),
scale = st.sem(____))
# Find confidence interval for mean height with 99% confidence level
conf_99 = st.norm.interval(alpha = ____,
loc = np.mean(____),
scale = st.sem(____))
print("conf_95 = ", conf_95)
print("conf_99 = ", conf_99)