I have an apparently very simple problem, but hours of google, discussion with a statistician who regularly uses Stata and searching this forum have not provided an answer...
I have the following dataset with 7 schools, as well as the number of male and female students:
Code:
input School Males Females 1 430 598 2 87 203 3 43 35 4 278 143 5 720 1347 6 388 613 7 702 610 end
Code:
tabi 430 598 \ 87 203 \ 43 35 \ 278 143 \ 720 1347 \ 388 613 \ 702 610, chi2
I have not been able to find a simple way of doing this. As a workaround, I expanded the dataset to one observation per subject, with a categorical variable indicating to which school the subject belongs, and a second binary variable coding gender. The data can then easily be analysed with "tab..., chi2", giving an identical result as the immediate command. However, this approach is quite tedious (there is probably a simpler way of doing this, but it cost me about 20 lines of code...), and I guess there must be some simpler way of telling Stata that the data are in contingency table format?
Thank you and best regards,
Patrick
0 Response to Pearson's chi square test when data are in contingency table format
Post a Comment