#Biostatistics 450 #RXC CONTINGENCY TEST #ZAR EXAMPLE 23.1 #DATA KEYED INTO MATRIX: X=matrix(c(32,43,16,9,55,65,64,16),nrow=2,byrow=T) X chisq.test(X) #HAND CALCULATION OF G TEST: O=matrix(chisq.test(X)$observed) O E=matrix(chisq.test(X)$expected) E #G STATISTIC: G=2*sum(O*log(O/E)) G #CRITICAL VALUE: alpha=0.05 k=4 g=0 df=k-g-1 C=qchisq(1-alpha,df) C #PROBABILITY: P=(1-pchisq(G,df)) P #DATA FROM A (DIFFERENT) ORIGINAL DATASET IN R FORMAT: ROS=read.table("RosnerTA3.11.txt") ROS attach(ROS) #CREATING CONTINGENCY TABLE: T=table(Antibo,Age) T chisq.test(T)