Biostatistics
Lesson 12—The Chi-Square Test for Goodness of Fit
By Olivia Mah
First published on April 20, 2019
Learning Objectives
Perform a chi-square goodness-of-fit test.
Demonstration
Goal: To conduct a chi-square goodness-of-test for #21.24 in our textbook.
For #21.24, the null hypothesis is:
\(H_0: p_{tall} = 0.75, p_{dwarf} = 0.25 \)
Here is the R code:
chisq.test(c(787, 277), p=c(0.75, 0.25))
Explanation:
We use the R function chisq.test to run a chi-square test.
The arguments for the chisq.test function are:
c(787, 277) is the vector that stores the two observed values
p=c(0.75, 0.25) is the vector that stores the probabilities in the theoretical model (ratio 3:1). (We must use the letter p but not any other letters in this chisq.test function).
-END-