I have 3 data vectors representing the gender (0=male, 1=female) of 3 groups A, B, C.
for example
A = [0 0 0 0 1 1 1 1 0 0];
B = [1 1 1 1 1 1 1 0];
C = [1 0 0 1 0 1 1 0 1 1 1 1 1];
and relative number of male and female
n_maleA =6;
n_femaleA =4;
n_maleB = 1;
n_femaleB = 7;
n_maleC = 4;
n_femaleC = 9;
I would like to know if there are significant differences in gender between the 3 groups. To do this I read that is possible to use
[tbl,chi2stat,pval] = crosstab(x1,x2)
How can I use this with more than 2 groups of data and with data that have different length? Is there any other way to perform the chi-squared test in MATLAB that suits with my case?
Thanks in advance
It sounds like you want to test whether the proportion of males/females differs across groups. One way to do this would be to use a logistic regression model with male/female as the response variable and the group membership as a categorical predictor. Then look at the chi-square test for the model as a whole vs. a constant model.