# note: "pooledChi.r" script depends on the package CompQuadForm # install it by executing from R: install.packages("CompQuadForm") source("pooledZ.r") source("pooledChi.r") source("conditionalZ.r") # vector of sample sizes starting with the shared control group (n0) n <- c(500, 100, 300, 250, 200, 400) # vector of p-values p <- c(0.07, 0.04, 0.8, 0.095, 0.075) # vector of effect signs; note you can multiply it by -1 and get the same results effect.signs <- c(1, 1, -1, 1, 1) # combined p-value for the Z method pz <- pooled.Z(n, p, effect.signs) # combined p-value for the chi-square method pchi <- pooled.Chi(n, p) # adjust the first p-value (0.07) given the second one (0.04) pcond <- conditional.Z(n[1:3], p[1:2], effect.signs[1:2]) cat(pz, pchi, pcond, "\n")