Hi Crawbears,
In a previous post, I examined baby circadian clocks, specifically the difference in night bedtime and sleep duration between napping and non-napping babies. Today, I’ll work with the National Health and Nutrition Examination Survey (NHANES) 2016 data set. NHANES is a yearly national cross-sectional study conducted by the CDC that assesses the health of the U.S. population, collecting thousands of health, diet, demographic, and socioeconomic variables. I’ll use it to answer four questions:
Question 1: What is the difference in systolic blood pressure (mmHg) between men and women in the U.S.?
Question 2: What proportion of black (non-hispanic) Americans has been uninsured in the past year?
Question 3. Is the proportion of black Americans uninsured in the past year greater than that of white Americans?
Question 4: Does the proportion of U.S. smokers that are hypertensive (systolic blood pressure >130 mmHg) differ from that of non-smokers?
In this analysis, I formulate clear, focused questions that detail our target populations and parameters, hypotheses, alpha, and assumptions upfront. This part is super-important in order to perform a high quality analysis, draw the right conclusions, and not go down rabbit holes. A key difference here compared to my previous post is that for questions 2, 3, and 4, we’ll work with difference in proportion of categorical data (not difference in mean of continuous data), which requires a bit more transformation and subsetting to get at the data we need to answer our questions. I walk through subsetting and creating relevant dataframes for each analysis using pd.groupby, pd.crosstab, and pd.cut and applying numpy and statsmodels functions for analysis. I use simplifying assumptions of random, independent sampling and normally distributed populations with similar variances (pooled standard error).
To answer Question 1, we use pd.groupby and .agg to group and aggregate data by gender and a 2-sided P-value using 1-t.cdf and sm.stats.ttest_ind. To answer Question 2, we use pd.crosstab to group by ethnicity and calculate a 95% confidence interval using both sm.stats.proportion_confint and generating lower and upper confidence bounds manually. To answer Question 3, we calculate a 1-sided P-value using 1-t.cdf, t.sf, and sm.stats.ttest_ind (and halving the result). To answer Question 4, we calculate a 2-sided P-value using 1-t.cdf and sm.stats.ttest_ind. For pooled standard error, we use pd.concat to combine dataframes. Importantly, throughout, I walk through how to interpret and communicate results and conclusions. In future posts, I will take our analysis a step further and fit linear and logistic regression models to uncover associations and make predictions.
Check out my code, explanatory notes, analysis, and conclusions below.



Thanks for reading and sending your questions! As always, reach out anytime and say hi at info@crawstat.com.
Keep exploring,
Rish