Recall our very first data collection exercise where I asked you to weigh two cookies separately.
The company claims that every pack of two cookies weighs 21 grams.
We are evaluating this claim based on some purchased boxes of 16 packs.
This is clearly a hypothesis testing application.
What is the estimand?
The estimand or the parameter of interest here is the total weight (or if you wish the average weight) in grams of the two cookies in the population of all packs of two cookies across all boxes of 16 packs each.
We can call that estimand \(\mu\) and we are evaluating the company’s claim that \(\mu=10.5\) grams.
You can apply what you learned in Chapters 6 and 7, if you want.
A nicer qq-plot is available in the package car. The command is qqPlot().
You may have to install this if you want to run the commands here for yourself.
This plot has confidence bands which may help in deciding whether the “goodness-of-fit” to the normal is acceptable to some extent.
par(mfrow =c(1, 2))hist(wt.avg[-46], freq =FALSE)curve(dnorm(x, mean=mean(wt.avg[-46]), sd=sd(wt.avg[-46])), add =TRUE, col ="hotpink2")library(car)qqPlot(wt.avg[-46], id =FALSE)
Dropping the “outlier”
Normality seems to be compatible with the data.
Let us try to proceed with the approach in Chapter 7 and evaluate the company’s claim.
t.test(wt.avg[-46], mu =10.5)
One Sample t-test
data: wt.avg[-46]
t = 1.3106, df = 62, p-value = 0.1948
alternative hypothesis: true mean is not equal to 10.5
95 percent confidence interval:
10.46732 10.65713
sample estimates:
mean of x
10.56222
Retaining the “outlier”
We can retain the “outlier” if this is an important data point.
But the justification here is using the central limit theorem and IID, of course.
t.test(wt.avg, mu =10.5)
One Sample t-test
data: wt.avg
t = 1.6326, df = 63, p-value = 0.1075
alternative hypothesis: true mean is not equal to 10.5
95 percent confidence interval:
10.47432 10.75489
sample estimates:
mean of x
10.61461
Many issues with the previous analysis
Can we act as if we did not do any pre-processing?
We have done multiple tests and carried out different analyses (under different assumptions).
What should we report?
Although the problem we are answering looks simple, every research process goes through what we have just seen.
The temptation to dig more
Although we set out to actually test only the company’s claim, you might be tempted to explore beyond what you set out to do.
There are sometimes issues related to this kind of exploration, that is why some have started to look into pre-registration.
There are many other things to explore but…
In fact, you may be inclined to explore whether there is a difference in the weights of the two cookies in one pack.
This should be relatively easy to implement but it is a bit different from a two-sample \(t\)-test discussed in Chapter 9.
But pay attention to the fact that the data collection protocol was not very clear in the sense that the data collection was extremely disorganized. For example, we did not agree which is to be the first and the second cookie.
M&M data analysis
The task here was to evaluate a claim of whether the company’s color distribution in the US for 2008 is the same color distribution as in China.
Df Sum Sq Mean Sq F value Pr(>F)
factor(box) 3 157.9 52.62 0.982 0.408
Residuals 54 2894.5 53.60
Many issues: normality? equal variance across boxes?
Clearly, there is a big problem which we have to fix for an observation in Box 2! Zero coffee chips??
You can repeat the analysis for chocolate chips.
You might also be interested in looking into a different estimand such as the coffee chip to chocolate chip mix. Even more interesting is to find if this mix varies across boxes!
# Apply Example 12.5.1# Number of coffee chips should be Poisson under some assumptions, see HW01cof.grouped$sqrt.x <-sqrt(cof.grouped$x)plot(sqrt.x ~factor(box), data = cof.grouped)
summary(aov(sqrt.x ~factor(box), data = cof.grouped))
Df Sum Sq Mean Sq F value Pr(>F)
factor(box) 3 2.82 0.9387 1.093 0.36
Residuals 54 46.39 0.8591
What to look forward to in the future
A lot!
What we have covered is a very small part of the Analysis portion of the Statistical Method.
Recall that we have Problem, Plan, Data, Analysis, and Conclusion.
There are already a lot of issues in Problem, Plan, Data which cause difficulties in choosing what type of analysis to pursue.
Topics I wish I could have taught
If this class is not part of the 统开课 system, I would have taught:
Chapter 11 on regression: I will show that Chapters 7, 9, 12 can be thought of as special cases of Chapter 11.
Check my analysis of variance notes as to what will be a better way to think of ANOVA now and in the future.
Check my method of moments notes for how to think about regression in the modern way.
Section 5.9 on the bootstrap: I share some notes on these in case you are interested.
Exact hypothesis tests in controlled experiments: Check one of the papers in the project option.
Advice for the future
Focus on true understanding rather than just research.
Find good friends you can trust and can be good to work with.
Always think about what you had done, what you are doing, and what you will be doing.
Communicate and write more in a different language.
Be vigilant and pay attention to what is happening around you.