Chi-squared for multiple groups

57 ビュー (過去 30 日間)
Eric
Eric 2021 年 1 月 14 日
回答済み: Jeff Miller 2021 年 1 月 14 日
Dear all
I have data on gender (male/female) for 4 groups that I would like to compare.
I found this previous post that shows how to compare 2 group (or proportions): Chi squared
Does anyone know how to do this?
Best,
Eric

回答 (2 件)

Jeff Miller
Jeff Miller 2021 年 1 月 14 日
The crosstab function will do this--it is not limited to 2x2 tables. Example:
% Make up example data for 200 participants, coding gender as 1/2 and group as 1/2/3/4:
n = 200;
Gender = randi(2,n,1);
Group = randi(4,n,1);
% run the chi-square test:
[tbl,chi2stat,pval] = crosstab(Gender,Group)
% output looks like this:
tbl =
34 24 22 26
21 30 23 20
chi2stat =
3.838
pval =
0.27949
Table shows you the number in each of the 2x4 combinations of group and gender.
chi2stat is the value of the chi-square statistic, here with 3 degrees of freedom. The null hypothesis being tested is that the proportions of males vs females are the same for all four groups. Or, equivalently, that the proportional distribution across the 4 groups is the same for males vs females.
The null would be rejected if pval is small, typically less than 0.05.

Star Strider
Star Strider 2021 年 1 月 14 日
Consider Perform One-Way ANOVA instead.

カテゴリ

Help Center および File ExchangeHypothesis Tests についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by