Goals for this lab.

Setup and packages

As usual, we start by loading our two packages: mosaic and ggformula. To load a package, you use the library() function. I’ve put the code to load one package into the chunk below. Add the other package you need.

library(mosaic)

# put in the other package that you need here

M&Ms Color Distribution

In this lab we will perform two different chi-square goodness of fit tests to determine whether the colors of M&Ms are uniformly distributed or whether the colors match a specified set of proportions described by the manufacturer. We will each open a mini-bag of M&Ms, count the number of Red, Orange, Yellow, Green, Blue and Brown M&Ms, then combine our data into one larger sample. Our first step is to put your counts and the combined class counts into the in-class Handout. Feel free to eat the M&Ms after the color counts are recorded.

Hypothesis Test 1: Are the colors distributed uniformly?

First we will investigate whether the colors are distributed uniformly, meaning we would expect to see and equal number of each color.

\[H_0: \pi_{red} = \pi_{orange} = \pi_{yellow} = \pi_{green} = \pi_{blue}= \pi_{brown} = 1/6\]

\[H_a:\textrm{ At least one of the population proportions is different from 1/6}\]

  1. Are the validity conditions for a chi-square test met? Explain why or why not, and what you are checking.

  2. Use the chisq.test function to calculate a theory-based p-value for the hypothesis test above. Write your executable code in the chunk below.

#chi-square goodness of fit
  1. Record your theory-based p-value, \(\chi^2\), and conclusions (with context) below.

theory-based p-value:

chi-square:

Conclusion with context:

Hypothesis Test 2: Are the colors distributed as claimed?

It is claimed that the color distributions of regular M&Ms is actually 13% red, 20% orange, 14% yellow, 16% green, 24% blue, and 13% brown. We will perform the following hypothesis test

\[H_0: \pi_{red} =0.13, \ \pi_{orange} = 0.20, \ \pi_{yellow} = 0.14, \ \pi_{green} = 0.16, \ \pi_{blue}= 0.24, \textrm{ and } \pi_{brown} = 0.13\]

\[H_a:\textrm{ At least one of the population proportions is different from the values claimed}\]

  1. Use the worksheet from class to calculate \(\chi^2\) and show all your steps. Attach that worksheet to your lab when you turn it in.

  2. Use the chisq.test function to calculate a theory-based p-value for the hypothesis test above. Write your executable code in the code chunk below.

#chi-square goodness of fit
  1. Record your theory-based p-value, \(\chi^2\), and conclusions with context below.

theory-based p-value:

chi-square:

Conclusion with context: