Wendell Joice
> chitest rep78, count
> count invalid
> r(198);
My guess is that this is because you are using an
out-of-date copy of -chitest-. Perhaps you downloaded
the program from http://www.stata.com/users/njc/tab_chi
which holds an older version (supposedly, for any remaining
users of Stata 5.0; any such on Statalist?).
The version on SSC allows the -count- option, which is
why it worked for me.
> I have no data with '0' observed values.
You will, some day!
> DO FILE
> .do chitest SEX "& racewbh==3 & csample==1"
>
> .forval i = 0/5 {
> 2. qui count if `1'== `i' `2'
> 3. if r(N)==0 {
> 4. continue
> 5. }
> 6. local counts "`counts' `r(N)'"
> 7. }
>
> . di "`counts'
> 950 767
>
> . chitesti `counts'
>
> Chi-square test:
> observed frequencies from keyboard
> expected frequencies equal
>
> Pearson chi2(1) = 19.5044 Pr = 0.000
> likelihood-ratio chi2(1) = 19.5415 Pr = 0.000
>
> residuals
> observed expected classic Pearson
> 1. 950 858.500 91.500 3.123
> 2. 767 858.500 -91.500 -3.123
>
> . macro drop _counts
>
> . end of do-file
The macro will get dropped anyway, as it
is local, and thus invisible outside the .do file,
but this does no harm.
Nick
n.j.cox@durham.ac.uk
*
* 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/