Read data

dat <- read.csv("Birthweight.csv")
dat
##      id headcirumference length Birthweight Gestation smoker motherage mnocig
## 1  1313               12     17         5.8        33      0        24      0
## 2   431               12     19         4.2        33      1        20      7
## 3   808               13     19         6.4        34      0        26      0
## 4   300               12     18         4.5        35      1        41      7
## 5   516               13     18         5.8        35      1        20     35
## 6   321               13     19         6.8        37      0        28      0
## 7  1363               12     19         5.2        37      1        20      7
## 8   575               12     19         6.1        37      1        19      7
## 9   822               13     19         7.5        38      0        20      0
## 10 1081               14     21         8.0        38      0        18      0
## 11 1636               14     20         8.6        38      0        29      0
## 12 1107               14     20         7.1        38      0        31      0
## 13 1023               13     20         6.6        38      1        30     12
## 14 1369               13     19         7.0        38      1        31     25
## 15  697               13     19         6.6        39      0        27      0
## 16 1600               13     21         6.3        39      0        19      0
## 17   57               14     20         7.3        39      1        23     17
## 18  272               14     20         8.5        39      1        30     25
## 19  569               13     19         5.5        39      1        22      7
## 20  619               13     20         7.5        39      1        23     25
## 21 1522               13     19         6.0        39      1        21     17
## 22  820               13     20         8.3        40      0        24      0
## 23 1016               14     21         9.5        40      0        19      0
## 24 1058               13     20         6.9        40      0        29      0
## 25 1088               14     20         7.2        40      0        24      0
## 26  365               14     20         7.7        40      1        26     25
## 27  532               13     21         7.9        40      1        31     12
## 28  752               14     19         7.3        40      1        27     12
## 29  792               14     21         8.0        40      1        20      2
## 30 1272               12     20         6.0        40      1        37     50
## 31  462               15     22         9.0        41      0        35      0
## 32  755               13     21         7.0        41      0        21      0
## 33 1683               13     21         7.3        41      0        27      0
## 34   27               14     20         7.8        41      1        37     25
## 35 1262               13     21         7.0        41      1        27     35
## 36 1388               13     20         6.9        41      1        22      7
## 37 1764               15     22        10.0        41      1        32     12
## 38  553               14     21         8.6        42      0        24      0
## 39 1191               13     21         8.0        42      0        21      0
## 40 1360               13     22        10.0        44      0        20      0
## 41  223               13     19         8.5        45      1        28     25
## 42 1187               14     20         8.9        44      0        20      0
##    mheight mppwt fage fedyrs fnocig fheight lowbwt mage35 LowBirthWeight
## 1       58    99   26     16      0      66      1      0            Low
## 2       63   109   20     10     35      71      1      0            Low
## 3       65   140   25     12     25      69      0      0         Normal
## 4       65   125   37     14     25      68      1      1            Low
## 5       67   125   23     12     50      73      1      0            Low
## 6       62   118   39     10      0      67      0      0         Normal
## 7       64   104   20     10     35      73      1      0            Low
## 8       65   132   20     14      0      72      0      0         Normal
## 9       62   103   22     14      0      70      0      0         Normal
## 10      67   109   20     12      7      67      0      0         Normal
## 11      64   135   31     16      0      70      0      0         Normal
## 12      64   125   35     16      0      72      0      0         Normal
## 13      64   140   38     14     50      70      0      0         Normal
## 14      63   124   32     16     50      76      0      0         Normal
## 15      63   135   27     14      0      70      0      0         Normal
## 16      64   125   23     14      2      76      0      0         Normal
## 17      62   104   32     12     25      66      0      0         Normal
## 18      67   170   40     16     50      70      0      0         Normal
## 19      62   115   23     14     25      78      1      0            Low
## 20      71   152   23     16      2      71      0      0         Normal
## 21      61   115   24     12      7      70      0      0         Normal
## 22      62   110   31     16      0      68      0      0         Normal
## 23      67   135   19     12      0      72      0      0         Normal
## 24      65   130   30     16     25      71      0      0         Normal
## 25      66   117   29     16      0      71      0      0         Normal
## 26      67   137   30     10     25      71      0      0         Normal
## 27      64   107   41     12     50      75      0      0         Normal
## 28      60   105   37     12     25      66      0      0         Normal
## 29      66   130   24     12     12      73      0      0         Normal
## 30      66   135   31     16      0      68      0      1         Normal
## 31      67   127   31     16     25      73      0      1         Normal
## 32      61   120   25     14     25      72      0      0         Normal
## 33      64   135   37     14      0      66      0      0         Normal
## 34      63   145   46     16      0      68      0      1         Normal
## 35      64   110   31     16     25      72      0      0         Normal
## 36      63   117   24     16     12      69      0      0         Normal
## 37      68   154   38     14     25      71      0      0         Normal
## 38      69   143   30     12      0      72      0      0         Normal
## 39      65   132   21     10     25      73      0      0         Normal
## 40      63   125   23     10     35      70      0      0         Normal
## 41      64   118   30     16      0      72      0      0         Normal
## 42      68   150   26     14     25      74      0      0         Normal

Do smokers have lighter babies?

dat %>% 
  ggplot(aes(x=factor(smoker), y=Birthweight)) +
  geom_boxplot()

dat %>%
  group_by(smoker) %>% 
  summarise(mean_birthweight = mean(Birthweight),
            median_birthweight = median(Birthweight))
## # A tibble: 2 × 3
##   smoker mean_birthweight median_birthweight
##    <int>            <dbl>              <dbl>
## 1      0             7.69                7.4
## 2      1             6.88                7

Is there a relationship between low birth weight & mother’s age over 35 yrs?

dat %>% 
  ggplot(aes(x=factor(mage35),fill=LowBirthWeight)) +
  geom_bar(position = "fill")

dat %>% 
  count(mage35, LowBirthWeight)
##   mage35 LowBirthWeight  n
## 1      0            Low  5
## 2      0         Normal 33
## 3      1            Low  1
## 4      1         Normal  3
risk_under35 = 5/(5+33)
risk_over35 = 1/(1+3)

relative_risk = risk_over35/risk_under35
relative_risk
## [1] 1.9