** Lab 5 - Xialing - Exercises and Questions **

download.file("http://www.tpmltd.com/ban/nc.RData", destfile = "nc.RData")
load("nc.RData")
summary(nc)
      fage           mage            mature        weeks     
 Min.   :14.0   Min.   :13   mature mom :133   Min.   :20.0  
 1st Qu.:25.0   1st Qu.:22   younger mom:867   1st Qu.:37.0  
 Median :30.0   Median :27                     Median :39.0  
 Mean   :30.3   Mean   :27                     Mean   :38.3  
 3rd Qu.:35.0   3rd Qu.:32                     3rd Qu.:40.0  
 Max.   :55.0   Max.   :50                     Max.   :45.0  
 NA's   :171                                   NA's   :2     
       premie        visits            marital        gained    
 full term:846   Min.   : 0.0   married    :386   Min.   : 0.0  
 premie   :152   1st Qu.:10.0   not married:613   1st Qu.:20.0  
 NA's     :  2   Median :12.0   NA's       :  1   Median :30.0  
                 Mean   :12.1                     Mean   :30.3  
                 3rd Qu.:15.0                     3rd Qu.:38.0  
                 Max.   :30.0                     Max.   :85.0  
                 NA's   :9                        NA's   :27    
     weight      lowbirthweight    gender          habit    
 Min.   : 1.00   low    :111    female:503   nonsmoker:873  
 1st Qu.: 6.38   not low:889    male  :497   smoker   :126  
 Median : 7.31                               NA's     :  1  
 Mean   : 7.10                                              
 3rd Qu.: 8.06                                              
 Max.   :11.75                                              

      whitemom  
 not white:284  
 white    :714  
 NA's     :  2  




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

The cases are births recorded in North Carolina. There are 1,000 cases with 13 variables in our sample.

dim(nc)
[1] 1000   13

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

The medians of the babies for smoker and nonsmoker moms are realitively close, though the median weight for the smoker mom is lower. The spread is relatively similar as well (1.62 vs. 1.657) but still reflects lower birth weight for babies whose moms are smokers. There are more outliers for babies from non smoking moms as well. The plot tells me that babies born to non smoking moms have higher birth weight over all and with much more varibilities in their weights (some outliers for on both sides). Birth weights for both groups are approximately normal.

by(nc$weight, nc$habit, summary)
nc$habit: nonsmoker
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   1.00    6.44    7.31    7.14    8.06   11.80 
-------------------------------------------------------- 
nc$habit: smoker
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   1.69    6.08    7.06    6.83    7.74    9.19 
boxplot(nc$weight[nc$habit =="nonsmoker"],nc$weight[nc$habit == "smoker"],xlab="habit",ylab="weight",main="Weight vs. habit", names = c("nonsmoker", "smoker"))

plot of chunk unnamed-chunk-5

Exercise 3 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.

by(nc$weight, nc$habit, length)
nc$habit: nonsmoker
[1] 873
-------------------------------------------------------- 
nc$habit: smoker
[1] 126

I assume the conditions are met: The population consists of birth records for the state of NC. The 1,000 The cases is probably less than 10% of the population to ensure they are simple random samples so independence is reasonable; there are more than 30 mean differences for each category. Even though the distribution of differences shown in the boxplots are a bit skewed they seems reasonable for the size of the sample.

Exercise 4 Write the hypotheses for testing if the average weights of babies born to smoking and non-smoking mothers are different.

Exercise 5 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.

inference(data = nc$weight, group = nc$habit, est = "mean", type = "ci", null = 0,alternative = "twosided", method = "theoretical",order = c("smoker","nonsmoker"))
Warning: package 'openintro' was built under R version 3.1.1
Please visit openintro.org for free statistics materials

Attaching package: 'openintro'

The following object is masked from 'package:datasets':

    cars
Warning: package 'BHH2' was built under R version 3.1.1

Attaching package: 'BHH2'

The following object is masked from 'package:openintro':

    dotPlot
One quantitative and one categorical variable
Difference between two means
n_smoker = 126 ; n_nonsmoker = 873 
Observed difference between means = -0.3155

plot of chunk unnamed-chunk-7

Standard error = 0.1338 
95 % Confidence interval = ( -0.58 , -0.05 )

Lab 5: Data Analysis

1. Calculate a 95% confidence interval for the average length of pregnancies (weeks) and interpret it in context. Note that since you're doing inference on a single population parameter, there is no grouping variable, so you can omit the group variable from the function.

inference(data = nc$weeks,est = "mean", type = "ci", null = 0,alternative = "twosided", method = "theoretical")
One quantitative variable 
Single mean 
Observed mean = 38.3347 

plot of chunk unnamed-chunk-8

Standard error = 0.0928 
95 % Confidence interval = ( 38.15 , 38.52 )

We are 95 % Confident that the average length of pregnancies (weeks) is between 38.15 and 38.52. This confidence interval is calculated based on the total sample that consists both smoking and nonsmoking mothers.

2. Calculate a new confidence interval for the same parameter at the 90% confidence level. You can change the confidence level by adding a new argument to the function: conflevel = 0.90.

inference(data = nc$weeks,est = "mean", type = "ci", null = 0,conflevel = 0.90, alternative = "twosided", method = "theoretical")
One quantitative variable 
Single mean 
Observed mean = 38.3347 

plot of chunk unnamed-chunk-9

Standard error = 0.0928 
90 % Confidence interval = ( 38.18 , 38.49 )

3. Conduct a hypothesis test evaluating whether the average weight gained by younger mothers is different than the average weight gained by mature mothers.

The null hypothesis is the average weight gained by younger mothers are not different from the average weight gained by mature mothers. Based on the test statics of p-value of 0.8526 there is strong evidence that we fail to reject the null hypothesis that the average weight gained by younger mothers are not different from the average weight gained by mature mothers.

inference(data = nc$weight, group = nc$mature, est = "mean", type = "ht", null = 0, alternative = "twosided", method = "theoretical")
One quantitative and one categorical variable
Difference between two means
n_mature mom = 133 ; n_younger mom = 867 
Observed difference between means = 0.0283
H0: mu_mature mom - mu_younger mom = 0 
HA: mu_mature mom - mu_younger mom != 0 
Standard error = 0.152 
Test statistic: Z =  0.186 
p-value:  0.8526 
-5.25 -5.239 -5.229 -5.218 -5.208 -5.197 -5.187 -5.176 -5.166 -5.155 -5.145 -5.134 -5.124 -5.113 -5.103 -5.092 -5.082 -5.071 -5.061 -5.05 -5.04 -5.029 -5.019 -5.008 -4.997 -4.987 -4.976 -4.966 -4.955 -4.945 -4.934 -4.924 -4.913 -4.903 -4.892 -4.882 -4.871 -4.861 -4.85 -4.84 -4.829 -4.819 -4.808 -4.798 -4.787 -4.777 -4.766 -4.756 -4.745 -4.734 -4.724 -4.713 -4.703 -4.692 -4.682 -4.671 -4.661 -4.65 -4.64 -4.629 -4.619 -4.608 -4.598 -4.587 -4.577 -4.566 -4.556 -4.545 -4.535 -4.524 -4.514 -4.503 -4.492 -4.482 -4.471 -4.461 -4.45 -4.44 -4.429 -4.419 -4.408 -4.398 -4.387 -4.377 -4.366 -4.356 -4.345 -4.335 -4.324 -4.314 -4.303 -4.293 -4.282 -4.272 -4.261 -4.251 -4.24 -4.229 -4.219 -4.208 -4.198 -4.187 -4.177 -4.166 -4.156 -4.145 -4.135 -4.124 -4.114 -4.103 -4.093 -4.082 -4.072 -4.061 -4.051 -4.04 -4.03 -4.019 -4.009 -3.998 -3.987 -3.977 -3.966 -3.956 -3.945 -3.935 -3.924 -3.914 -3.903 -3.893 -3.882 -3.872 -3.861 -3.851 -3.84 -3.83 -3.819 -3.809 -3.798 -3.788 -3.777 -3.767 -3.756 -3.745 -3.735 -3.724 -3.714 -3.703 -3.693 -3.682 -3.672 -3.661 -3.651 -3.64 -3.63 -3.619 -3.609 -3.598 -3.588 -3.577 -3.567 -3.556 -3.546 -3.535 -3.525 -3.514 -3.504 -3.493 -3.482 -3.472 -3.461 -3.451 -3.44 -3.43 -3.419 -3.409 -3.398 -3.388 -3.377 -3.367 -3.356 -3.346 -3.335 -3.325 -3.314 -3.304 -3.293 -3.283 -3.272 -3.262 -3.251 -3.24 -3.23 -3.219 -3.209 -3.198 -3.188 -3.177 -3.167 -3.156 -3.146 -3.135 -3.125 -3.114 -3.104 -3.093 -3.083 -3.072 -3.062 -3.051 -3.041 -3.03 -3.02 -3.009 -2.998 -2.988 -2.977 -2.967 -2.956 -2.946 -2.935 -2.925 -2.914 -2.904 -2.893 -2.883 -2.872 -2.862 -2.851 -2.841 -2.83 -2.82 -2.809 -2.799 -2.788 -2.778 -2.767 -2.757 -2.746 -2.735 -2.725 -2.714 -2.704 -2.693 -2.683 -2.672 -2.662 -2.651 -2.641 -2.63 -2.62 -2.609 -2.599 -2.588 -2.578 -2.567 -2.557 -2.546 -2.536 -2.525 -2.515 -2.504 -2.493 -2.483 -2.472 -2.462 -2.451 -2.441 -2.43 -2.42 -2.409 -2.399 -2.388 -2.378 -2.367 -2.357 -2.346 -2.336 -2.325 -2.315 -2.304 -2.294 -2.283 -2.273 -2.262 -2.252 -2.241 -2.23 -2.22 -2.209 -2.199 -2.188 -2.178 -2.167 -2.157 -2.146 -2.136 -2.125 -2.115 -2.104 -2.094 -2.083 -2.073 -2.062 -2.052 -2.041 -2.031 -2.02 -2.01 -1.999 -1.988 -1.978 -1.967 -1.957 -1.946 -1.936 -1.925 -1.915 -1.904 -1.894 -1.883 -1.873 -1.862 -1.852 -1.841 -1.831 -1.82 -1.81 -1.799 -1.789 -1.778 -1.768 -1.757 -1.746 -1.736 -1.725 -1.715 -1.704 -1.694 -1.683 -1.673 -1.662 -1.652 -1.641 -1.631 -1.62 -1.61 -1.599 -1.589 -1.578 -1.568 -1.557 -1.547 -1.536 -1.526 -1.515 -1.505 -1.494 -1.483 -1.473 -1.462 -1.452 -1.441 -1.431 -1.42 -1.41 -1.399 -1.389 -1.378 -1.368 -1.357 -1.347 -1.336 -1.326 -1.315 -1.305 -1.294 -1.284 -1.273 -1.263 -1.252 -1.241 -1.231 -1.22 -1.21 -1.199 -1.189 -1.178 -1.168 -1.157 -1.147 -1.136 -1.126 -1.115 -1.105 -1.094 -1.084 -1.073 -1.063 -1.052 -1.042 -1.031 -1.021 -1.01 -0.9995 -0.989 -0.9785 -0.9679 -0.9574 -0.9469 -0.9364 -0.9259 -0.9153 -0.9048 -0.8943 -0.8838 -0.8732 -0.8627 -0.8522 -0.8417 -0.8312 -0.8206 -0.8101 -0.7996 -0.7891 -0.7786 -0.768 -0.7575 -0.747 -0.7365 -0.726 -0.7154 -0.7049 -0.6944 -0.6839 -0.6733 -0.6628 -0.6523 -0.6418 -0.6313 -0.6207 -0.6102 -0.5997 -0.5892 -0.5787 -0.5681 -0.5576 -0.5471 -0.5366 -0.5261 -0.5155 -0.505 -0.4945 -0.484 -0.4734 -0.4629 -0.4524 -0.4419 -0.4314 -0.4208 -0.4103 -0.3998 -0.3893 -0.3788 -0.3682 -0.3577 -0.3472 -0.3367 -0.3262 -0.3156 -0.3051 -0.2946 -0.2841 -0.2735 -0.263 -0.2525 -0.242 -0.2315 -0.2209 -0.2104 -0.1999 -0.1894 -0.1789 -0.1683 -0.1578 -0.1473 -0.1368 -0.1263 -0.1157 -0.1052 -0.09469 -0.08417 -0.07365 -0.06313 -0.05261 -0.04208 -0.03156 -0.02104 -0.01052 0 0.01052 0.02104 0.03156 0.04208 0.05261 0.06313 0.07365 0.08417 0.09469 0.1052 0.1157 0.1263 0.1368 0.1473 0.1578 0.1683 0.1789 0.1894 0.1999 0.2104 0.2209 0.2315 0.242 0.2525 0.263 0.2735 0.2841 0.2946 0.3051 0.3156 0.3262 0.3367 0.3472 0.3577 0.3682 0.3788 0.3893 0.3998 0.4103 0.4208 0.4314 0.4419 0.4524 0.4629 0.4734 0.484 0.4945 0.505 0.5155 0.5261 0.5366 0.5471 0.5576 0.5681 0.5787 0.5892 0.5997 0.6102 0.6207 0.6313 0.6418 0.6523 0.6628 0.6733 0.6839 0.6944 0.7049 0.7154 0.726 0.7365 0.747 0.7575 0.768 0.7786 0.7891 0.7996 0.8101 0.8206 0.8312 0.8417 0.8522 0.8627 0.8732 0.8838 0.8943 0.9048 0.9153 0.9259 0.9364 0.9469 0.9574 0.9679 0.9785 0.989 0.9995 1.01 1.021 1.031 1.042 1.052 1.063 1.073 1.084 1.094 1.105 1.115 1.126 1.136 1.147 1.157 1.168 1.178 1.189 1.199 1.21 1.22 1.231 1.241 1.252 1.263 1.273 1.284 1.294 1.305 1.315 1.326 1.336 1.347 1.357 1.368 1.378 1.389 1.399 1.41 1.42 1.431 1.441 1.452 1.462 1.473 1.483 1.494 1.505 1.515 1.526 1.536 1.547 1.557 1.568 1.578 1.589 1.599 1.61 1.62 1.631 1.641 1.652 1.662 1.673 1.683 1.694 1.704 1.715 1.725 1.736 1.746 1.757 1.768 1.778 1.789 1.799 1.81 1.82 1.831 1.841 1.852 1.862 1.873 1.883 1.894 1.904 1.915 1.925 1.936 1.946 1.957 1.967 1.978 1.988 1.999 2.01 2.02 2.031 2.041 2.052 2.062 2.073 2.083 2.094 2.104 2.115 2.125 2.136 2.146 2.157 2.167 2.178 2.188 2.199 2.209 2.22 2.23 2.241 2.252 2.262 2.273 2.283 2.294 2.304 2.315 2.325 2.336 2.346 2.357 2.367 2.378 2.388 2.399 2.409 2.42 2.43 2.441 2.451 2.462 2.472 2.483 2.493 2.504 2.515 2.525 2.536 2.546 2.557 2.567 2.578 2.588 2.599 2.609 2.62 2.63 2.641 2.651 2.662 2.672 2.683 2.693 2.704 2.714 2.725 2.735 2.746 2.757 2.767 2.778 2.788 2.799 2.809 2.82 2.83 2.841 2.851 2.862 2.872 2.883 2.893 2.904 2.914 2.925 2.935 2.946 2.956 2.967 2.977 2.988 2.998 3.009 3.02 3.03 3.041 3.051 3.062 3.072 3.083 3.093 3.104 3.114 3.125 3.135 3.146 3.156 3.167 3.177 3.188 3.198 3.209 3.219 3.23 3.24 3.251 3.262 3.272 3.283 3.293 3.304 3.314 3.325 3.335 3.346 3.356 3.367 3.377 3.388 3.398 3.409 3.419 3.43 3.44 3.451 3.461 3.472 3.482 3.493 3.504 3.514 3.525 3.535 3.546 3.556 3.567 3.577 3.588 3.598 3.609 3.619 3.63 3.64 3.651 3.661 3.672 3.682 3.693 3.703 3.714 3.724 3.735 3.745 3.756 3.767 3.777 3.788 3.798 3.809 3.819 3.83 3.84 3.851 3.861 3.872 3.882 3.893 3.903 3.914 3.924 3.935 3.945 3.956 3.966 3.977 3.987 3.998 4.009 4.019 4.03 4.04 4.051 4.061 4.072 4.082 4.093 4.103 4.114 4.124 4.135 4.145 4.156 4.166 4.177 4.187 4.198 4.208 4.219 4.229 4.24 4.251 4.261 4.272 4.282 4.293 4.303 4.314 4.324 4.335 4.345 4.356 4.366 4.377 4.387 4.398 4.408 4.419 4.429 4.44 4.45 4.461 4.471 4.482 4.492 4.503 4.514 4.524 4.535 4.545 4.556 4.566 4.577 4.587 4.598 4.608 4.619 4.629 4.64 4.65 4.661 4.671 4.682 4.692 4.703 4.713 4.724 4.734 4.745 4.756 4.766 4.777 4.787 4.798 4.808 4.819 4.829 4.84 4.85 4.861 4.871 4.882 4.892 4.903 4.913 4.924 4.934 4.945 4.955 4.966 4.976 4.987 4.997 5.008 5.019 5.029 5.04 5.05 5.061 5.071 5.082 5.092 5.103 5.113 5.124 5.134 5.145 5.155 5.166 5.176 5.187 5.197 5.208 5.218 5.229 5.239 5.254.907e-07 5.178e-07 5.463e-07 5.763e-07 6.08e-07 6.413e-07 6.764e-07 7.133e-07 7.521e-07 7.93e-07 8.361e-07 8.813e-07 9.29e-07 9.791e-07 1.032e-06 1.087e-06 1.145e-06 1.207e-06 1.271e-06 1.339e-06 1.41e-06 1.485e-06 1.564e-06 1.646e-06 1.733e-06 1.824e-06 1.92e-06 2.021e-06 2.126e-06 2.237e-06 2.354e-06 2.476e-06 2.605e-06 2.74e-06 2.881e-06 3.03e-06 3.186e-06 3.349e-06 3.521e-06 3.701e-06 3.89e-06 4.088e-06 4.295e-06 4.513e-06 4.741e-06 4.98e-06 5.231e-06 5.494e-06 5.769e-06 6.058e-06 6.361e-06 6.677e-06 7.009e-06 7.357e-06 7.721e-06 8.102e-06 8.501e-06 8.919e-06 9.357e-06 9.815e-06 1.029e-05 1.08e-05 1.132e-05 1.187e-05 1.244e-05 1.305e-05 1.367e-05 1.433e-05 1.502e-05 1.574e-05 1.649e-05 1.727e-05 1.809e-05 1.895e-05 1.985e-05 2.079e-05 2.176e-05 2.279e-05 2.385e-05 2.497e-05 2.614e-05 2.735e-05 2.862e-05 2.995e-05 3.133e-05 3.278e-05 3.428e-05 3.586e-05 3.75e-05 3.921e-05 4.1e-05 4.286e-05 4.48e-05 4.683e-05 4.894e-05 5.114e-05 5.344e-05 5.583e-05 5.833e-05 6.093e-05 6.363e-05 6.646e-05 6.94e-05 7.246e-05 7.565e-05 7.897e-05 8.243e-05 8.603e-05 8.978e-05 9.368e-05 9.774e-05 0.000102 0.0001064 0.0001109 0.0001157 0.0001207 0.0001258 0.0001312 0.0001367 0.0001425 0.0001486 0.0001548 0.0001613 0.0001681 0.0001751 0.0001824 0.00019 0.0001979 0.0002061 0.0002146 0.0002234 0.0002326 0.0002421 0.000252 0.0002623 0.0002729 0.000284 0.0002954 0.0003073 0.0003197 0.0003325 0.0003458 0.0003595 0.0003738 0.0003886 0.000404 0.0004199 0.0004364 0.0004535 0.0004712 0.0004895 0.0005085 0.0005282 0.0005486 0.0005698 0.0005916 0.0006143 0.0006377 0.000662 0.0006871 0.0007131 0.00074 0.0007679 0.0007967 0.0008265 0.0008573 0.0008892 0.0009221 0.0009562 0.0009915 0.001028 0.001066 0.001104 0.001145 0.001186 0.001229 0.001273 0.001319 0.001366 0.001415 0.001466 0.001518 0.001572 0.001627 0.001684 0.001743 0.001804 0.001867 0.001932 0.001999 0.002068 0.002139 0.002212 0.002288 0.002366 0.002446 0.002529 0.002614 0.002702 0.002793 0.002886 0.002982 0.003081 0.003183 0.003288 0.003396 0.003507 0.003622 0.00374 0.003861 0.003985 0.004114 0.004246 0.004381 0.004521 0.004664 0.004812 0.004963 0.005119 0.005279 0.005444 0.005613 0.005787 0.005966 0.006149 0.006337 0.006531 0.006729 0.006933 0.007142 0.007357 0.007577 0.007803 0.008035 0.008273 0.008517 0.008768 0.009025 0.009288 0.009558 0.009835 0.01012 0.01041 0.01071 0.01101 0.01132 0.01164 0.01197 0.01231 0.01265 0.01301 0.01337 0.01373 0.01411 0.0145 0.01489 0.0153 0.01571 0.01614 0.01657 0.01701 0.01747 0.01793 0.0184 0.01888 0.01938 0.01988 0.0204 0.02093 0.02146 0.02201 0.02257 0.02315 0.02373 0.02433 0.02494 0.02556 0.0262 0.02684 0.0275 0.02818 0.02886 0.02956 0.03028 0.03101 0.03175 0.0325 0.03327 0.03406 0.03486 0.03567 0.0365 0.03735 0.03821 0.03908 0.03998 0.04088 0.04181 0.04275 0.0437 0.04467 0.04566 0.04667 0.04769 0.04873 0.04979 0.05086 0.05196 0.05307 0.05419 0.05534 0.0565 0.05768 0.05888 0.0601 0.06134 0.06259 0.06387 0.06516 0.06647 0.0678 0.06915 0.07052 0.07191 0.07331 0.07474 0.07619 0.07765 0.07914 0.08064 0.08217 0.08371 0.08527 0.08686 0.08846 0.09008 0.09172 0.09338 0.09506 0.09677 0.09849 0.1002 0.102 0.1038 0.1056 0.1074 0.1092 0.1111 0.113 0.1148 0.1168 0.1187 0.1206 0.1226 0.1246 0.1266 0.1286 0.1307 0.1327 0.1348 0.1369 0.139 0.1411 0.1433 0.1455 0.1476 0.1498 0.152 0.1543 0.1565 0.1588 0.161 0.1633 0.1656 0.1679 0.1703 0.1726 0.175 0.1773 0.1797 0.1821 0.1845 0.1869 0.1894 0.1918 0.1942 0.1967 0.1992 0.2016 0.2041 0.2066 0.2091 0.2116 0.2141 0.2166 0.2191 0.2217 0.2242 0.2267 0.2293 0.2318 0.2343 0.2369 0.2394 0.242 0.2445 0.2471 0.2496 0.2521 0.2547 0.2572 0.2598 0.2623 0.2648 0.2673 0.2698 0.2723 0.2748 0.2773 0.2798 0.2823 0.2848 0.2872 0.2896 0.2921 0.2945 0.2969 0.2993 0.3017 0.304 0.3064 0.3087 0.311 0.3133 0.3156 0.3179 0.3201 0.3224 0.3246 0.3267 0.3289 0.331 0.3332 0.3352 0.3373 0.3394 0.3414 0.3434 0.3453 0.3473 0.3492 0.3511 0.3529 0.3547 0.3565 0.3583 0.36 0.3617 0.3634 0.365 0.3666 0.3682 0.3697 0.3712 0.3727 0.3741 0.3755 0.3768 0.3782 0.3794 0.3807 0.3819 0.3831 0.3842 0.3853 0.3863 0.3873 0.3883 0.3892 0.3901 0.3909 0.3917 0.3925 0.3932 0.3939 0.3945 0.3951 0.3957 0.3962 0.3966 0.3971 0.3974 0.3978 0.398 0.3983 0.3985 0.3986 0.3988 0.3988 0.3988 0.3988 0.3988 0.3986 0.3985 0.3983 0.398 0.3978 0.3974 0.3971 0.3966 0.3962 0.3957 0.3951 0.3945 0.3939 0.3932 0.3925 0.3917 0.3909 0.3901 0.3892 0.3883 0.3873 0.3863 0.3853 0.3842 0.3831 0.3819 0.3807 0.3794 0.3782 0.3768 0.3755 0.3741 0.3727 0.3712 0.3697 0.3682 0.3666 0.365 0.3634 0.3617 0.36 0.3583 0.3565 0.3547 0.3529 0.3511 0.3492 0.3473 0.3453 0.3434 0.3414 0.3394 0.3373 0.3352 0.3332 0.331 0.3289 0.3267 0.3246 0.3224 0.3201 0.3179 0.3156 0.3133 0.311 0.3087 0.3064 0.304 0.3017 0.2993 0.2969 0.2945 0.2921 0.2896 0.2872 0.2848 0.2823 0.2798 0.2773 0.2748 0.2723 0.2698 0.2673 0.2648 0.2623 0.2598 0.2572 0.2547 0.2521 0.2496 0.2471 0.2445 0.242 0.2394 0.2369 0.2343 0.2318 0.2293 0.2267 0.2242 0.2217 0.2191 0.2166 0.2141 0.2116 0.2091 0.2066 0.2041 0.2016 0.1992 0.1967 0.1942 0.1918 0.1894 0.1869 0.1845 0.1821 0.1797 0.1773 0.175 0.1726 0.1703 0.1679 0.1656 0.1633 0.161 0.1588 0.1565 0.1543 0.152 0.1498 0.1476 0.1455 0.1433 0.1411 0.139 0.1369 0.1348 0.1327 0.1307 0.1286 0.1266 0.1246 0.1226 0.1206 0.1187 0.1168 0.1148 0.113 0.1111 0.1092 0.1074 0.1056 0.1038 0.102 0.1002 0.09849 0.09677 0.09506 0.09338 0.09172 0.09008 0.08846 0.08686 0.08527 0.08371 0.08217 0.08064 0.07914 0.07765 0.07619 0.07474 0.07331 0.07191 0.07052 0.06915 0.0678 0.06647 0.06516 0.06387 0.06259 0.06134 0.0601 0.05888 0.05768 0.0565 0.05534 0.05419 0.05307 0.05196 0.05086 0.04979 0.04873 0.04769 0.04667 0.04566 0.04467 0.0437 0.04275 0.04181 0.04088 0.03998 0.03908 0.03821 0.03735 0.0365 0.03567 0.03486 0.03406 0.03327 0.0325 0.03175 0.03101 0.03028 0.02956 0.02886 0.02818 0.0275 0.02684 0.0262 0.02556 0.02494 0.02433 0.02373 0.02315 0.02257 0.02201 0.02146 0.02093 0.0204 0.01988 0.01938 0.01888 0.0184 0.01793 0.01747 0.01701 0.01657 0.01614 0.01571 0.0153 0.01489 0.0145 0.01411 0.01373 0.01337 0.01301 0.01265 0.01231 0.01197 0.01164 0.01132 0.01101 0.01071 0.01041 0.01012 0.009835 0.009558 0.009288 0.009025 0.008768 0.008517 0.008273 0.008035 0.007803 0.007577 0.007357 0.007142 0.006933 0.006729 0.006531 0.006337 0.006149 0.005966 0.005787 0.005613 0.005444 0.005279 0.005119 0.004963 0.004812 0.004664 0.004521 0.004381 0.004246 0.004114 0.003985 0.003861 0.00374 0.003622 0.003507 0.003396 0.003288 0.003183 0.003081 0.002982 0.002886 0.002793 0.002702 0.002614 0.002529 0.002446 0.002366 0.002288 0.002212 0.002139 0.002068 0.001999 0.001932 0.001867 0.001804 0.001743 0.001684 0.001627 0.001572 0.001518 0.001466 0.001415 0.001366 0.001319 0.001273 0.001229 0.001186 0.001145 0.001104 0.001066 0.001028 0.0009915 0.0009562 0.0009221 0.0008892 0.0008573 0.0008265 0.0007967 0.0007679 0.00074 0.0007131 0.0006871 0.000662 0.0006377 0.0006143 0.0005916 0.0005698 0.0005486 0.0005282 0.0005085 0.0004895 0.0004712 0.0004535 0.0004364 0.0004199 0.000404 0.0003886 0.0003738 0.0003595 0.0003458 0.0003325 0.0003197 0.0003073 0.0002954 0.000284 0.0002729 0.0002623 0.000252 0.0002421 0.0002326 0.0002234 0.0002146 0.0002061 0.0001979 0.00019 0.0001824 0.0001751 0.0001681 0.0001613 0.0001548 0.0001486 0.0001425 0.0001367 0.0001312 0.0001258 0.0001207 0.0001157 0.0001109 0.0001064 0.000102 9.774e-05 9.368e-05 8.978e-05 8.603e-05 8.243e-05 7.897e-05 7.565e-05 7.246e-05 6.94e-05 6.646e-05 6.363e-05 6.093e-05 5.833e-05 5.583e-05 5.344e-05 5.114e-05 4.894e-05 4.683e-05 4.48e-05 4.286e-05 4.1e-05 3.921e-05 3.75e-05 3.586e-05 3.428e-05 3.278e-05 3.133e-05 2.995e-05 2.862e-05 2.735e-05 2.614e-05 2.497e-05 2.385e-05 2.279e-05 2.176e-05 2.079e-05 1.985e-05 1.895e-05 1.809e-05 1.727e-05 1.649e-05 1.574e-05 1.502e-05 1.433e-05 1.367e-05 1.305e-05 1.244e-05 1.187e-05 1.132e-05 1.08e-05 1.029e-05 9.815e-06 9.357e-06 8.919e-06 8.501e-06 8.102e-06 7.721e-06 7.357e-06 7.009e-06 6.677e-06 6.361e-06 6.058e-06 5.769e-06 5.494e-06 5.231e-06 4.98e-06 4.741e-06 4.513e-06 4.295e-06 4.088e-06 3.89e-06 3.701e-06 3.521e-06 3.349e-06 3.186e-06 3.03e-06 2.881e-06 2.74e-06 2.605e-06 2.476e-06 2.354e-06 2.237e-06 2.126e-06 2.021e-06 1.92e-06 1.824e-06 1.733e-06 1.646e-06 1.564e-06 1.485e-06 1.41e-06 1.339e-06 1.271e-06 1.207e-06 1.145e-06 1.087e-06 1.032e-06 9.791e-07 9.29e-07 8.813e-07 8.361e-07 7.93e-07 7.521e-07 7.133e-07 6.764e-07 6.413e-07 6.08e-07 5.763e-07 5.463e-07 5.178e-07 4.907e-07

plot of chunk unnamed-chunk-10

4. Now, a non-inference task: Determine the age cutoff for younger and mature mothers. Use a method of your choice, and explain how your method works.

Based on the summary data and the boxplot the age cutoff for younger and mature mothers is 35. Look at the summary data the max age for younger mom is 34, whereas the mininum age for mature mother is 35. In the boxplot for the age of mature mom the minimum value of a data set is 35.

by(nc$mage, nc$mature,summary)
nc$mature: mature mom
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   35.0    35.0    37.0    37.2    38.0    50.0 
-------------------------------------------------------- 
nc$mature: younger mom
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   13.0    21.0    25.0    25.4    30.0    34.0 
boxplot(nc$mage[nc$mature == "mature mom"])

plot of chunk unnamed-chunk-12

5. Pick a pair of numerical and categorical variables and come up with a research question evaluating the relationship between these variables. Formulate the question in a way that it can be answered using a hypothesis test and/or a confidence interval. Answer your question using the inference function, report the statistical results, and also provide an explanation in plain language.

We are interested in researching the relationship between mothers' ages and the term of their pregnancy. The null hypothesis will be that there is no relationship between mothers' ages and the term of their pregnancy.

inference(data = nc$mage, group = nc$premie, est = "mean", type = "ht", null = 0,alternative = "twosided", method = "theoretical",order = c("full term","premie"))
One quantitative and one categorical variable
Difference between two means
n_full term = 846 ; n_premie = 152 
Observed difference between means = 0.125
H0: mu_full term - mu_premie = 0 
HA: mu_full term - mu_premie != 0 
Standard error = 0.57 
Test statistic: Z =  0.219 
p-value:  0.8266 
-5.25 -5.239 -5.229 -5.218 -5.208 -5.197 -5.187 -5.176 -5.166 -5.155 -5.145 -5.134 -5.124 -5.113 -5.103 -5.092 -5.082 -5.071 -5.061 -5.05 -5.04 -5.029 -5.019 -5.008 -4.997 -4.987 -4.976 -4.966 -4.955 -4.945 -4.934 -4.924 -4.913 -4.903 -4.892 -4.882 -4.871 -4.861 -4.85 -4.84 -4.829 -4.819 -4.808 -4.798 -4.787 -4.777 -4.766 -4.756 -4.745 -4.734 -4.724 -4.713 -4.703 -4.692 -4.682 -4.671 -4.661 -4.65 -4.64 -4.629 -4.619 -4.608 -4.598 -4.587 -4.577 -4.566 -4.556 -4.545 -4.535 -4.524 -4.514 -4.503 -4.492 -4.482 -4.471 -4.461 -4.45 -4.44 -4.429 -4.419 -4.408 -4.398 -4.387 -4.377 -4.366 -4.356 -4.345 -4.335 -4.324 -4.314 -4.303 -4.293 -4.282 -4.272 -4.261 -4.251 -4.24 -4.229 -4.219 -4.208 -4.198 -4.187 -4.177 -4.166 -4.156 -4.145 -4.135 -4.124 -4.114 -4.103 -4.093 -4.082 -4.072 -4.061 -4.051 -4.04 -4.03 -4.019 -4.009 -3.998 -3.987 -3.977 -3.966 -3.956 -3.945 -3.935 -3.924 -3.914 -3.903 -3.893 -3.882 -3.872 -3.861 -3.851 -3.84 -3.83 -3.819 -3.809 -3.798 -3.788 -3.777 -3.767 -3.756 -3.745 -3.735 -3.724 -3.714 -3.703 -3.693 -3.682 -3.672 -3.661 -3.651 -3.64 -3.63 -3.619 -3.609 -3.598 -3.588 -3.577 -3.567 -3.556 -3.546 -3.535 -3.525 -3.514 -3.504 -3.493 -3.482 -3.472 -3.461 -3.451 -3.44 -3.43 -3.419 -3.409 -3.398 -3.388 -3.377 -3.367 -3.356 -3.346 -3.335 -3.325 -3.314 -3.304 -3.293 -3.283 -3.272 -3.262 -3.251 -3.24 -3.23 -3.219 -3.209 -3.198 -3.188 -3.177 -3.167 -3.156 -3.146 -3.135 -3.125 -3.114 -3.104 -3.093 -3.083 -3.072 -3.062 -3.051 -3.041 -3.03 -3.02 -3.009 -2.998 -2.988 -2.977 -2.967 -2.956 -2.946 -2.935 -2.925 -2.914 -2.904 -2.893 -2.883 -2.872 -2.862 -2.851 -2.841 -2.83 -2.82 -2.809 -2.799 -2.788 -2.778 -2.767 -2.757 -2.746 -2.735 -2.725 -2.714 -2.704 -2.693 -2.683 -2.672 -2.662 -2.651 -2.641 -2.63 -2.62 -2.609 -2.599 -2.588 -2.578 -2.567 -2.557 -2.546 -2.536 -2.525 -2.515 -2.504 -2.493 -2.483 -2.472 -2.462 -2.451 -2.441 -2.43 -2.42 -2.409 -2.399 -2.388 -2.378 -2.367 -2.357 -2.346 -2.336 -2.325 -2.315 -2.304 -2.294 -2.283 -2.273 -2.262 -2.252 -2.241 -2.23 -2.22 -2.209 -2.199 -2.188 -2.178 -2.167 -2.157 -2.146 -2.136 -2.125 -2.115 -2.104 -2.094 -2.083 -2.073 -2.062 -2.052 -2.041 -2.031 -2.02 -2.01 -1.999 -1.988 -1.978 -1.967 -1.957 -1.946 -1.936 -1.925 -1.915 -1.904 -1.894 -1.883 -1.873 -1.862 -1.852 -1.841 -1.831 -1.82 -1.81 -1.799 -1.789 -1.778 -1.768 -1.757 -1.746 -1.736 -1.725 -1.715 -1.704 -1.694 -1.683 -1.673 -1.662 -1.652 -1.641 -1.631 -1.62 -1.61 -1.599 -1.589 -1.578 -1.568 -1.557 -1.547 -1.536 -1.526 -1.515 -1.505 -1.494 -1.483 -1.473 -1.462 -1.452 -1.441 -1.431 -1.42 -1.41 -1.399 -1.389 -1.378 -1.368 -1.357 -1.347 -1.336 -1.326 -1.315 -1.305 -1.294 -1.284 -1.273 -1.263 -1.252 -1.241 -1.231 -1.22 -1.21 -1.199 -1.189 -1.178 -1.168 -1.157 -1.147 -1.136 -1.126 -1.115 -1.105 -1.094 -1.084 -1.073 -1.063 -1.052 -1.042 -1.031 -1.021 -1.01 -0.9995 -0.989 -0.9785 -0.9679 -0.9574 -0.9469 -0.9364 -0.9259 -0.9153 -0.9048 -0.8943 -0.8838 -0.8732 -0.8627 -0.8522 -0.8417 -0.8312 -0.8206 -0.8101 -0.7996 -0.7891 -0.7786 -0.768 -0.7575 -0.747 -0.7365 -0.726 -0.7154 -0.7049 -0.6944 -0.6839 -0.6733 -0.6628 -0.6523 -0.6418 -0.6313 -0.6207 -0.6102 -0.5997 -0.5892 -0.5787 -0.5681 -0.5576 -0.5471 -0.5366 -0.5261 -0.5155 -0.505 -0.4945 -0.484 -0.4734 -0.4629 -0.4524 -0.4419 -0.4314 -0.4208 -0.4103 -0.3998 -0.3893 -0.3788 -0.3682 -0.3577 -0.3472 -0.3367 -0.3262 -0.3156 -0.3051 -0.2946 -0.2841 -0.2735 -0.263 -0.2525 -0.242 -0.2315 -0.2209 -0.2104 -0.1999 -0.1894 -0.1789 -0.1683 -0.1578 -0.1473 -0.1368 -0.1263 -0.1157 -0.1052 -0.09469 -0.08417 -0.07365 -0.06313 -0.05261 -0.04208 -0.03156 -0.02104 -0.01052 0 0.01052 0.02104 0.03156 0.04208 0.05261 0.06313 0.07365 0.08417 0.09469 0.1052 0.1157 0.1263 0.1368 0.1473 0.1578 0.1683 0.1789 0.1894 0.1999 0.2104 0.2209 0.2315 0.242 0.2525 0.263 0.2735 0.2841 0.2946 0.3051 0.3156 0.3262 0.3367 0.3472 0.3577 0.3682 0.3788 0.3893 0.3998 0.4103 0.4208 0.4314 0.4419 0.4524 0.4629 0.4734 0.484 0.4945 0.505 0.5155 0.5261 0.5366 0.5471 0.5576 0.5681 0.5787 0.5892 0.5997 0.6102 0.6207 0.6313 0.6418 0.6523 0.6628 0.6733 0.6839 0.6944 0.7049 0.7154 0.726 0.7365 0.747 0.7575 0.768 0.7786 0.7891 0.7996 0.8101 0.8206 0.8312 0.8417 0.8522 0.8627 0.8732 0.8838 0.8943 0.9048 0.9153 0.9259 0.9364 0.9469 0.9574 0.9679 0.9785 0.989 0.9995 1.01 1.021 1.031 1.042 1.052 1.063 1.073 1.084 1.094 1.105 1.115 1.126 1.136 1.147 1.157 1.168 1.178 1.189 1.199 1.21 1.22 1.231 1.241 1.252 1.263 1.273 1.284 1.294 1.305 1.315 1.326 1.336 1.347 1.357 1.368 1.378 1.389 1.399 1.41 1.42 1.431 1.441 1.452 1.462 1.473 1.483 1.494 1.505 1.515 1.526 1.536 1.547 1.557 1.568 1.578 1.589 1.599 1.61 1.62 1.631 1.641 1.652 1.662 1.673 1.683 1.694 1.704 1.715 1.725 1.736 1.746 1.757 1.768 1.778 1.789 1.799 1.81 1.82 1.831 1.841 1.852 1.862 1.873 1.883 1.894 1.904 1.915 1.925 1.936 1.946 1.957 1.967 1.978 1.988 1.999 2.01 2.02 2.031 2.041 2.052 2.062 2.073 2.083 2.094 2.104 2.115 2.125 2.136 2.146 2.157 2.167 2.178 2.188 2.199 2.209 2.22 2.23 2.241 2.252 2.262 2.273 2.283 2.294 2.304 2.315 2.325 2.336 2.346 2.357 2.367 2.378 2.388 2.399 2.409 2.42 2.43 2.441 2.451 2.462 2.472 2.483 2.493 2.504 2.515 2.525 2.536 2.546 2.557 2.567 2.578 2.588 2.599 2.609 2.62 2.63 2.641 2.651 2.662 2.672 2.683 2.693 2.704 2.714 2.725 2.735 2.746 2.757 2.767 2.778 2.788 2.799 2.809 2.82 2.83 2.841 2.851 2.862 2.872 2.883 2.893 2.904 2.914 2.925 2.935 2.946 2.956 2.967 2.977 2.988 2.998 3.009 3.02 3.03 3.041 3.051 3.062 3.072 3.083 3.093 3.104 3.114 3.125 3.135 3.146 3.156 3.167 3.177 3.188 3.198 3.209 3.219 3.23 3.24 3.251 3.262 3.272 3.283 3.293 3.304 3.314 3.325 3.335 3.346 3.356 3.367 3.377 3.388 3.398 3.409 3.419 3.43 3.44 3.451 3.461 3.472 3.482 3.493 3.504 3.514 3.525 3.535 3.546 3.556 3.567 3.577 3.588 3.598 3.609 3.619 3.63 3.64 3.651 3.661 3.672 3.682 3.693 3.703 3.714 3.724 3.735 3.745 3.756 3.767 3.777 3.788 3.798 3.809 3.819 3.83 3.84 3.851 3.861 3.872 3.882 3.893 3.903 3.914 3.924 3.935 3.945 3.956 3.966 3.977 3.987 3.998 4.009 4.019 4.03 4.04 4.051 4.061 4.072 4.082 4.093 4.103 4.114 4.124 4.135 4.145 4.156 4.166 4.177 4.187 4.198 4.208 4.219 4.229 4.24 4.251 4.261 4.272 4.282 4.293 4.303 4.314 4.324 4.335 4.345 4.356 4.366 4.377 4.387 4.398 4.408 4.419 4.429 4.44 4.45 4.461 4.471 4.482 4.492 4.503 4.514 4.524 4.535 4.545 4.556 4.566 4.577 4.587 4.598 4.608 4.619 4.629 4.64 4.65 4.661 4.671 4.682 4.692 4.703 4.713 4.724 4.734 4.745 4.756 4.766 4.777 4.787 4.798 4.808 4.819 4.829 4.84 4.85 4.861 4.871 4.882 4.892 4.903 4.913 4.924 4.934 4.945 4.955 4.966 4.976 4.987 4.997 5.008 5.019 5.029 5.04 5.05 5.061 5.071 5.082 5.092 5.103 5.113 5.124 5.134 5.145 5.155 5.166 5.176 5.187 5.197 5.208 5.218 5.229 5.239 5.254.907e-07 5.178e-07 5.463e-07 5.763e-07 6.08e-07 6.413e-07 6.764e-07 7.133e-07 7.521e-07 7.93e-07 8.361e-07 8.813e-07 9.29e-07 9.791e-07 1.032e-06 1.087e-06 1.145e-06 1.207e-06 1.271e-06 1.339e-06 1.41e-06 1.485e-06 1.564e-06 1.646e-06 1.733e-06 1.824e-06 1.92e-06 2.021e-06 2.126e-06 2.237e-06 2.354e-06 2.476e-06 2.605e-06 2.74e-06 2.881e-06 3.03e-06 3.186e-06 3.349e-06 3.521e-06 3.701e-06 3.89e-06 4.088e-06 4.295e-06 4.513e-06 4.741e-06 4.98e-06 5.231e-06 5.494e-06 5.769e-06 6.058e-06 6.361e-06 6.677e-06 7.009e-06 7.357e-06 7.721e-06 8.102e-06 8.501e-06 8.919e-06 9.357e-06 9.815e-06 1.029e-05 1.08e-05 1.132e-05 1.187e-05 1.244e-05 1.305e-05 1.367e-05 1.433e-05 1.502e-05 1.574e-05 1.649e-05 1.727e-05 1.809e-05 1.895e-05 1.985e-05 2.079e-05 2.176e-05 2.279e-05 2.385e-05 2.497e-05 2.614e-05 2.735e-05 2.862e-05 2.995e-05 3.133e-05 3.278e-05 3.428e-05 3.586e-05 3.75e-05 3.921e-05 4.1e-05 4.286e-05 4.48e-05 4.683e-05 4.894e-05 5.114e-05 5.344e-05 5.583e-05 5.833e-05 6.093e-05 6.363e-05 6.646e-05 6.94e-05 7.246e-05 7.565e-05 7.897e-05 8.243e-05 8.603e-05 8.978e-05 9.368e-05 9.774e-05 0.000102 0.0001064 0.0001109 0.0001157 0.0001207 0.0001258 0.0001312 0.0001367 0.0001425 0.0001486 0.0001548 0.0001613 0.0001681 0.0001751 0.0001824 0.00019 0.0001979 0.0002061 0.0002146 0.0002234 0.0002326 0.0002421 0.000252 0.0002623 0.0002729 0.000284 0.0002954 0.0003073 0.0003197 0.0003325 0.0003458 0.0003595 0.0003738 0.0003886 0.000404 0.0004199 0.0004364 0.0004535 0.0004712 0.0004895 0.0005085 0.0005282 0.0005486 0.0005698 0.0005916 0.0006143 0.0006377 0.000662 0.0006871 0.0007131 0.00074 0.0007679 0.0007967 0.0008265 0.0008573 0.0008892 0.0009221 0.0009562 0.0009915 0.001028 0.001066 0.001104 0.001145 0.001186 0.001229 0.001273 0.001319 0.001366 0.001415 0.001466 0.001518 0.001572 0.001627 0.001684 0.001743 0.001804 0.001867 0.001932 0.001999 0.002068 0.002139 0.002212 0.002288 0.002366 0.002446 0.002529 0.002614 0.002702 0.002793 0.002886 0.002982 0.003081 0.003183 0.003288 0.003396 0.003507 0.003622 0.00374 0.003861 0.003985 0.004114 0.004246 0.004381 0.004521 0.004664 0.004812 0.004963 0.005119 0.005279 0.005444 0.005613 0.005787 0.005966 0.006149 0.006337 0.006531 0.006729 0.006933 0.007142 0.007357 0.007577 0.007803 0.008035 0.008273 0.008517 0.008768 0.009025 0.009288 0.009558 0.009835 0.01012 0.01041 0.01071 0.01101 0.01132 0.01164 0.01197 0.01231 0.01265 0.01301 0.01337 0.01373 0.01411 0.0145 0.01489 0.0153 0.01571 0.01614 0.01657 0.01701 0.01747 0.01793 0.0184 0.01888 0.01938 0.01988 0.0204 0.02093 0.02146 0.02201 0.02257 0.02315 0.02373 0.02433 0.02494 0.02556 0.0262 0.02684 0.0275 0.02818 0.02886 0.02956 0.03028 0.03101 0.03175 0.0325 0.03327 0.03406 0.03486 0.03567 0.0365 0.03735 0.03821 0.03908 0.03998 0.04088 0.04181 0.04275 0.0437 0.04467 0.04566 0.04667 0.04769 0.04873 0.04979 0.05086 0.05196 0.05307 0.05419 0.05534 0.0565 0.05768 0.05888 0.0601 0.06134 0.06259 0.06387 0.06516 0.06647 0.0678 0.06915 0.07052 0.07191 0.07331 0.07474 0.07619 0.07765 0.07914 0.08064 0.08217 0.08371 0.08527 0.08686 0.08846 0.09008 0.09172 0.09338 0.09506 0.09677 0.09849 0.1002 0.102 0.1038 0.1056 0.1074 0.1092 0.1111 0.113 0.1148 0.1168 0.1187 0.1206 0.1226 0.1246 0.1266 0.1286 0.1307 0.1327 0.1348 0.1369 0.139 0.1411 0.1433 0.1455 0.1476 0.1498 0.152 0.1543 0.1565 0.1588 0.161 0.1633 0.1656 0.1679 0.1703 0.1726 0.175 0.1773 0.1797 0.1821 0.1845 0.1869 0.1894 0.1918 0.1942 0.1967 0.1992 0.2016 0.2041 0.2066 0.2091 0.2116 0.2141 0.2166 0.2191 0.2217 0.2242 0.2267 0.2293 0.2318 0.2343 0.2369 0.2394 0.242 0.2445 0.2471 0.2496 0.2521 0.2547 0.2572 0.2598 0.2623 0.2648 0.2673 0.2698 0.2723 0.2748 0.2773 0.2798 0.2823 0.2848 0.2872 0.2896 0.2921 0.2945 0.2969 0.2993 0.3017 0.304 0.3064 0.3087 0.311 0.3133 0.3156 0.3179 0.3201 0.3224 0.3246 0.3267 0.3289 0.331 0.3332 0.3352 0.3373 0.3394 0.3414 0.3434 0.3453 0.3473 0.3492 0.3511 0.3529 0.3547 0.3565 0.3583 0.36 0.3617 0.3634 0.365 0.3666 0.3682 0.3697 0.3712 0.3727 0.3741 0.3755 0.3768 0.3782 0.3794 0.3807 0.3819 0.3831 0.3842 0.3853 0.3863 0.3873 0.3883 0.3892 0.3901 0.3909 0.3917 0.3925 0.3932 0.3939 0.3945 0.3951 0.3957 0.3962 0.3966 0.3971 0.3974 0.3978 0.398 0.3983 0.3985 0.3986 0.3988 0.3988 0.3988 0.3988 0.3988 0.3986 0.3985 0.3983 0.398 0.3978 0.3974 0.3971 0.3966 0.3962 0.3957 0.3951 0.3945 0.3939 0.3932 0.3925 0.3917 0.3909 0.3901 0.3892 0.3883 0.3873 0.3863 0.3853 0.3842 0.3831 0.3819 0.3807 0.3794 0.3782 0.3768 0.3755 0.3741 0.3727 0.3712 0.3697 0.3682 0.3666 0.365 0.3634 0.3617 0.36 0.3583 0.3565 0.3547 0.3529 0.3511 0.3492 0.3473 0.3453 0.3434 0.3414 0.3394 0.3373 0.3352 0.3332 0.331 0.3289 0.3267 0.3246 0.3224 0.3201 0.3179 0.3156 0.3133 0.311 0.3087 0.3064 0.304 0.3017 0.2993 0.2969 0.2945 0.2921 0.2896 0.2872 0.2848 0.2823 0.2798 0.2773 0.2748 0.2723 0.2698 0.2673 0.2648 0.2623 0.2598 0.2572 0.2547 0.2521 0.2496 0.2471 0.2445 0.242 0.2394 0.2369 0.2343 0.2318 0.2293 0.2267 0.2242 0.2217 0.2191 0.2166 0.2141 0.2116 0.2091 0.2066 0.2041 0.2016 0.1992 0.1967 0.1942 0.1918 0.1894 0.1869 0.1845 0.1821 0.1797 0.1773 0.175 0.1726 0.1703 0.1679 0.1656 0.1633 0.161 0.1588 0.1565 0.1543 0.152 0.1498 0.1476 0.1455 0.1433 0.1411 0.139 0.1369 0.1348 0.1327 0.1307 0.1286 0.1266 0.1246 0.1226 0.1206 0.1187 0.1168 0.1148 0.113 0.1111 0.1092 0.1074 0.1056 0.1038 0.102 0.1002 0.09849 0.09677 0.09506 0.09338 0.09172 0.09008 0.08846 0.08686 0.08527 0.08371 0.08217 0.08064 0.07914 0.07765 0.07619 0.07474 0.07331 0.07191 0.07052 0.06915 0.0678 0.06647 0.06516 0.06387 0.06259 0.06134 0.0601 0.05888 0.05768 0.0565 0.05534 0.05419 0.05307 0.05196 0.05086 0.04979 0.04873 0.04769 0.04667 0.04566 0.04467 0.0437 0.04275 0.04181 0.04088 0.03998 0.03908 0.03821 0.03735 0.0365 0.03567 0.03486 0.03406 0.03327 0.0325 0.03175 0.03101 0.03028 0.02956 0.02886 0.02818 0.0275 0.02684 0.0262 0.02556 0.02494 0.02433 0.02373 0.02315 0.02257 0.02201 0.02146 0.02093 0.0204 0.01988 0.01938 0.01888 0.0184 0.01793 0.01747 0.01701 0.01657 0.01614 0.01571 0.0153 0.01489 0.0145 0.01411 0.01373 0.01337 0.01301 0.01265 0.01231 0.01197 0.01164 0.01132 0.01101 0.01071 0.01041 0.01012 0.009835 0.009558 0.009288 0.009025 0.008768 0.008517 0.008273 0.008035 0.007803 0.007577 0.007357 0.007142 0.006933 0.006729 0.006531 0.006337 0.006149 0.005966 0.005787 0.005613 0.005444 0.005279 0.005119 0.004963 0.004812 0.004664 0.004521 0.004381 0.004246 0.004114 0.003985 0.003861 0.00374 0.003622 0.003507 0.003396 0.003288 0.003183 0.003081 0.002982 0.002886 0.002793 0.002702 0.002614 0.002529 0.002446 0.002366 0.002288 0.002212 0.002139 0.002068 0.001999 0.001932 0.001867 0.001804 0.001743 0.001684 0.001627 0.001572 0.001518 0.001466 0.001415 0.001366 0.001319 0.001273 0.001229 0.001186 0.001145 0.001104 0.001066 0.001028 0.0009915 0.0009562 0.0009221 0.0008892 0.0008573 0.0008265 0.0007967 0.0007679 0.00074 0.0007131 0.0006871 0.000662 0.0006377 0.0006143 0.0005916 0.0005698 0.0005486 0.0005282 0.0005085 0.0004895 0.0004712 0.0004535 0.0004364 0.0004199 0.000404 0.0003886 0.0003738 0.0003595 0.0003458 0.0003325 0.0003197 0.0003073 0.0002954 0.000284 0.0002729 0.0002623 0.000252 0.0002421 0.0002326 0.0002234 0.0002146 0.0002061 0.0001979 0.00019 0.0001824 0.0001751 0.0001681 0.0001613 0.0001548 0.0001486 0.0001425 0.0001367 0.0001312 0.0001258 0.0001207 0.0001157 0.0001109 0.0001064 0.000102 9.774e-05 9.368e-05 8.978e-05 8.603e-05 8.243e-05 7.897e-05 7.565e-05 7.246e-05 6.94e-05 6.646e-05 6.363e-05 6.093e-05 5.833e-05 5.583e-05 5.344e-05 5.114e-05 4.894e-05 4.683e-05 4.48e-05 4.286e-05 4.1e-05 3.921e-05 3.75e-05 3.586e-05 3.428e-05 3.278e-05 3.133e-05 2.995e-05 2.862e-05 2.735e-05 2.614e-05 2.497e-05 2.385e-05 2.279e-05 2.176e-05 2.079e-05 1.985e-05 1.895e-05 1.809e-05 1.727e-05 1.649e-05 1.574e-05 1.502e-05 1.433e-05 1.367e-05 1.305e-05 1.244e-05 1.187e-05 1.132e-05 1.08e-05 1.029e-05 9.815e-06 9.357e-06 8.919e-06 8.501e-06 8.102e-06 7.721e-06 7.357e-06 7.009e-06 6.677e-06 6.361e-06 6.058e-06 5.769e-06 5.494e-06 5.231e-06 4.98e-06 4.741e-06 4.513e-06 4.295e-06 4.088e-06 3.89e-06 3.701e-06 3.521e-06 3.349e-06 3.186e-06 3.03e-06 2.881e-06 2.74e-06 2.605e-06 2.476e-06 2.354e-06 2.237e-06 2.126e-06 2.021e-06 1.92e-06 1.824e-06 1.733e-06 1.646e-06 1.564e-06 1.485e-06 1.41e-06 1.339e-06 1.271e-06 1.207e-06 1.145e-06 1.087e-06 1.032e-06 9.791e-07 9.29e-07 8.813e-07 8.361e-07 7.93e-07 7.521e-07 7.133e-07 6.764e-07 6.413e-07 6.08e-07 5.763e-07 5.463e-07 5.178e-07 4.907e-07

plot of chunk unnamed-chunk-13

based on the test statics of p-value of 0.8266 there is strong evidence that we fail to reject the null hypothesis there is no relationship between mothers' ages and the term of their pregnancy.

Short Answer Questions

1. Global warming. We considered the differences between the temperature readings in January 1 of 1968 and 2008 at 51 locations in the continental US. The mean and standard deviation of the reported differences are 1.1 degrees and 4.9 degrees, respectively.

(a) Calculate a 90% confidence interval for the average difference between the temperature measurements between 1968 and 2008.

meandiff <- 1.1
sddiff <- 4.9
n<- 51
semeandiff<-sddiff/sqrt(51)
semeandiff
[1] 0.6861
lower <-meandiff - qt(0.95, df=50)*semeandiff
upper <- meandiff + qt(0.95, df=50)*semeandiff
c(lower, upper)
[1] -0.0499  2.2499

(b) Interpret this interval in context.

Between January 1 of 1968 and 2008, the 90% confidence interval of the average difference in temperature is between -0.0321 and 2.2321.

© Does the confidence interval provide convincing evidence that the temperature was higher in 2008 than in 1968 in the continental US? Explain.

No, it doesn't. The null hypothesis for this question would be that the difference between the average of two temperature reading is zero. Since the calculated lower confidence level is negative (below zero) and the upper level is positive we fail to reject the null hypothesis as the mean of the temperature differences could be zero.

2. Cleveland vs. Sacramento Average income varies from one region of the country to another, and it often reflects both lifestyles and regional living expenses. Suppose a new graduate is considering a job in two locations, Cleveland, OH and Sacramento, CA, and he wants to see whether the average income in one of these cities is higher than the other. He would like to conduct a t test based on two small samples from the 2000 Census, but he first must consider whether the conditions are met to implement the test. Below are histograms for each city. Should he move forward with the t test? Explain your reasoning.

The distribution of income for Cleveland and Sacramento need to be normal for the t test to be valid. The sample size are small, 21 for cleveland and 17 for Sacramento so we would expect reasonable skewness of the data. First he needs to consider if the two sample means are independent (from less than 10% of the population). Another condition for the distribution to be considered near normal is that the distribution of sample observations is not strongly skewed. Looking at the histograms and the statistical summaries I do not think he should carry forward with the t test because both samples have strong positively skewed outliers.

3. Sleep habits of New Yorkers. New York is known as “the city that never sleeps”. A random sample of 25 New Yorkers were asked how much sleep they get per night. Statistical summaries of these data are shown below. Do these data provide strong evidence that New Yorkers sleep less than 8 hours a night on average?

n x¯ s min max 25 7.73 0.77 6.17 9.78

(a) Write the hypotheses in symbols and in words.

(b) Check conditions, then calculate the test statistic, T, and the associated degrees of freedom.

The observations are simple random sample and consist of less thand 10% of New Yorkers, therefore independence is reasonable. The summary statistics do notsuggest any strong skew or outliers. The normality assumption seems reasonable.

We use the row with 24 degrees of freedom (25 - 1). The value T = 1.753 (ignore the negative sign)

null <- 8
sd <- 0.77
n <- 25
mean <-7.73
t <-(mean-null)/(sd/sqrt(n))
t
[1] -1.753

© Find and interpret the p-value in this context. Drawing a picture may be helpful.

Based on the degrees of freedom of 24 T value of 1.753 falls between the 2nd of 3rd columns. Since this is a single tail test this corresponds to a p-value between 0.025 and 0.05. The p-value is not guaranteed to be less than 0.05 so we fail to reject the null hypothesis.

(d) What is the conclusion of the hypothesis test?

These data does not provide strong evidence that New Yorkers sleep less than 8 hours a night on average.

(e) If you were to construct a 90% confidence interval that corresponded to this hypothesis test, would you expect 8 hours to be in the interval?

Yes the interval contains the 8 hours.

mean
[1] 7.73
se<-0.77/sqrt(25)
se
[1] 0.154
t24<-2.49
lower<-mean-t24*se
upper <-mean+t24*se
c(lower,upper)
[1] 7.347 8.113

4. Chicken diet and weight. The ANOVA output below can be used to test for differences between theaverage weights of chicks on different diets. Conduct a hypothesis test to determine if these data provide convincing evidence that the average weight of chicks varies across some (or all) groups. Make sure to check relevant conditions. Figures and summary statistics are shown below.

Since the calculated p value is so small we reject the null hypothesis.

Looking at the boxplot the variance for each group is not equal from one to the next. The group for horsebean and sunflower have a much smaller variance than the rest of the group.

observedF <-15.36
pf(observedF, df1 = 5, df2 = 65, lower.tail=FALSE)
[1] 5.968e-10

5. Caffeine is the world's most widely used stimulant, with approximately 80% consumed in the form of Coffee. Participants in a study investigating the relationship between coffee consumption and exercise were asked to report the number of hours they spent per week on moderate (e.g., brisk walking) and vigorous (e.g., strenuous sports and jogging) exercise. Based on these data the researchers estimated the total hours of metabolic equivalent tasks (MET) per week, a value always greater than 0. The table below gives summary statistics of MET for women in this study based on the amount of coffee consumed.

(a) Write the hypotheses for evaluating if the average physical activity level varies among the different levels of coffee consumption.

(b) Check conditions and describe any assumptions you must make to proceed with the test.

Three conditions must be checked before ANOVA analsysi:

© Below is part of the output associated with this test. Fill in the empty cells.

(d) What is the conclusion of the test?

Since the P value of 0.0003 is much smaller than the assumed significance level of 0.05 we reject the null hypoesis and conclude that the average physical activity level varies among at least some of the different levels of coffee consumption.