#Biostatistics 410 #CHI-SQUARE TEST FOR GOODNESS OF FIT #ZAR EXAMPLE 22.1 ZAR=read.table("ZarEX22.1R.txt") ZAR attach(ZAR) chisq.test(observed,p=expected,rescale.p=TRUE) #WITH YATES CORRECTION: chisq.test(observed,p=expected,rescale.p=TRUE, correct=TRUE) #NOTE THAT THIS APPARENTLY DOESN'T WORK IN R FOR NON 2x2 TABLES #SO CALCULATING BY HAND: O=observed E=expected df=1 YatesCHISQ=sum(((abs(O-E)-0.5)^2)/E) YatesCHISQ YatesProb=1-pchisq(YatesCHISQ,df) YatesProb