## Friday, January 23, 2015

### M&M ANOVA

Khan Academy does a nice job of explaining ANOVA at this link.  This is in fact where I learned it.  Below I have a nice application of ANOVA using M&Ms that I would like to share.

There are numerous tables below which can be glided over without any loss of understanding.  Indeed, if you just read the prose in between the tables you will be far better off.

In the Fall of 2014, I assigned a series of activities to my Elementary Statistics involving M&Ms.  These activities begin here. There were six groups of students involved and each group took a sample of ten bags of M&Ms.  These samples are listed below.

 Group 1 Color/Bag 1 2 3 4 5 6 7 8 9 10 Red 2 5 2 4 3 7 3 1 7 5 Orange 7 3 6 5 6 7 5 7 6 9 Yellow 2 3 0 1 2 0 2 4 3 4 Green 3 0 6 6 3 2 1 3 4 2 Blue 3 5 4 2 4 7 4 5 4 5 Brown 1 1 1 0 1 3 1 1 1 3

 Group 2 Color/Bag 1 2 3 4 5 6 7 8 9 10 Red 2 2 3 2 2 3 1 6 3 3 Orange 3 4 0 4 4 4 3 2 2 3 Yellow 2 5 5 1 1 1 0 1 2 4 Green 3 1 5 4 4 3 4 2 4 2 Blue 3 2 2 4 3 3 6 1 4 4 Brown 3 2 1 1 2 2 2 4 1 1
 Group 3 Color/bag 1 2 3 4 5 6 7 8 9 10 Red 1 1 1 0 2 3 0 4 0 0 Orange 2 0 1 2 5 6 5 3 1 0 Yellow 1 1 2 0 3 5 0 7 1 3 Green 1 3 1 2 2 1 5 4 1 1 Blue 2 2 4 2 4 5 5 2 2 1 Brown 1 0 0 1 2 0 3 1 2 1
 Group 4 Color/Bag 1 2 3 4 5 6 7 8 9 10 Red 4 5 1 3 1 0 2 2 3 2 Orange 1 1 7 3 3 6 3 5 4 6 Yellow 1 4 6 0 3 2 3 0 3 4 Green 2 3 1 8 4 4 5 6 1 3 Blue 5 1 1 5 4 2 3 3 3 2 Brown 2 3 4 1 3 3 2 1 2 0
 Group 5 Color/Bag 1 2 3 4 5 6 7 8 9 10 Red 2 3 1 5 5 2 0 1 5 5 Orange 2 0 1 3 2 3 3 1 5 3 Yellow 6 2 5 2 3 4 7 7 1 5 Green 2 5 5 7 1 2 4 6 5 1 Blue 1 5 6 2 4 5 4 1 2 3 Brown 3 6 0 1 3 2 3 2 1 1
 Group 6 Color/Bag 1 2 3 4 5 6 7 8 9 10 Red 1 2 2 4 3 3 1 2 1 7 Orange 3 3 1 1 3 1 3 2 1 2 Yellow 3 5 3 3 2 2 3 6 4 4 Green 3 1 7 3 3 6 2 2 4 2 Blue 4 4 1 4 3 3 3 4 4 3 Brown 2 1 4 1 4 2 4 2 5 1
This is a nice collection of real data and my thought was to make the most of it.  As a sample size of ten is small, my thought was to pool the data, but before this can be legitimately done, it must be justified.  One might argue that since all of the samples were taken from M&M's that might be justification enough, but I had lingering doubts.  What if proportion of M&M color is not consistent from batch to batch? What if M&Ms are put out in a variety of Fun Sizes?  What if my students had just royally goofed?  In order to be careful, I decided that after having taught elementary statistics for twenty years it was time to learn ANOVA.

I first wanted to get an good confidence interval for the average number of M&Ms per bag. I calculated that using the data for each group, finding the bag by bag total.  I put that into the following table:

 Bag/Group 1 2 3 4 5 6 1 18 16 8 15 16 16 2 17 16 7 17 21 16 3 19 16 9 20 18 18 4 18 16 7 20 20 16 5 19 16 18 18 18 18 6 26 16 20 17 18 17 7 16 16 18 18 21 16 8 21 16 21 17 18 18 9 25 16 7 16 19 19 10 28 17 6 17 18 19
I then calculated the mean for each of the groups individually and the grand mean of the total pooled data.  Using this, I calculated the sum of the squares for differences within each of the groups and the sum of the squares for differences between the groups.  Those calculations are in the table below:

 DATA Bag/Group 1 2 3 4 5 6 1 18 16 8 15 16 16 2 17 16 7 17 21 16 3 19 16 9 20 18 18 4 18 16 7 20 20 16 5 19 16 18 18 18 18 6 26 16 20 17 18 17 7 16 16 18 18 21 16 8 21 16 21 17 18 18 9 25 16 7 16 19 19 10 28 17 6 17 18 19 GrandMean Means 17.07 20.7 16.1 12.1 17.5 18.7 17.3

 SSW 1 2 3 4 5 6 7.29 0.01 16.81 6.25 7.29 1.69 13.69 0.01 26.01 0.25 5.29 1.69 2.89 0.01 9.61 6.25 0.49 0.49 7.29 0.01 26.01 6.25 1.69 1.69 2.89 0.01 34.81 0.25 0.49 0.49 28.09 0.01 62.41 0.25 0.49 0.09 22.09 0.01 34.81 0.25 5.29 1.69 0.09 0.01 79.21 0.25 0.49 0.49 18.49 0.01 26.01 2.25 0.09 2.89 53.29 0.81 37.21 0.25 0.49 2.89 Sums 156.10 0.90 352.90 22.50 22.10 14.10

 SSB 1 2 3 4 5 6 13.20 0.93 24.67 0.19 2.67 0.05 13.20 0.93 24.67 0.19 2.67 0.05 13.20 0.93 24.67 0.19 2.67 0.05 13.20 0.93 24.67 0.19 2.67 0.05 13.20 0.93 24.67 0.19 2.67 0.05 13.20 0.93 24.67 0.19 2.67 0.05 13.20 0.93 24.67 0.19 2.67 0.05 13.20 0.93 24.67 0.19 2.67 0.05 13.20 0.93 24.67 0.19 2.67 0.05 13.20 0.93 24.67 0.19 2.67 0.05 Sums 132.01 9.34 246.68 1.88 26.68 0.54
The SSW sums to 568.6 and the SSB sums to 417.1.  The numerator has m-1=5 degrees of freedom as we are comparing m=6 groups. The denominator has m*(n-1)=6*(10-1)=54 degrees of freedom as each of those groups took a sample of size n=10.  This gives an F test-statistics of F=7.92.  The critical number for those degrees of freedom with a significance level of  alpha=0.10 is 1.957.  As 7.92 is greater than 1.957, we must conclude that these samples are not all drawn from the same population.

This came as something of surprise to me.  As an educator of over 30 years experience, I immediately suspected student error.  Looking at the SSW and SSB table above, I noted that the numbers from group 3 were considerably larger than the rest.  I was curious as whether and how they had erred.  Discerning this was easy because I had had the students document their process.  In looking at the documentation from group 3, I found the follow photograph:

The student had been told to use Fun Size M&Ms.  It was assumed that they would plain and that the bags would not be mixed.  We are well tutored in how one spells ass-u-me.

I would be remiss at this point, however, if I did not say that I had pushed this further. Elementating group 3 does not fix the problem.  The remaining groups are not sampling the same populations and an examination of the documentation of the other groups does not reveal a similar glaring error in methods.   Of all six groups, only 4 and 6 seem to be sampling the same population.

I will be having my class do a similar experiment this semester--with better instructions from the teacher--and after this I will conduct this study again.