> Wendell Joice
>
> > -chitesti- works fine; I need to tabulate the variables of
> > interest and then key in the frequencies to -chitesti-.
> >
> > Perchance, however, is there a command (other than and not
> > as elaborate
> > as -collapse-), that will produce a variable B containing
> > the frequencies of
> > the values in variable A? That way, I can place variable
> B directly
> > into -chitest- .
> >
> > Unless, of course, you know of a one-sample test that will
> > carry out the
> > entire process of calculating the frequencies of the
> > values of a specified
> > categorical variable and then provide a one-sample
> > chi-square over those
> > frequencies? (Analogous to -tabulate- for two sample chi square)
> >
>
As a sequel to my previous reply, here is one technique
illustrated:
. forval i = 1/5 {
2. qui count if rep78 == `i'
3. local counts "`counts' `r(N)'"
4. }
. di "`counts'
2 8 30 18 11
. chitesti `counts'
One advantage of this technique is that
will work fine when observed frequencies
are 0. You just have to use -forvalues-
or -foreach- to cycle over the possible
values of a variable relevant to your
test.
This could also be automated in a program.
*
* 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/