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

Re: st: Tabodds with multiple explanatory variables


From   Philip Ryan <philip.ryan@adelaide.edu.au>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Tabodds with multiple explanatory variables
Date   Wed, 18 Aug 2004 09:50:10 +0930

egen exp_group = group(hair eyes), label
tabodds cases exp_group, or


The -label- option makes nice output in the -tabodds- table when you have value labels already applied to the original exposure variables.

Phil


At 05:31 PM 17/08/2004 -0400, you wrote:

Howdy,

This is mostly a post to ask, is there an easier/more elegant way?

I would like to calculate odds ratios over pairs of stratification
variables, for example, hair and eyes.  Hair has values of 0 or 1 and eyes
can be 0, 1, or 2.  There are then 6 categories: hair = 0 and eyes = 0; hair
= 1 and eyes = 0; hair = 0 and eyes = 1; hair = 1 and eyes = 1 ...and so on.
The goal is a table that looks like this:

---------------------------------------------------------------------------
   hair eyes |  Odds Ratio       chi2       P>chi2     [95% Conf. Interval]
-------------+----------------------------------------------------------
     0     0 |    1.000000          .           .              .          .
     1     0 |    0.857143       0.02       0.8814      0.112836   6.511180
     0     1 |    3.529412       2.23       0.1354      0.602837  20.663549
     1     1 |    3.600000       2.39       0.1222      0.633331  20.463229
     0     2 |   44.000000      16.95       0.0000      2.009823 963.268843
     1     2 |    6.857143       4.72       0.0298      0.911312  51.596417
---------------------------------------------------------------------------

To achieve this result I currently use the following code:

gen cat = hair + 2*eyes
lab def catlbl 0 "0   0" 1 "1   0" 2 "0   1" 3 "1   1" 4 "0   2" 5 "1   2"
lab val cat catlbl
lab var cat "hair eyes"
tabodds cases cat, or base(1) // make sure we use hair = 0, eyes = 0 as the
referent

This code works but isn't portable.  I have 3 primary variables to be
stratified over 8 other variables all with various possible values (ie some
are 0,1, and others are 0,1,2,3) yielding 24 combinations.  Is there a
clever, portable way to generate variables representing all possible
combinations of two categorical variables?  Or, better yet, a way to get
tabodds to stratify over two variables?

Thanks in advance to any thought given this problem,

Ben Hulley

*******************
NCI/DCEG/GEB
Room: EPS 7007
Tel: (301) 402-1622
Fax: (301) 402-4489
*
*   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/
Philip Ryan
Associate Professor,
Department of Public Health
Associate Dean (Information Technology)
Faculty of Health Sciences
University of Adelaide 5005
South Australia
tel 61 8 8303 3570
fax 61 8 8223 4075
http://www.public-health.adelaide.edu.au/
CRICOS Provider Number 00123M
-----------------------------------------------------------
This email message is intended only for the addressee(s)
and contains information that may be confidential and/or
copyright. If you are not the intended recipient please
notify the sender by reply email and immediately delete
this email. Use, disclosure or reproduction of this email
by anyone other than the intended recipient(s) is strictly
prohibited. No representation is made that this email or
any attachments are free of viruses. Virus scanning is
recommended and is the responsibility of the recipient.

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index