Compare two proportions (Chi-square)
[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
Citation pour cette source
laurie (2026). Compare two proportions (Chi-square) (https://fr.mathworks.com/matlabcentral/fileexchange/45966-compare-two-proportions-chi-square), MATLAB Central File Exchange. Extrait(e) le .
Compatibilité avec les versions de MATLAB
Plateformes compatibles
Windows macOS LinuxCatégories
- AI and Statistics > Statistics and Machine Learning Toolbox > Probability Distributions and Hypothesis Tests > Hypothesis Tests >
Tags
Découvrir Live Editor
Créez des scripts avec du code, des résultats et du texte formaté dans un même document exécutable.
| Version | Publié le | Notes de version | |
|---|---|---|---|
| 1.0.0.0 |
