| Purpose | Technique | Notes |
|---|---|---|
| compare 2 means (quantitative/ numeric) | T-test | |
| compare 2 or more categories (qualitative/ counts) | chi square test | |
| compare continuous variable | ANOVA analysis |
More info: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3900058/
Collect your data, and summarize it in a two-way table. These numbers represent the observed cell counts.
Set up your null hypothesis, Ho: Variables are independent; and the alternative hypothesis, Ha: Variables are dependent.
Calculate the expected cell counts under the assumption of independence.
Check the conditions of the Chi-square test before proceeding; each expected cell count must be greater than or equal to five.
Figure the Chi-square test statistic. This statistic finds the observed cell count minus the expected cell count, squares the difference, and divides it by the expected cell count. Do these steps for each cell, and then add them all up.
Look up your test statistic on the Chi-square table (Table A-3 in the appendix) and find the p-value (or one that’s close).
If your result is less than your predetermined cutoff (the α level), usually 0.05, reject Ho and conclude dependence of the two variables.
example with table
image of graph
datamatrix = matrix(c(4700,3500,4300, 3300, 1500,1000), nrow = 3, ncol = 2, byrow = TRUE, dimnames=list(c("treatment1", "treatment2", "control"), c("died", "alive")))
datamatrix
## died alive
## treatment1 4700 3500
## treatment2 4300 3300
## control 1500 1000
chisq.test(datamatrix)
##
## Pearson's Chi-squared test
##
## data: datamatrix
## X-squared = 9.0245, df = 2, p-value = 0.01097
print("Conclusion: at least one is different because the p-value is < 5%.")
## [1] "Conclusion: at least one is different because the p-value is < 5%."
Why Bonferroni? It’s designed to avoid overanalyzing data until you find a connection.
Suppose a researcher wants to find out what variable is related to sales of bedroom slippers. He collects data on everything he can think of, including the size of people’s feet, the frequency with which they go out to get the paper in their slippers, and their favorite colors.
Not finding anything significant, he goes on to examine marital status, age, and income. Still coming up short, he goes out on a limb and looks at hair color, whether or not the subjects have seen a circus, and where they like to sit on an airplane (aisle or window, sir?).
Then wouldn’t you know, he strikes gold. Turns out that, according to his data, people who sit on the aisles on planes are more likely to buy bedroom slippers than those who sit by the window or in the middle of a row.
What’s wrong with this picture? Too many tests. Each time the researcher examines one variable and conducts a test on it, he chooses an α level at which to conduct the test. (Recall that the α level is the amount of chance you’re willing to take of rejecting the null hypothesis and making a false alarm.)
As the number of tests increases, the α’s pile up. Suppose α is chosen to be 0.05. The researcher then has a 5 percent chance of being wrong in finding a significant conclusion, just by chance. So if he does 100 tests, each with a 5 percent chance of an error, on average 5 of those 100 tests will result in a statistically significant result, just by chance.
However, researchers who don’t know that (or who know and go ahead regardless) find results that they claim are significant even though they’re really bogus.
Rumsey, Deborah J.. Statistics II for Dummies (pp. 185-186). Wiley. Kindle Edition.