# Practicals 5 test.res<-chisq.test(c(10, 25, 18, 6), p=rep(1/4, 4)) # Chi-squared test for given probabilities # # data: c(10, 25, 18, 6) # X-squared = 14.559, df = 3, p-value = 0.002235 unclass(test.res) test.res$observed-test.res$expected # [1] -4.75 10.25 3.25 -8.75 (test.res$observed-test.res$expected)/test.res$expected # [1] -0.3220339 0.6949153 0.2203390 -0.5932203 chisq.test(c(125, 60, 50, 12), p=c(9/16, 3/16, 3/16, 1/16)) # Chi-squared test for given probabilities # # data: c(125, 60, 50, 12) # X-squared = 6.5025, df = 3, p-value = # 0.08956 pchisq(5.04, df=3, lower.tail=F) 1-pchisq(5.04, df=3) qchisq(0.05, df=3, lower.tail = F) qchisq(0.01, df=3, lower.tail = F) qchisq(0.05, df=8, lower.tail = F) qchisq(0.01, df=8, lower.tail = F) chisq.test(c(6,4)) # Chi-squared test for given probabilities # # data: c(6, 4) # X-squared = 0.4, df = 1, p-value = 0.5271 chisq.test(c(60,40)) # Chi-squared test for given probabilities # # data: c(60, 40) # X-squared = 4, df = 1, p-value = 0.0455 chisq.test(c(600,400)) # Chi-squared test for given probabilities # # data: c(600, 400) # X-squared = 40, df = 1, p-value = 2.54e-10 chisq.test(c(12,6,5,0), p=c(9/16,3/16,3/16,1/16))