1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

JavaScript で母比率の差の検定

Posted at

JavaScript で母比率の差の検定を書く。
正規分布の実装は jStat の distribution.js を使う。

JavaScript
var propTest = function(Nc, Nt, Pc, Pt) {
	var p = (Nc*Pc + Nt*Pt)/(Nc + Nt);
	var z = Math.abs(Pc - Pt) / Math.sqrt(p * (1-p) * (1/Nc + 1/Nt));
	var pValue = jStat.normal.cdf(-z, 0, 1) * 2
	return(pValue);
}
var pValue = propTest(300, 200, 29/300, 9/200);
console.log(pValue);
結果
 0.032696640479626615

2群の母比率の差の検定 で計算した結果と同じになることを確認すること。

参考:比率の検定・独立性の検定

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?