The categories of a categorical variable are given along with the observed counts from a sample. The expected counts from a null hypothesis are given in parentheses. Compute the χ2-test statistic, and use the χ2-distribution to find the p-value of the test.
Category | A | B | C | D |
Observed |
25(20) | 35(40) | 50(60) | 90(80) |
Round your answer for the chi-square statistic to two decimal
places, and your answer for the p-value to four decimal
places.
chi-square statistic = Enter your answer; chi-square
statistic
p-value = Enter your answer; p-value
Using R code we can have the results.
CODE:
obs <- c(25,35,50,90)
exp <- c(20,40,60,80)
#Value of the statistic
sum(((obs-exp)^2)/exp)
#P-value
pchisq(sum(((obs-exp)^2)/exp),3,lower.tail = F)
OUTPUT:
> obs <- c(25,35,50,90)
> exp <- c(20,40,60,80)
> #Value of the statistic
> sum(((obs-exp)^2)/exp)
[1] 4.791667
> #P-value
> pchisq(sum(((obs-exp)^2)/exp),3,lower.tail = F)
[1] 0.1877036
Chi-squar statistic = 4.791667.
P-value = 0.1877036.
Get Answers For Free
Most questions answered within 1 hours.