Extra Tasks
Try these extra tasks to practice writing your own code in R.
Pregnancies Questions
In 2004, the state of North Carolina released a large data set containing information on births recorded in this state. This data set is useful to researchers studying the relation between habits and practices of expectant mothers and the birth of their children. We will work with a random sample of observations from this data set.
Load the nc data set into your workspace by typing the following code in an Rscript file in your local Rstudio.
download.file("http://www.openintro.org/stat/data/nc.RData", destfile = "nc.RData")
load("nc.RData")Before attempting the following exercises, explore the data as much or as little as you like using code from this Tutorial.
Task 1
Calculate a 95% confidence interval for the average length of pregnancies (weeks). Note that since you’re doing inference on a single population parameter, there is no explanatory variable.
Complete the following sentence, giving your answers to 2 decimal places. We are 95% certain that the average length of pregnancy for the population of women is between and weeks.
Task 2
Calculate a new confidence interval for the same parameter at the 90% confidence level.
Complete the following sentence, giving your answers to 2 decimal places. We are 90% certain that the average length of pregnancy for the population of women is between and weeks.
Task 3
Conduct a hypothesis test evaluating whether the average weight gained by younger mothers is different than the average weight gained by mature mothers.
Create a 95% confidence interval for the difference in mean weight gained between the two age groups. Don't forget to calculate a new standard error to use.