Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.

# st: RE: multi-dimensional chi-squared?

 From "Chevalier, Judy" To "statalist@hsphsun2.harvard.edu" Subject st: RE: multi-dimensional chi-squared? Date Tue, 20 Jul 2010 10:54:53 -0400

```Hello.  I am fairly new to this listserve.  I have a question about how one my think about constructing a test statistic and then  how to program it in STATA.  I may be missing a good way to think about it.  I will present this in the context of an economics/marketing dataset, though it may have a close analog in other domains.

Consider a dataset with multiple products (let's call them 4 different brands of peanut butter to be concrete) observed over multiple weeks.   I have coded whether each product for each week is at its regular price or on sale.    I am interested in the question of whether one and only one product being on sale in a given week occurs more frequently than would be predicted if the product sales were independent of one another.   So, I have (easily calculated) the frequency with which:

0 items are on sale
1 item is on sale
2 items are on sale
3 items are on sale
All 4 items are on sale.

Also, given the overall frequency that each item is on sale, I have also easily calculated the predicted probability (under the null hypothesis of independence) that 0 items would be on sale, 1 item would be on sale, 2 items would be on sale, 3 items would be on sale, etc.

I can see that 1 item is on sale more frequently in the data than would be predicted under the null hypothesis of independence, and, of course, the other categories are somewhat less frequent than would be predicted under the null.  However, I am stymied as to how to construct an appropriate test statistic.    I can test for the independence of the sales for each item, pairwise, easily, using Stata, but I can't quite manage the right test statistic nor how to compute it in Stata.   I will actually repeat this test for some other samples--- the products will be different, the number of products will be different, but the hypothesis will be the same-- that 1 and only 1 product is on sale more often than would be predicted under the null of independence.

If you have gotten this far-thanks for reading!

Judy

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```