比率の差の信頼区間計算機
- p 1 、p 2 : サンプル 1 の割合、サンプル 2 の割合
- z: 信頼水準に基づく z 臨界値
- n 1 、n 2 : サンプルサイズ 1、サンプルサイズ 2
95 % CI = [ 0.0236 , 0.2964 ]
function calc() {
//get input values var n1 = +document.getElementById('n1').value; var p1 = +document.getElementById('p1').value; var n2 = +document.getElementById('n2').value; var p2 = +document.getElementById('p2').value; var conf = +document.getElementById('conf').value;
var confUse = conf - (-(1-conf)/2); var confOut = conf*100;
//calculate stuff var meanDiff = p1-p2; var z = Math.abs(jStat.normal.inv(confUse, 0, 1)); var se = Math.sqrt(p1*(1-p1)/n1 - (-1*(p2*(1-p2)/n2)));
var low = meanDiff - (z*se); var high = meanDiff - (-1*z*se);
//output results document.getElementById('confOut').innerHTML = confOut; document.getElementById('confOut2').innerHTML = confOut; document.getElementById('low').innerHTML = low.toFixed(4); document.getElementById('low2').innerHTML = low.toFixed(4); document.getElementById('high').innerHTML = high.toFixed(4); document.getElementById('high2').innerHTML = high.toFixed(4); }