Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Re: RE: one-sample chi square test


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Re: RE: one-sample chi square test
Date   Thu, 30 Jan 2003 10:31:08 -0000

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)
> 

-chitest- is able to do this for you. Here is  
a silly example for the simplest case of equal 
expected frequencies. 

. chitest rep78, count

Chi-square test:
    observed frequencies from rep78
    expected frequencies equal

         Pearson chi2(4) =  33.3913   Pr =  0.000
likelihood-ratio chi2(4) =  34.7183   Pr =  0.000

                                   residuals
     +-----------------------------------------+
     | observed   expected   classic   Pearson |
     |-----------------------------------------|
  1. |        2     13.800   -11.800    -3.176 |
  2. |        8     13.800    -5.800    -1.561 |
  3. |       30     13.800    16.200     4.361 |
  4. |       18     13.800     4.200     1.131 |
  5. |       11     13.800    -2.800    -0.754 |
     +-----------------------------------------+

What -chitest- can't do is count values which 
could be there in principle but which in 
practice don't occur (cells with observed 0, 
in short). 

I suspect there are other problems, but at worst 
you need to type a few numbers at -chitesti-. 

If this doesn't solve the problem, please give 
a clear example of the data structure you have in 
mind. 

Nick 
[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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index