Smoking habit: counts and proportions
Birth weight by smoking habit (kg)
Is the difference real? A two-sample t-test
Test result
Where the observed statistic falls
The curve is the t distribution if H₀ were true. The shaded tails beyond the observed t are the p-value; the dotted lines mark ±t*, the cut-offs for rejecting at the chosen α.
Working, step by step
The notebook's printout (two_sample_ttest_summary)
Birth weight against one variable
Correlation matrix
As in the notebook: every numeric column plus a 0/1 dummy for each category (pd.get_dummies(drop_first=True)). Look along the weight_kg row, and spot the pairs that are built from each other: premie and weeks, mature and mother_age, lowbirthweight and weight_kg.
Coefficients
Actual (black) and predicted (red)
Residuals against fitted
No pattern is good. A curve suggests a missing term (try weeks²); a funnel means the spread changes with the fitted value.
Q-Q plot of residuals
Points on the dashed line mean roughly normal residuals. The very premature babies show up as the long lower tail.
Your models
Compare two models
Collinearity check (VIF)
Coefficient table for your last five models
Like the notebook's summary_col: coefficient with stars, standard error in brackets. Watch habit[T.smoker] as variables come and go.
Predict a baby
Show the Python
The same model as notebook code, using the notebook's fit_and_plot(). It gives the same numbers as this page.
About the data
Each row is one birth. weight_kg is the baby's birth weight; habit says whether the mother smoked during pregnancy. The other columns describe the pregnancy (weeks, premie, visits, gained_kg), the parents (mother_age, mature, father_age, whitemom) and the baby (gender, lowbirthweight). Weights were converted from pounds, so they come in steps of about 28 g.
- Built from other columns: premie is weeks < 37, mature is mother_age ≥ 35, and lowbirthweight is weight_kg < 2.5. The last one is the outcome itself, cut in two.
- Missing values: father_age is missing for 171 births. Any model that uses it loses those babies.
- Very premature births (20 to 24 weeks, about 0.5 kg) are real and influential. They bend the weeks relationship.