Exercise 1:

A researcher is studying the sugar content of the different snack options given to elementary school students in a summer camp. The results of the amount of grams of sugar found in 20 snack options are stored in the vector “sugar_content” (see code chunk below).

From previous research done on this topic, the researcher knows that the sugar content in any food is well described by a normal distribution.

The researcher wants to know if the average sugar content of the different snack options given to students meets the diabetic nutrition standards, which requires the sugar content to be no more than 11 grams.

  1. State the hypotheses that the research will be using to conduct her study.

Ho:μ <= 11 grams

Ha:μ > 11 grams (right tail test)

Run the following code chunk to create the vector with the data:

sugar_content= c(10.8, 10.7, 10.3, 9.9, 13.6, 9.2, 12.3, 13.2, 11.5, 13.7 , 11.9 , 9.5, 10.4, 8.9, 10.4, 10.3 , 9.8, 11.1, 14.4, 12.3)
  1. Obtain the sample mean and sample standard deviation of the sugar content. Can the researcher reach a conclusion simply based on the sample mean and sample standard deviation?
mean(sugar_content)
## [1] 11.21
sd(sugar_content)
## [1] 1.596015

since mean is 11.21 is close to 11 then the mean is not enough to determine exclusively from the mean so the test statistic and p-value is computed

No, just because the sample mean is greater than 11 it does not mean that, at the population level (all the snacks), the average is greater than 11. We need to figure out is 11.21 is sufficiently far away from 11. Is it? The test statistic and the p-value will tell us.

Note: Remember that, in the simulation example, the population mean was 20 and sometimes the sample was above 20.

  1. Run the statistical test using the corresponding R built-in function.

Observe the value of the test statistic and make sure you know what formula is used to compute it (you do NOT have to compute the test statistic because its value is given as part of the output. Just make sure you know what formula is used to get it).

t.test(sugar_content, alternative = c("greater"), mu=11)
## 
##  One Sample t-test
## 
## data:  sugar_content
## t = 0.58843, df = 19, p-value = 0.2816
## alternative hypothesis: true mean is greater than 11
## 95 percent confidence interval:
##  10.59291      Inf
## sample estimates:
## mean of x 
##     11.21
# the alternative Ha is greater
#(11.21-11)/(1.596015/sqrt(20))
  1. Make the appropriate conclusion using a significance level of 0.05.

p = 0.2816 > 0.05 therefore we fail to reject Ho

therefore the data does not give us evidence to support the suspicion that the average sugar content is above 11 grams. The diabetic nutritional standard seems to be satisfied

p-value = 0.2816 > alpha (0.05); therefore, we fail to reject Ho.

Therefore, the data does NOT give us evidence to support the suspicion that the average sugar content is above 11 grams. The diabetic nutrition standards seems to be satisfied.

Exercise 2:

Suppose a clinical trial is underway to see if medicine X is effective to improve the symptoms associated with disease Y. Researchers worry that medicine X may increase a patient’s cholesterol levels. As part of the introductory phase of the clinical protocol, researchers want to detect early signs of cholesterol increase. For that, they ask you to run an analysis of the cholesterol levels (in mg/dl) of 20 patients who have taken medicine X for a significant amount of time. Cholesterol level is a random variable well described by the normal distribution.

The cholesterol data for these 20 patients can be found in the vector “cholest_trial” (see code chunk below).

Conduct a hypothesis test to see if you find evidence that the average cholesterol level of patients who take medicine X is above the desired level of 200 mg/dl.

  1. State the hypotheses needed to conduct this study.

Ho: μ <= 200mg/dl

Ha: μ > 200mg/dl (right tail test)

The > great than always goes on the bottom when cholesterol level 200mg/dl or less the situation is ok (status-quo or Ho)

Run the following code chunk to create the vector with the data:

cholest_trial= c(178.81, 188.87, 200.36, 214.80, 186.77, 183.99, 211.50, 232.32, 215.00, 250.41, 227.28, 227.76, 186.11, 188.27, 197.36, 242.25, 215.69, 224.23, 237.97,195.99)
  1. Run the statistical test using the corresponding R built-in function. .
t.test(cholest_trial, alternative=c("greater"), mu=200)
## 
##  One Sample t-test
## 
## data:  cholest_trial
## t = 2.1163, df = 19, p-value = 0.02387
## alternative hypothesis: true mean is greater than 200
## 95 percent confidence interval:
##  201.882     Inf
## sample estimates:
## mean of x 
##   210.287
# the alternative Ha is greater
  1. Make the appropriate conclusion using a significance level of 0.05.

p-value 0.02387 < 0.05(alpha)

p-value = 0.02387 < alpha (0.05); therefore, we reject Ho and support Ha.

Therefore, the data (sample) is giving us evidence to conclude that the cholesterol level is above 200; thus, the drug does not seem safe with respect to cholesterol level.

Exercise 3:

A sample formed by 21 water samples was randomly taken to assess the zinc concentration (mg/L) in the drinking water in a given neighborhood.

The data is stored in the vector “zinc_conc”. Run the following code chunk to create this vector:

zinc_conc= c(5.25, 5.02, 5.49, 5.35, 5.15, 4.95, 5.11, 5.02, 5.37, 5.30, 4.87, 5.02, 5.27, 5.28, 5.41, 4.96, 4.76, 6.02, 5.68, 4.86, 5.52)
  1. Obtain a 95% CI for the average zinc concentration in the drinking water in the whole neighborhood.

95% is the confidence level

t.test(zinc_conc, conf.level = 0.95)$conf.int
## [1] 5.083668 5.360142
## attr(,"conf.level")
## [1] 0.95

The 95% CI is (5.083668 5.360142) lower limit 5.083668 upper limit 5.360142

  1. Obtain a 99% CI and compare its width with the previous CI.
t.test(zinc_conc, conf.level = 0.99)$conf.int
## [1] 5.033344 5.410466
## attr(,"conf.level")
## [1] 0.99

The 99% CI is (5.033344 5.410466)

5.360142 - 5.083668
## [1] 0.276474
5.410466 - 5.033344
## [1] 0.377122

the wind with the largest percent interval is 0.99 which is 0.377122

  1. Let’s say that nine new values of zinc concentration has been added to the previous sample (maybe a coworker had collected these nine values in the same spot where you collected yours but you did not know about it).

Run the following code chunk to add these new values to the sample:

zinc_conc = c(zinc_conc, 5.30, 5.45, 4.90, 4.85, 5.05, 4.80, 4.96, 5.03, 5.22)

Obtain a new 95% CI and comment on the observed effect of sample size on the interval width. In other words, given a confidence level, what is the effect on increasing the sample size on the interval’s width?