Compare two proportions (Chi-square)

版本 1.0.0.0 (1.7 KB) 作者: laurie
A simple Chi-square test to compare two proportions.
2.3K 次下载
更新时间 2014/3/20

查看许可证

[h,p, chi2stat,df] = prop_test(X , N, correct)
A simple Chi-square test to compare two proportions
It is a 2 sided test with alpha=0.05

Input:

* X = vector with number of success for each sample (e.g. [20 22])
* N = vector of total counts for each sample (e.g. [48 29])
* correct = true/false : Yates continuity correction for small samples?

Output:

* h = hypothesis (H1/H0)
* p = p value
* chi2stat= Chi-square value
* df = degrees of freedom (always equal to 1: 2 samples)

Needs chi2cdf from the Statistics toolbox
Inspired by prop.test() in "R" but much more basic

Example: [h,p,chi]=prop_test([20 22],[48 29], true)
The above example tests if 20/48 differs from 22/29 using Yate's correction

引用格式

laurie (2024). Compare two proportions (Chi-square) (https://www.mathworks.com/matlabcentral/fileexchange/45966-compare-two-proportions-chi-square), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2009b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Hypothesis Tests 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.0.0