### B. Balgooyen ### 08/16/01 ### ### COMPARISON OF INCIDENCE RATES -- EXACT TEST (2-sided) ### ### This test appears in the text: FUNDAMENTALS OF BIOSTATISTICS By Bernard Rosner (pg. 686) ### ### ### Let P = true proportion of events in group 1. ### To test the hypothesis Ho: ID(1) = ID(2) (or equivalently, P=Po) ### H1: ID(1) not(=) ID(2) (or equivalently, P not(=) Po) ### Where: ### ID(1) = true incidence density in group 1 ### ID(2) = true incidence density in group 2 ### Po = t1/(t1+t2), Qo=1-Po a1 <- 5 # Let a1 = the observed number of events in group 1 a2 <- 2 # Let a2 = the observed number of events in group 2 t1 <- 85424 # let t1 = total event time in group 1 t2 <- 264579 # let t2 = total event time in group 2 Po <- t1/(t1 + t2) Qo <- 1-Po if (a1 < (a1+a2)*Po) low.limit <- 0 if (a1 < (a1+a2)*Po) up.limit <- a1 if (a1 >= (a1 + a2)*Po) low.limit <- a1 if (a1 >= (a1 + a2)*Po) up.limit <- a1+a2 sum.vector<-c() # Set sum.vector to empty set for (i in low.limit:up.limit){ one.sum <- choose(a1+a2,i)*Po^i*Qo^((a1+a2)-i) sum.vector <- c(sum.vector,one.sum) } binom.result <- sum(sum.vector) p.value <- 2*binom.result print(p.value) # The result for the 2-sided p-value