DATA SET1; /* This program is stored as comodds.sas */ INPUT F1 S1 F1= TREATMENT FAILURES /***************************************** S2= CONTROL SUCCESSES This program uses PROC IML in SAS to F2= CONTROL FAILURES; compute three estimates of a common CARDS; odds ratio for a set of 2x2 tables. It also evaluates seven test statistics to test homogeneity of odds ratio across tables. Some of these tests may produce unreliable p-values in some situations. The data file should contain one line for each 2x2 table with the counts arranged in the order shown below. The example includes data from eighteen 2x2 tables. Odds ratios are F2 S2; LABEL S1= TREATMENT SUCCESSES 1 0 3 5 1 0 2 4 . . . . . . . . run; PROC PRINT DATA= SET1; PROC IML; START CC; (S1)(F2)/(F1)(S2), the odds of success in the treatment /* Enter the observed counts group (group 1) divided by the odds of success in the other group. ******************************* USE SET1; READ ALL INTO */ X; 1 K=NROW(X); 2 /*----- COMPUTE MH ESTIMATOR --------*/ K1=K+1; F1=X[ ,1]; /* Treatment group failures*/ R1=J(K,1); S1=X[ ,2]; /* Treatment group succeses*/ R2=R1; F2=X[ ,3]; /* Control group failures */ S2=X[ ,4]; /* Control group successes */ N1=S1+F1; R1[I4,1]= (S1[I4,1]*F2[I4,1])/N[I4,1]; R2[I4,1]= (S2[I4,1]*F1[I4,1])/N[I4,1]; N2=S2+F2; END; N=N1+N2; MH=SUM(R1)/SUM(R2); MV=S1+S2; PRINT,,," DO I4=1 TO K; THE OBSERVED COUNTS", X; /*---STD. DEVIATION FOR MH ESTIMATOR--*/ /* Terminate the program if either the L1=J(K,1); control group or the treatment group L2=L1; has all successes in every table or L11=L1; all failures in every table */ L22=L1; L3=L1; CHECK=SUM(S1)*SUM(S2)*SUM(F1)*SUM(F2); IF (CHECK=0) THEN DO; DO I5=1 to k; PRINT,,,"EITHER ALL SUCCESSES OR ALL L1[I5,1]=((S1[I5,1]+F2[I5,1])*(S1[I5,1] FAILURES FOR AT LEAST ONE GROUP"; *F2[I5,1]))/(N[I5,1]##2); STOP; L11[I5,1]=(S1[I5,1]*F2[I5,1])/N[I5,1]; END; 3 4 /*--COMPUTE MLE OF COMMON ODDS RATIO--*/ L2[I5,1]=((S1[I5,1]+F2[I5,1]) *(S2[I5,1]*F1[I5,1])+(S2[I5,1]+F1[I5,1]) /* USE MH ESTIMATOR FOR THE STARTING VALUE */ *(S1[I5,1]*F2[I5,1]))/(N[I5,1]##2); L22[I5,1]= (S2[I5,1]*F1[I5,1])/N[I5,1]; BA=LOG(MH); BP=.5*(LOG((S1+.5)/(N1-S1+.5))+ L3[I5,1]=((S2[I5,1]+F1[I5,1])*(S2[I5,1] LOG((S2+.5)/(N2-S2+.5))+LOG(MH)); *F1[I5,1]))/(N[I5,1]##2); B=BP//BA; end; BT=B`; L7=SUM(L1)/(2*(SUM(L11)##2)); /* L8=SUM(L2)/(2*SUM(L11)*SUM(L22)); USE THE NEWTON-RAPHSON ALGORITHM TO GET THE MLE */ L9=SUM(L3)/(2*(SUM(L22)##2)); MAXIT=50; SLMH=SQRT(L7+L8+L9); HALVING=16; SMH=MH*SLMH; CONVERGE=.0001; MHL=EXP(LOG(MH)-(1.96)*SLMH); RUN NEWTON; MHU=EXP(LOG(MH)+(1.96)*SLMH); RUN DERIV; HI=INV(H); 5 6 BP=B[1:K,1]; BA=B[K1,1]; run TEST3; PI=EXP(BP)/(KO+EXP(BP)); PVAL3=1-PROBCHI(BD,DF); PRINT ' COR=EXP(B[K1,1]); Breslow-Day test for a common odds ratio:' BD PVAL3; SCOR=COR*SQRT(HI[K1,K1]); MLEL=exp(log(cor)-(1.96)*scor/cor); MLEU= exp(log(cor)+(1.96)*scor/cor); run test4; run ccorprg; PVAL4=1-PROBCHI(MBD,DF); PRINT 'Modified Breslow-Day test for RUN TEST1; a common odds ratio:' MBD PVAL4; DF=K-1; PVAL1=1-PROBCHI(LR,DF); RUN TEST6; PRINT ' PVAL5=1-PROBCHI(CS,DF); Likelihood ratio test for a common odds ratio:' LR PVAL1; PVAL6=1-PROBNORM(T4); PRINT ' run TEST2; Conditional score test for a common odds ratio:' CS PVAL5; PVAL2=1-PROBCHI(P,DF); PRINT ' PRINT ' Pearson chi-squared test for Liang & Self T4 test for a common odds ratio:' T4 PVAL6; a common odds ratio:' P PVAL2; 7 8 /*--MODIFIED NEWTON-RAPHSON ALGORITHM-------*/ /* USER MUST SUPPLY INITIAL VALUES FOR RUN TEST7; PARAMETERS IN B, AND THE FUN AND DERIV PVAL7=1-PROBNORM(T5); PRINT ' FUNCTIONS. FUN EVALUATES THE FUNCTION TO Liang & Self T5 test for BE MAXIMIZED. a common odds ratio:' T5 PVAL7; SECOND PARTIAL DERIVATIVES. FIRST PARTIAL PRINT,,,, "ESTIMATES OF THE COMMON ODDS RATIO "; PRINT," MANTEL-HAENZEL ESTIMATE " MH; PRINT " STANDARD ERROR FOR MH ESTIMATE " SMH; PRINT " DERIV EVALUATES FIRST AND 95% CONFIDENCE INTERVAL " MHL MHU; PRINT," MAXIMUM LIKELIHOOD ESTIMATE " COR; PRINT " STANDARD ERROR FOR MLE " SCOR; PRINT " 95% CONFIDENCE INTERVAL " MLEL MLEU; PRINT,"COND. MAXIMUM LIKELIHOOD ESTIMATE " COR; PRINT " STANDARD ERROR FOR COND. MLE " SCOR; PRINT " 95% CONFIDENCE INTERVAL " MLEL MLEU; DERIVATIVES ARE PUT IN Q. THE NEGETIVE OF THE MATRIX OF SECOND PARTIAL DERIVATIVES ARE PUT INTO H */ START NEWTON; CHECK=1; DO ITER =1 TO MAXIT WHILE (INT(CHECK/CONVERGE)); RUN FUN; FOLD=F; BT=B`; STEP=ITER-1; *PRINT,STEP BT F; FINISH; BOLD=B; B2=BOLD; RUN DERIV; 9 HI=INV(H); 10 /*--USER SUPPLIED FUNCTION EVALUATION--*/ B=BOLD + HI*Q; RUN FUN; DO HITER= 1 TO HALVING WHILE(FOLD-F >= 0); B=B2+2.*((.5)##HITER)*HI*Q; START FUN; KO = J(K,1); BP=B[1:k,1]; BT=B`; BA=B[k1,1]; *PRINT STEP HITER BT F; RUN FUN; G1=LGAMMA(N1+KO)+LGAMMA(N2+KO); END; G2=LGAMMA(S1+KO)+LGAMMA(S2+KO)+ LGAMMA(N1-S1+KO)+LGAMMA(N2-S2+KO); IF(HITER=HALVING) THEN DO; G5=(S1+S2)`*BP; PRINT,,,"DID NOT CONVERGE AFTER G6=(SUM (N2-S2))*BA; USING ALL HALVING STEPS"; G7=N1`*LOG(KO+EXP(BP)); STOP; G8=N2`*LOG(EXP(BA)*KO+EXP(BP)); END; CHECK=((BOLD-B)`*(BOLD-B))/(B`*B); F=SUM(G1-G2)+G5+G6-G7-G8; end; FINISH; FINISH; 11 12 /*--USER SUPPLIED DERIVATIVE EVALUATION---- H2= EXP(BA)*(N2#EXP(BP))/ FIRST PARTIAL DERIVATIVES ARE RETURNED (((EXP(BA)*KO)+EXP(BP))##2); IN Q AND THE NEGETIVE OF THE 2ND PARTIAL DERIVATIVES ARE RETURNED IN THE MATRIX H. H3= -EXP(BA)*SUM((N2#EXP(BP)) -------------------------------------------*/ START DERIV; /(((EXP(BA)*KO)+EXP(BP))##2)); H4= (H2//H3)`; KO = J(K,1); H5= H1||H2; BP= B[1:K,1]; H = H5//H4; BA= B[K1,1]; H = -H; Q1=(S1+S2)-(N1#EXP(BP))/(KO+EXP(BP))- FINISH; (N2#EXP(BP))/((EXP(BA)*KO)+EXP(BP)); Q2=SUM(N2-S2)-EXP(BA)* /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ (SUM(N2/((EXP(BA)*KO)+EXP(BP)))); * @ ************************************ @ Q=Q1//Q2; H1=-((N1#EXP(BP))/((KO+EXP(BP))##2))(EXP(BA)*(N2#EXP(BP))/ ((((EXP(BA)*KO)+EXP(BP))##2))); * @ * * @ * @ * Program to find out the values * @ * @ * of the Seven(7) Test Statistics * @ * @ * * @ * @ ************************************ @ * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ H1=DIAG(H1); 13 14 IF (S2[I,1]>0) THEN /***************************************** * LR=LR+(S2[I,1])*(LOG(BL[I,1]) * -LOG(S2[I,1])); *(1) Compute the value of the likelihood * * Ratio Test Statistic ( L-R TEST ) * * IF (F2[I,1]>0) THEN * LR=LR+(F2[I,1])*(LOG(N2[I,1] ******************************************/ -BL[I,1])-LOG(F2[I,1])); END; START TEST1; LR=-2*LR; BI=N1#PI; FINISH; BL=((N2#BI)/(BI+COR*(N1-BI))); /****************************************** LR=0; * * DO I=1 TO K; * (2) Compute the value of the * IF (S1[I,1]>0) THEN * LR=LR+(S1[I,1])*(LOG(BI[I,1]) Pearson Chi-square test statistic * -LOG(S1[I,1])); * * *******************************************/ IF (F1[I,1]>0) THEN START TEST2; LR=LR+(F1[I,1])*(LOG(N1[I,1] P=SUM((N1#((S1-BI)##2))/(BI#(N1-BI)))+ -BI[I,1])-LOG(F1[I,1])); SUM((N2#((S2-BL)##2))/(BL#(N2-BL))); FINISH; 15 16 /* Z is a solution of the quadratic equation at the Mantel-Hanszel estimator */ /********************************** * * U=(S1-Z); * (3) Compute the value of the * W=((KO/Z)+(KO/(N1-Z))+(KO/(MV-Z)) * * Breslow-Day test statistic * +(KO/(N2-MV+Z))); * ***********************************/ v=(1/w); BD= sum((U##2)/V); START TEST3; FINISH; KO=J(K,1); /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~* Z1= N2-(((1-MH)*KO)#MV)+((MH*KO)#N1); Z2= * SQRT(((N2-(((1-MH)*KO)#MV)+ ((MH*KO)#N1))##2)+(((4*(1-MH)*MH) * * (4) Modified Breslow and Day statistic * * * *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ *KO) #N1)#MV); START TEST4; Z3= 2*(1-MH)*KO; Z=(-Z1+Z2)/Z3; CT=((SUM(S1-Z))##2)/SUM(v); MBD=BD-CT; FINISH; 17 18 DC = TC; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~* * * * (5) CONDITIONAL SCORE TEST * * (6) LIANG AND SELF'S T4 STATISTIC * * * *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ START TEST6; EC1=J(K,1); EC2=EC1; EC3=EC1; EC4=EC1; VC=EC1; DO I1 =1 TO K; M=S1[I1,1]+S2[I1,1]; K2=N1[I1,1]; K3=M-N2[I1,1]; IF (K3<0) THEN K3=0; IF (M<K2) THEN K2=M; D1=K3*DC; D2=K3*D1; D3=K3*D2; D4=K3*D3; DO I2 = K3+1 TO K2; TC = TC*(N1[I1,1]-I2+1)*(M-I2+1)/ (I2*(N2[I1,1]-M+I2)); TC=TC*CCOR; DC=DC+TC; D1=D1+I2*TC; D2=D2+(I2**2)*TC; D3=D3+(I2**3)*TC; D4=D4+(I2**4)*TC; END; EC1[I1,1]=D1/DC; TC=EXP(LGAMMA(N1[I1,1]+1)-LGAMMA(K3+1) -LGAMMA(N1[I1,1]-K3+1)+ LGAMMA(N2[I1,1]+1)-LGAMMA(M-K3+1) -LGAMMA(N2[I1,1]-M+K3+1) +log(CCOR)*K3); 19 EC2[I1,1]=D2/DC; EC3[I1,1]=D3/DC; EC4[I1,1]=D4/DC; VC[I1,1]=EC2[I1,1]-(EC1[I1,1]##2); END; 20 V1=(CCOR##2)/SUM(VC); B1=SUM((EC3-3*EC2#EC1+2*(EC1##3))/(CCOR*VC)); START TEST7; V2=SUM((EC4-4*EC1#EC3+6*(EC1##2) S11=SUM((Q11##2)-VC); #EC2-3*(EC1##4))/(VC##2)); I11=SUM(EC4-4*EC3#EC1+6*EC2#(EC1##2) Q11=(S1-EC1); -3*(EC1##4)-2*VC#(EC2-(EC1##2))+(VC##2)); CS= SUM((Q11##2)/VC); I12=SUM(EC3-3*EC2#EC1+2*(EC1##3)); k11=0; I22=SUM(VC); do I1=1 TO K; T5=S11/SQRT(I11-((I12##2)/I22)); if (S1[I1,1]+S2[I1,1] > 0) & FINISH; (S1[I1,1]+S2[I1,1]<N[I1,1]) THEN K11=K11+1; /*----------------------------------- END; Subroutine for evaluating the conditional likelihood T4=(CS-K11)/SQRT((V2-K11)-(B1##2)*V1); ------------------------------------*/ FINISH; start condexp; E=0; /*############################### * * do I1=1 to k; * (7) T5 TEST STATISTIC * * M=S1[I1,1]+S2[I1,1]; * K2=N1[I1,1]; ################################*/ 21 K3=M-N2[I1,1]; IF(K3<0) THEN K3=0; 22 /*---------------------------------------- IF( M < K2 ) THEN K2=M; C1=EXP(LGAMMA(N1[I1,1]+1)LGAMMA(K3+1)-LGAMMA(N1[I1,1]-K3+1)); C2=EXP(LGAMMA(N2[I1,1]+1)-LGAMMA(M-K3+1) -LGAMMA(N2[I1,1]-M+K3+1)); C3=PHI##K3; Bisection routine to compute conditional mle for the common odds ratio( CCOR ) ----------------------------------------*/ start ccorprg; PHI=MHL; CALL CONDEXP; E2=C1*C2*C3; E1=E2*K3; EL=E; PHI=MHU; IF( K2 > K3 ) THEN DO; DO I2= K3+1 TO K2; C1=C1*(N1[I1,1]-I2+1)/I2; C2=C2*(M-I2+1)/(N2[I1,1]-M+I2); C3=C3*PHI; E1=E1+(I2*C1*C2*C3); E2=E2+(C1*C2*C3); END; END; E=E+(E1/E2); END; E=E-SUM(S1); FINISH; 23 CALL CONDEXP; EU=E; PHI=MH; CALL CONDEXP; EM=E; PHIU=MHU; PHIL=MHL; IF( EL >0 & EM<0) THEN DO; PHIU=MH; EU=EM; END; 24 IF( EM > 0 & EU < 0 ) THEN DO; PHIL=MH; EL=EM; END; IF( EL < 0 & E > 0) THEN DO; PHIU=PHI; EU=E; END; IF( EL < 0 & EM > 0 ) THEN DO; PHIU=MH; EU=EM; END; IF( EL < 0 & E < 0 ) THEN DO; PHIL=PHI; EL=E; END; IF( EM < 0 & EU > 0 ) THEN DO; PHIL=MH; EL=EM; END; IF( EL > 0 & E > 0 ) THEN DO; PHIL=PHI; EL=E; END; /* COMPUTE THE NUMBER OF ITERATIONS FOR THE BISECTION SEARCH */ IF( EL > 0 & E < 0 ) THEN DO; PHIU=PHI; EU=E; END; END; NIT=LOG10((PHIU-PHIL)*1000000)/LOG10(2); NIT=INT(NIT+1); IF( NIT > 50 ) THEN NIT=50; DO J1=1 TO NIT; PHI=( PHIU+PHIL )/2; CALL CONDEXP; CCOR=(PHIL+PHIU)/2; FINISH; RUN CC; 25 26 THE OBSERVED COUNTS LR Likelihood ratio test for a X common odds ratio: 1 0 3 5 1 0 2 4 1 0 1 4 0 1 1 5 1 0 4 1 1 0 4 5 1 0 5 3 1 0 4 4 1 0 3 2 0 1 8 1 1 0 5 1 1 0 8 1 1 0 5 3 1 0 4 1 1 0 4 2 1 0 7 1 0 1 4 2 1 0 5 3 27 16.308133 PVAL1 0.5021057 P Pearson chi-squared test for a common odds ratio: 24.769313 PVAL2 0.0999935 BD Breslow-Day test for a common odds ratio: 21.421637 PVAL3 0.207996 28 T5 MBD Liang & Self T5 test for a Modified Breslow-Day test for a common odds ratio: 21.324071 common odds ratio: 0.0104599 PVAL7 PVAL4 0.4958272 0.212129 CS Conditional score test for a common odds ratio: 22.043525 ESTIMATES OF THE COMMON ODDS RATIO PVAL5 0.183051 MH MANTEL-HAENZEL ESTIMATE 0.3001888 STANDARD ERROR FOR MH ESTIMATE 0.2077417 T4 Liang & Self T4 test for a common odds ratio: 0.4307947 SMH PVAL6 0.3333088 MHL 95% CONFIDENCE INTERVAL 0.07732 MHU 1.16538 29 30 COR MAXIMUM LIKELIHOOD ESTIMATE 0.2387576 # This code computes values of the SCOR STANDARD ERROR FOR MLE 0.1752867 # Mantel-Haenszel estimator of a # common odds ratio and evaluates # the Breslow-Day and Liang-Self T4 # tests for homogeneity of odds ratios 95% CONFIDENCE INTERVAL MLEL MLEU 0.05663 1.00667 # It is stored in the file comodds.spl #------------------------------------------# Evaluation of the conditional log- COR CONDITIONAL MLE 0.2387576 SCOR STANDARD ERROR FOR CONDITIONAL MLE 95% CONFIDENCE INTERVAL 0.1752867 MLEL MLEU 0.05663 1.00667 31 # likelihood uses the following function # to calculte the number of ways of # choosing k items out of n items #------------------------------------------n.pick.k<-function(n, k) dbinom(k,n,0.5)*2^n 32 #-----------------------------------------# This function evaluates the conditional # log-likelihood function conditioning on # the marginal counts and assuming a common # odds ratio for all 2x2 tables. #-----------------------------------------cond.loglik<-function(alpha, s1, f1, s, f.tot, n1, j.start, j.end) { denom <- c() num <- n.pick.k(s, s1)* n.pick.k(f.tot, f1) * alpha^s1 for(kk in 1:k) { j <- j.start[kk]:j.end[kk] denom[kk] <- sum(n.pick.k(s[kk], j) * n.pick.k(f.tot[kk], n1[kk] - j) * alpha^j) } sum(log(num/denom)) } 33 # Compute the MH estimator comodds<-function(X,pout=as.logical(c("T"))) { f1 <- X[, 1] s1 <- X[, 2] f2 <- X[, 3] s2 <- X[, 4] k <- dim(X)[1] k1 <- k + 1 n1 <- s1 + f1 n2 <- s2 + f2 n <- n1 + n2 s <- s1 + s2 f.tot <- f1 + f2 34 # Compute the Breslow-Day test mh <- sum((s1 * f2)/n)/sum((s2 * f1)/n) # Compute std and a #--------------------------------------------# MAIN FUNCTION. # For k 2x2 independent tables, # (1) Calculate the Mantel-Haenszel estimator # of common odds ratio and an approximate # 95% confidence interval. # (2) Use the Breslow-Day test to check for # a common odds ratio. # (3) Use Liang-Self T4 test to check for a # common odds ratio. #--------------------------------------------- 95% CI for common odds s1pf2 <- s1 + f2 s2pf1 <- s2 + f1 s1tf2 <- s1 * f2 s2tf1 <- s2 * f1 n.sqr <- n^2 L1 <- (s1pf2 * s1tf2)/n.sqr L11 <- s1tf2/n L2 <- (s1pf2 * s2tf1 + s2pf1 * s1tf2)/n.sqr L22 <- s2tf1/n L3 <- (s2pf1 * s2tf1)/n.sqr sum.L11<-sum(L11) sum.L22<-sum(L22) L7 <- sum(L1)/(2 * sum.L11^2) L8 <- sum(L2)/(2 * sum.L11 * sum.L22) L9 <- sum(L3)/(2 * sum.L22^2) slmh <- sqrt(L7 + L8 + L9) smh <-mh*slmh mhl <- exp(log(mh) - 1.96 * slmh) mhu <- exp(log(mh) + 1.96 * slmh) 35 z1 <- n2 - (1 - mh) * s + mh * n1 z2 <- sqrt(z1^2 + 4 * (1 - mh) * mh * n1 * s) z <- (z2 - z1)/(2 * (1 - mh)) w <- 1/z + 1/(n1 - z) + 1/(s - z) + 1/(n2 - s + z) BD <- sum(w * (s1 - z)^2) df <- k - 1 pvalue.BD <- 1 - pchisq(BD, df) # Compute Liang's T4 test; j.start <- s1 - f2 j.start[j.start < 0] <- 0 j.end <- s temp<-s > n1 j.end[temp] <- n1[temp] lower<-exp(log(mh) - 3* slmh) upper<-exp(log(mh) + 3* slmh) obj <- optimize(cond.loglik, lower = lower, upper = upper, max = T, s1 = s1, f1 = f1, s = s, f.tot = f.tot, n1 = n1, j.start = j.start, j.end = j.end) 36 # Conditional mle of the common odds ratio v.cond <- EC2 - EC1^2 cs <- sum((s1 - EC1)^2/v.cond) alpha.c <- obj$maximum k.star <- sum((s > 0) * (f.tot > 0)) EC1 <- c() V <- alpha.c^2/sum(v.cond) EC2 <- c() B <- sum((EC3 - 3 * EC2 * EC1 + 2 * EC1^3)/ EC3 <- c() v.cond)/alpha.c EC4 <- c() var.cs.cond <- sum((EC4 - 4 * EC1 * EC3 + 6 * for(kk in 1:k) { EC1^2 * EC2 - 3 * EC1^4)/v.cond^2) j <- j.start[kk]:j.end[kk] T4 <- (cs - k.star)/sqrt(var.cs.cond - temp <- n.pick.k(s[kk], j) * k.star - B^2 * V) n.pick.k(f.tot[kk], n1[kk] pvalue.T4 <- (1 - pnorm(abs(T4))) - j) * alpha.c^j den <- sum(temp) list(mh.estimate = mh, mh.std=smh, EC1[kk] <- sum(j * temp)/den conditional.estimate=alpha.c, ci95 = c(mhl, mhu), EC2[kk] <- sum(j^2 * temp)/den Breslow.Day.test = c(BD.statistic= BD, EC3[kk] <- sum(j^3 * temp)/den df = df, BD.pvalue= pvalue.BD), EC4[kk] <- sum(j^4 * temp)/den Liang.Self.T4test = c(T4.statistic = T4, } T4.pvalue = pvalue.T4)) 37 #Print out the results 38 #-------------------------------------- if(pout) { cat("***Mantel-Haenszel estimate \n of the common odds ratio: ", signif(mh,digits=6), "\n \n") cat("***Standard error of the \n Mantael-Haenszel estimator: ", signif(smh,digits=6), "\n \n") cat("*** 95% confidence interval for \n the common odds ratio:\n") cat(" (", signif(mhl,digits=6), " ", signif(mhu,digits=6), ")\n \n") cat("*** Breslow-Day test for a \n common odds ratio: \n") cat("test statistic = ", signif(BD,digits=6), "\n", " df = ", signif(df,digits=6), "\n", "p-value = ", signif(pvalue.BD,digits=6), "\n \n") cat("***Conditional m.l.e. of the \n common odds ratio: ", signif(alpha.c,digits=6), "\n \n") cat("*** Liang-Self T4 test for \n common odds ratio: \n") cat("test statistic = ", signif(T4,digits=6), "\n", "p-value = ", signif(pvalue.T4,digits=6), "\n") }} 39 # Enter the data. # corresponds to one row in data Each 2x2 table # matrix. # failures for treatment 1 and the # second column contains the successes # for treatment 1. # contains failures for treatment 2 # and the fourth column contains # successes for treatment 2. The first column contains The third column #-------------------------------------X<-matrix(c(1, 0, 3, 5, 1, 0, 2, 4, 1, 0, 1, 4, . . . . . . . . . . . . 0, 1, 4, 2, 1, 0, 5, 3), ncol=4, byrow=T) obj<-comodds(X) 40 ***Mantel-Haenszel estimate of the common odds ratio: 0.300189 ***Standard error of the Mantael-Haenszel estimator: 0.207742 *** 95% confidence interval for the common odds ratio: ( 0.0773252 1.16538 ) *** Breslow-Day test for a common odds ratio: test statistic = df = p-value = 21.4216 17 0.207996 ***Conditional m.l.e. of the common odds ratio: 0.284776 *** Liang-Self T4 test for common odds ratio: test statistic = p-value = 0.430778 0.333315 41