---
title: "Hypothesis Tests for Population Means"
author: "Evan L. Ray"
date: "November 10, 2017"
output:
  html_document: default
---

```{r setup, include=FALSE}
require(ggplot2)
require(dplyr)
require(readr)
require(mosaic)
```


## Example 1: Chips Ahoy! (Adapted from SDM4 20.43)

Chips Ahoy claims that their 18-ounce bags of chocolate chip cookies contained over 1000 chocolate chips, on average.  Dedicated statistics students at the Air Force Academy purchased some randomly selected bags of cookies and counted the chocolate chips.  The following R chunk reads these data in:

```{r}
cookies <- read_csv("https://mhc-stat140-2017.github.io/data/sdm4/Chips_ahoy.csv")
```

#### Make a density plot of the number of chocolate chips in each bag (the variable is named Chips) and compute the mean and standard deviation of the number of chocolate chips.

SOLUTION:

```{r}
# Your code goes here

```

#### Would it be appropriate to conduct a hypothesis test about the mean number of chocolate chips per bag using these data?  Check all assumptions.

SOLUTION:



#### Regardless of you answer above, let's go ahead with the hypothesis test to see whether the data provide strong evidence that the mean number of chocolate chips is over 1000.  State your null and alternative hypotheses.

SOLUTION:



#### Calculate the p-value using the t.test function in R.

SOLUTION:

```{r}

```

#### Calculate the p-value again using the pt function in R.  You will first need to calculate the test statistic, and then calculate the p-value: the probability of getting a "more extreme" test statistic, assuming the null hypothesis is true.  You should get the same answer as above, up to rounding error.

SOLUTION:



#### Draw a conclusion in the context of this problem.

SOLUTION:



## Example 2: Mercury Contamination in Food

Dolphins are at the top of the oceanic food chain; as a consequence, dangerous substances such as mercury tend to be present in their organs and muscles at high concentrations. In areas where dolphins are regularly consumed, it is important to monitor dolphin mercury levels. This example uses data from a random sample of 19 Risso's dolphins from the Taiji area in Japan.  (Taiji is a significant source of dolphin and whale meat in Japan. Thousands of dolphins pass through the Taiji area annually; assume that these 19 dolphins represent a simple random sample. Data reference: Endo T and Haraguchi K. 2009. High mercury levels in hair samples from residents of Taiji, a Japanese whaling town. Marine Pollution Bulletin 60(5):743-747.)

In a sample of 19 dolphins, the average concentration of mercury was 4.4 micrograms of mercury per wet gram of muscle, with a standard deviation of 2.3 micrograms of mercury per wet gram of muscle.

Based on guidelines from the Food and Agriculture Organization, a subdivision of the World Health Organization, the maximum safe concentration of mercury for someone weighing 70kg who wants to eat a serving of dolphin meat is about 1.32 micrograms of mercury per gram of muscle.

Do the data provide strong evidence that the concentration of mercury in dolphin meat is above the safe limit for consumption?  That is, is the population mean concentration of mercury greater than 1.32 micrograms of mercury per gram of muscle?

#### We don't have the data available to make a plot of the concentration of mercury in dolphin meat for this sample, so we can't check all of the necessary assumptions.  Regardless, list the assumptions necessary for conducting a hypothesis test about the population mean.  Check the assumptions that you can check, and for the rest state what you would need to look at.

SOLUTION:



#### Regardless of you answer above, let's go ahead with the hypothesis test to see whether the data provide strong evidence that the concentration of mercury is greater than 1.32 micrograms per gram of muscle.  State your null and alternative hypotheses.

SOLUTION:



#### Calculate the p-value using the pt function in R.  You will first need to calculate the test statistic, and then calculate the p-value: the probability of getting a "more extreme" test statistic, assuming the null hypothesis is true.

SOLUTION:



#### Draw a conclusion in the context of this problem.

SOLUTION:


