Herv� <[email protected]> wants to see if a categorical variable is the
same in a subpopulation as in the population, I think. Jeff Pitblado
gives a solution for comparing two categorical variables, not subject
to that restriction, by reshaping (though from Herv�'s post, I think
he made x1 and x2 from a dataset containing only x). If my
interpretation is correct, I think Herv� might actually prefer a Chi^2
goodness-of-fit test (-findit chi2fit-).
OTOH, if the total sample is not the population, then a test of
equality of proportions in the whole sample (samp==1 | samp==0) and in
a subsample defined by samp==1 is given by a Chi^2 test of
independence of x tabulated versus samp:
. tab x samp, chi2
No variable creation or rehaping, required, I think, for Herv�'s data.
On 4/11/06, Jeff Pitblado, StataCorp LP <[email protected]> wrote:
> Herve STOLOWY <[email protected]> has two categorical variables and wants to
> compare the proportions of each category between them:
>
> > the original variable is the same but are applied to two different
> > populations, the total sample and a restricted sample. I created two
> > different variables. With -tabulate-, I get easily the frequencies of both
> > variables).
> >
>
> I'll assume you have two variables, say -x1- and -x2-. You could reshape your
> data from wide to long and then use -tabulate- to get an association test
> between the categories of your original variables. Here is a simulated data
> example.
> --Jeff
> [email protected]
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/