do.binom.test <- function(target, param) { x <- length(target[target=="o"]) n <- length(target) if (n > 0) { b <- binom.test(x, n) ret <- c(as.double(b$estimate)*100, b$conf.int[1:2]*100, x, n, b$p.value) } else { ret <- c(0, -1, 1, 0, 0, 1) } cat(param, ": ", x, "/", n, "=", ret[1], "% (", ret[2], "%-", ret[3], "%)\n", sep="") ret } do.prop.test <- function(param, x, n) { for (i in 1:(length(x)-1)) { for (j in (i+1):length(x)) { if (n[i] > 0 && n[j] > 0) { p = prop.test(c(x[i], x[j]), c(n[i], n[j])) if (p$p.value <= 0.05) { differ <- "○" } else { differ <- "×" } cat(param[i],"-",param[j],": ", differ, "; p=", p$p.value, "\n", sep="") } else { cat(param[i],"-",param[j],": 該当データ無し\n", sep="") } } } } par(mfrow=c(3,2)) title <- "[装備による操り成功率]" cat("\n", title, "\n", sep="") eqSuccessRate <- rep(0, times=length(equips)) eqlcl <- rep(-1, times=length(equips)) equcl <- rep(1, times=length(equips)) eqx <- rep(0, times=length(equips)) eqn <- rep(0, times=length(equips)) for (i in 1:length(equips)) { stat <- do.binom.test(result[pet==dst.pet & CoP==ac & equip==equips[i]], equips[i]) eqSuccessRate[i] <- stat[1] eqlcl[i] <- stat[2] equcl[i] <- stat[3] eqx[i] <- stat[4] eqn[i] <- stat[5] } if (imgout) png(file=filename1, width=300, height=200, pointsize=10) #plot(CHR, eqSuccessRate, xlim=range(c(CHR, max(CHR)+2)), ylim=range(c(eqlcl,equcl)), plot(CHR, eqSuccessRate, xlim=range(c(CHR, max(CHR)+2)), ylim=range(y.range), main=title, xlab="CHR", ylab="操り成功率[%]") arrows(CHR, equcl, CHR, eqlcl, length=.05, angle=90, code=3) text(CHR+2, eqSuccessRate, equips) if (imgout) dev.off() if (PROP.TEST==1) { do.prop.test(equips, eqx, eqn) } title <- "[装備による操り成功率]" subtitle <- "(再操りは除外)" cat("\n", title, subtitle, "\n", sep="") eqSuccessRate2 <- rep(0, times=length(equips)) eqlcl2 <- rep(0, times=length(equips)) equcl2 <- rep(0, times=length(equips)) eqx2 <- rep(0, times=length(equips)) eqn2 <- rep(0, times=length(equips)) for (i in 1:length(equips)) { stat <- do.binom.test(result[pet==dst.pet & CoP==ac & equip==equips[i] & recast==0], equips[i]) eqSuccessRate2[i] <- stat[1] eqlcl2[i] <- stat[2] equcl2[i] <- stat[3] eqx2[i] <- stat[4] eqn2[i] <- stat[5] } if (imgout) png(file=filename2, width=300, height=200, pointsize=10) plot(CHR, eqSuccessRate2, xlim=range(c(CHR, max(CHR)+2)), ylim=range(y.range), main=title, sub=subtitle, xlab="CHR", ylab="操り成功率[%]") arrows(CHR, equcl2, CHR, eqlcl2, length=.05, angle=90, code=3) text(CHR+2, eqSuccessRate2, equips) if (imgout) dev.off() if (PROP.TEST==1) { do.prop.test(equips, eqx2, eqn2) } title <- "[曜日による操り成功率]" cat("\n", title, "\n", sep="") dowSuccessRate <- rep(0, times=length(dows)) dowlcl <- rep(-1, times=length(dows)) dowucl <- rep(1, times=length(dows)) downum <- rep(0, times=length(dows)) dowx <- rep(0, times=length(dows)) down <- rep(0, times=length(dows)) for (i in 1:length(dows)) { stat <- do.binom.test(result[pet==dst.pet & CoP==ac & vdow==dows[i]], dows[i]) downum[i] <- i dowSuccessRate[i] <- stat[1] dowlcl[i] <- stat[2] dowucl[i] <- stat[3] dowx[i] <- stat[4] down[i] <- stat[5] } if (imgout) png(file=filename3, width=300, height=200, pointsize=10) plot(downum, dowSuccessRate, xlim=range(downum), ylim=range(y.range), xaxt="n", main=title, xlab="曜日", ylab="操り成功率[%]") arrows(downum, dowucl, downum, dowlcl, length=.05, angle=90, code=3) axis(1, at=1:length(dows), labels=dows) if (imgout) dev.off() if (PROP.TEST==1) { do.prop.test(dows, dowx, down) } title <- "[曜日による操り成功率]" subtitle <- "(再操りは除外)" cat("\n", title, subtitle, "\n", sep="") dowSuccessRate2 <- rep(0, times=length(dows)) dowlcl2 <- rep(0, times=length(dows)) dowucl2 <- rep(0, times=length(dows)) downum <- rep(0, times=length(dows)) dowx2 <- rep(0, times=length(dows)) down2 <- rep(0, times=length(dows)) for (i in 1:length(dows)) { stat <- do.binom.test(result[pet==dst.pet & CoP==ac & vdow==dows[i] & recast==0], dows[i]) downum[i] <- i dowSuccessRate2[i] <- stat[1] dowlcl2[i] <- stat[2] dowucl2[i] <- stat[3] dowx2[i] <- stat[4] down2[i] <- stat[5] } if (imgout) png(file=filename4, width=300, height=200, pointsize=10) plot(downum, dowSuccessRate2, xlim=range(downum), ylim=range(y.range), xaxt="n", main=title, sub=subtitle, xlab="曜日", ylab="操り成功率[%]") arrows(downum, dowucl2, downum, dowlcl2, length=.05, angle=90, code=3) axis(1, at=1:length(dows), labels=dows) if (imgout) dev.off() if (PROP.TEST==1) { do.prop.test(dows, dowx2, down2) } title <- "[月齢による操り成功率]" cat("\n", title, "\n", sep="") mnSuccessRate <- rep(0, times=length(moons)) mnlcl <- rep(-1, times=length(moons)) mnucl <- rep(1, times=length(moons)) moonnum <- rep(0, times=length(moons)) mnx <- rep(0, times=length(moons)) mnn <- rep(0, times=length(moons)) for (i in 1:length(moons)) { stat <- do.binom.test(result[pet==dst.pet & CoP==ac & vmoon==moons[i]], moons[i]) moonnum[i] <- i mnSuccessRate[i] <- stat[1] mnlcl[i] <- stat[2] mnucl[i] <- stat[3] mnx[i] <- stat[4] mnn[i] <- stat[5] } if (imgout) png(file=filename5, width=300, height=200, pointsize=10) plot(moonnum, mnSuccessRate, xlim=range(moonnum), ylim=range(y.range), xaxt="n", main=title, xlab="月齢", ylab="操り成功率[%]") arrows(moonnum, mnucl, moonnum, mnlcl, length=.05, angle=90, code=3) axis(1, at=1:length(moons), labels=moons) if (imgout) dev.off() if (PROP.TEST==1) { do.prop.test(moons, mnx, mnn) } title <- "[月齢による操り成功率]" subtitle <- "(再操りは除外)" cat("\n", title, subtitle, "\n", sep="") mnSuccessRate2 <- rep(0, times=length(moons)) mnlcl2 <- rep(0, times=length(moons)) mnucl2 <- rep(0, times=length(moons)) moonnum <- rep(0, times=length(moons)) mnx2 <- rep(0, times=length(moons)) mnn2 <- rep(0, times=length(moons)) for (i in 1:length(moons)) { stat <- do.binom.test(result[pet==dst.pet & CoP==ac & vmoon==moons[i] & recast==0], moons[i]) moonnum[i] <- i mnSuccessRate2[i] <- stat[1] mnlcl2[i] <- stat[2] mnucl2[i] <- stat[3] mnx2[i] <- stat[4] mnn2[i] <- stat[5] } if (imgout) png(file=filename6, width=300, height=200, pointsize=10) plot(moonnum, mnSuccessRate2, xlim=range(moonnum), ylim=range(y.range), xaxt="n", main=title, sub=subtitle, xlab="月齢", ylab="操り成功率[%]") arrows(moonnum, mnucl2, moonnum, mnlcl2, length=.05, angle=90, code=3) axis(1, at=1:length(moons), labels=moons) if (imgout) dev.off() if (PROP.TEST==1) { do.prop.test(moons, mnx2, mnn2) }