Introduction

This project investigates this significant public health issue using information in the dataset for births in North Carolina, which has been released by OpenIntro. It is essential to understand the variables that affect birth weight because the birth weight of a baby is an essential health indicator.

Research Question

Does the mother’s smoking status affect the baby’s birth weight?

The dataset comprises 150 birth records from North Carolina and includes data from mothers who smoked during pregnancy as well as those who did not smoke during pregnancy. In order to explore our research question, we look into various important variables present in the dataset: smoke (smoked/ did not smoke), weight (birth weight of baby in pounds), weeks (length of pregnancy in weeks), premature (premature/ full term), m_age (mother’s age), and gained (weight gain of mother during pregnancy in pounds).

#The North Carolina births dataset

births <- read_csv("births.csv")
## Rows: 150 Columns: 9
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): premature, sex_baby, smoke
## dbl (6): f_age, m_age, weeks, visits, gained, weight
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
head(births)
## # A tibble: 6 × 9
##   f_age m_age weeks premature visits gained weight sex_baby smoke    
##   <dbl> <dbl> <dbl> <chr>      <dbl>  <dbl>  <dbl> <chr>    <chr>    
## 1    31    30    39 full term     13      1   6.88 male     smoker   
## 2    34    36    39 full term      5     35   7.69 male     nonsmoker
## 3    36    35    40 full term     12     29   8.88 male     nonsmoker
## 4    41    40    40 full term     13     30   9    female   nonsmoker
## 5    42    37    40 full term     NA     10   7.94 male     nonsmoker
## 6    37    28    40 full term     12     35   8.25 male     smoker

Data Analysis

The process begins by importing the dataset and cleaning the data by choosing our desired variables and eliminating missing values from the analysis columns (smoke and weight). This is followed by the application of Exploratory Data Analysis (EDA) functions on the cleaned dataset.

Clean Dataset

library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
clean_births <- births %>%
  select(smoke, weight, weeks, premature, m_age, gained) %>%
  filter(!is.na(smoke), !is.na(weight))

#Check missing value count in cleaned dataset
summary(clean_births)
##        smoke         weight           weeks           premature  
##  Length   :150   Min.   : 1.630   Min.   :26.00   Length   :150  
##  N.unique :  2   1st Qu.: 6.455   1st Qu.:38.00   N.unique :  2  
##  N.blank  :  0   Median : 7.310   Median :39.00   N.blank  :  0  
##  Min.nchar:  6   Mean   : 7.046   Mean   :38.55   Min.nchar:  6  
##  Max.nchar:  9   3rd Qu.: 8.000   3rd Qu.:40.00   Max.nchar:  9  
##                  Max.   :10.130   Max.   :44.00                  
##                                                                  
##      m_age          gained     
##  Min.   :15.0   Min.   : 0.00  
##  1st Qu.:22.0   1st Qu.:22.75  
##  Median :25.0   Median :30.50  
##  Mean   :26.6   Mean   :32.45  
##  3rd Qu.:31.0   3rd Qu.:40.00  
##  Max.   :41.0   Max.   :85.00  
##                 NAs    :2
head(clean_births)
## # A tibble: 6 × 6
##   smoke     weight weeks premature m_age gained
##   <chr>      <dbl> <dbl> <chr>     <dbl>  <dbl>
## 1 smoker      6.88    39 full term    30      1
## 2 nonsmoker   7.69    39 full term    36     35
## 3 nonsmoker   8.88    40 full term    35     29
## 4 nonsmoker   9       40 full term    40     30
## 5 nonsmoker   7.94    40 full term    37     10
## 6 smoker      8.25    40 full term    28     35

Summary Statistics

# Compute summary statistics grouped by smoking status

smoking_summary <- clean_births |>
  group_by(smoke) |>
  summarise(
    count = n(),
    mean_weight = mean(weight, na.rm = TRUE),
    median_weight = median(weight, na.rm = TRUE),
    max_weight = max(weight, na.rm = TRUE),
    mean_weeks = mean(weeks, na.rm = TRUE),
    mean_age = mean(m_age, na.rm = TRUE)) |>
    mutate(
    mean_weight = round(mean_weight, 2),
    max_weight = round(max_weight, 2),
    mean_weeks = round(mean_weeks, 2),
    mean_age = round(mean_age, 2))

smoking_summary
## # A tibble: 2 × 7
##   smoke     count mean_weight median_weight max_weight mean_weeks mean_age
##   <chr>     <int>       <dbl>         <dbl>      <dbl>      <dbl>    <dbl>
## 1 nonsmoker   100        7.18          7.44      10.1        38.6     26.9
## 2 smoker       50        6.78          6.97       9.13       38.5     26

Visualization

# Visualization comparing birth weight by smoking status

library(ggplot2)
ggplot(clean_births, aes(x = smoke, y = weight, fill = smoke)) +
  geom_boxplot(alpha = 0.7, na.rm = TRUE) +
  labs(title = "Baby Birth Weight by Mother's Smoking Status",
    x = "Smoking Status",
    y = "Birth Weight (lbs)",
    fill = "Smoking Status") +
  theme_minimal() +
  theme(legend.position = "none")