Wc.stat<-function(Y0,N0,Y1,N1,YC,NC,S2) { # Hoel-Yanagawa conditional two-sample test # Y0 (Y1) = number of successes in the concurrent control (treatment) # groups # N0 (N1) = number of trials in the concurrent control (treatment) # groups # YC (NC) = number of successes (trials) in the histor. control data # S2 = variance in historical control proportions # mu.C <- YC/NC phi.C <- (S2 - mu.C*(1-mu.C)/NC) / (mu.C*(1-mu.C) - S2) a.C <- mu.C/phi.C b.C <- (1-mu.C)/phi.C N.plus <- N0 + N1 temp <- N0 + a.C + b.C T.C <- (temp*Y1 - N1*(Y0 + a.C)) / (N1+temp) p.0 <- (Y0+a.C)/temp se.TC <- sqrt(temp/(temp+1)*p.0*(1-p.0)*(N1 - N1^2/(N1+temp))) W.C <- T.C/se.TC data.frame(ac=a.C,bc=b.C,muC=mu.C,phiC=phi.C,Tc=T.C,se.Tc=se.TC, Wc=W.C,pvalue=1-pnorm(W.C)) }