I have aggregated yes/no data for the number of individuals with and without a specific characteristic in two groups across a large number of variables.
etc for multiple rows... I wish to compare homogeneity (i.e. are there equal proportions between groups 1 and 2 as represented by Yes_1 and No_1 and Yes_2 and No_2 respectively) between the two groups for each variable and would like to use the chi squared test. This would effectively be creating multiple 2x2 contingency tables, performing a chi square test on each and storing the output in a new column (like the empty p above). I can see that
will do the simple maths that I want for variable A, but I can't see how to apply them to multiple pieces of aggregated data like this nor how to save the calculated probability in column p. Advice appreciated (Stata/MP 13.0)
Variable | Yes_1 | No_1 | Yes_2 | No_2 | p |
A | 25 | 35 | 45 | 78 | |
B | 41 | 19 | 100 | 23 | |
C | 33 | 27 | 81 | 42 |
Code:
tabi 25 35 \ 45 78, chi2
Comment