North Carolina births

Exercises

  1. What are the cases in this data set? How many cases are there in our sample?

The cases are births in the state of North Carolina

  1. Make a side-by-side boxplot of habit and weight. What does the plot highlight about the relationship between these two variables?

The plots reveal that the baby weights of non-smoking mothers are higher

Inference

  1. Check if the conditions necessary for inference are satisfied. Note that you will need to obtain sample sizes to check the conditions. You can compute the group size using the same by command above but replacing mean with length.

The conditions are satisfied, as the sample sizes are larger than 30, presumably represent less than 10% of the population, and are independant.

## nc$habit: nonsmoker
## [1] 873
## -------------------------------------------------------- 
## nc$habit: smoker
## [1] 126
  1. Write the hypotheses for testing if the average weights of babies born to smoking and non-smoking mothers are different.

H0: (\(\mu_{nonsmoker} = \mu_{smoker}\))
HA: (\(\mu_{nonsmoker} ≠ \mu_{smoker}\))

  1. Change the type argument to "ci" to construct and record a confidence interval for the difference between the weights of babies born to smoking and non-smoking mothers.
## Response variable: numerical, Explanatory variable: categorical
## Difference between two means
## Summary statistics:
## n_nonsmoker = 873, mean_nonsmoker = 7.1443, sd_nonsmoker = 1.5187
## n_smoker = 126, mean_smoker = 6.8287, sd_smoker = 1.3862

## Observed difference between means (nonsmoker-smoker) = 0.3155
## 
## Standard error = 0.1338 
## 95 % Confidence interval = ( 0.0534 , 0.5777 )

On your own

We are 95% certain that the mean pregnancy length is between 38.15 and 38.5 weeks. The sample is skewed left

## Single mean 
## Summary statistics:

## mean = 38.3347 ;  sd = 2.9316 ;  n = 998 
## Standard error = 0.0928 
## 95 % Confidence interval = ( 38.1528 , 38.5165 )
## Single mean 
## Summary statistics:

## mean = 38.3347 ;  sd = 2.9316 ;  n = 998 
## Standard error = 0.0928 
## 90 % Confidence interval = ( 38.182 , 38.4873 )

As shown below, since the p-value is ~.17 is higher than an alpha of .05, we fail to reject the null hypothesis (mu_mature mom - mu_younger mom = 0 ).

## Response variable: numerical, Explanatory variable: categorical
## Difference between two means
## Summary statistics:
## n_mature mom = 129, mean_mature mom = 28.7907, sd_mature mom = 13.4824
## n_younger mom = 844, mean_younger mom = 30.5604, sd_younger mom = 14.3469
## Observed difference between means (mature mom-younger mom) = -1.7697
## 
## H0: mu_mature mom - mu_younger mom = 0 
## HA: mu_mature mom - mu_younger mom != 0 
## Standard error = 1.286 
## Test statistic: Z =  -1.376 
## p-value =  0.1686

Here I use the by() function to provide summary statistics for each group. This indicates that corresponding age ranges for each group

## nc$mature: mature mom
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   35.00   35.00   37.00   37.18   38.00   50.00 
## -------------------------------------------------------- 
## nc$mature: younger mom
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   13.00   21.00   25.00   25.44   30.00   34.00

QUESTION: Do younger mothers have more boys than mature mothers?

Below we test two categorical variables, gender and mature. In the sample, we observe a difference in the proportions of boys of -.0095. This value falls well within the range of possible observed values if the null hypothesis were true (no difference in proportion of boys between age groups) and so we fail to reject the Null Hypothesis.

## Response variable: categorical, Explanatory variable: categorical
## Two categorical variables
## Difference between two proportions -- success: male
## Summary statistics:
##         x
## y        mature mom younger mom  Sum
##   female         68         435  503
##   male           65         432  497
##   Sum           133         867 1000
## Observed difference between proportions (mature mom-younger mom) = -0.0095
## 
## H0: p_mature mom - p_younger mom = 0 
## HA: p_mature mom - p_younger mom != 0 
## Pooled proportion = 0.497 
## Check conditions:
##    mature mom : number of expected successes = 66 ; number of expected failures = 67 
##    younger mom : number of expected successes = 431 ; number of expected failures = 436 
## Standard error = 0.047 
## Test statistic: Z =  -0.205 
## p-value =  0.8376