[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
May Boggess <mboggess@stata.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: reporting odds for N categories |

Date |
Thu, 22 Sep 2005 13:50:16 -0500 |

On Thursday morning, Dan asked about odds and odds ratios:

Dan has asked a few different things, but here I'll just concentrate on one aspect of his question: how to graph odds.

I have a cross sectional dataset which reports the health outcomes and covariate information for patients belonging to Z clinics.

I am trying to compare the performance (ie. % of patients in a clinic that failed health outcome) for each of the Z clinics, but can not find a way that I can produce results suitable for graphing from either the logistic or tabodds commands, as the reference group is, by default, the clinic with the lowest numeric ID.

How can I set the reference category to the mean, so that I can graph the odds of failing, controlling for A and B, for each of the Z clinics in the dataset?

One can use the epitab command -tabodds- to calculate odds. For example:

clear

webuse bdesop

expand freq

tabodds case alc

di " p= " 40/(40+386)

di "odds= " (40/(40+386))/(1- 40/(40+386))

The last two lines remind us how odds are calculated: odds=p/(1-p).

We can use a logistic model to obtain the same results. The reason to do that is that we can get the probabilities, and thus odds, as variables in the dataset:

clear

webuse bdesop

expand freq

tabodds case alc

xi:logit case i.alc

predict p

gen odds=p/(1-p)

tabdisp alc, c(p odds)

Now -twoway- can be used to create a graph:

twoway scatter odds alc

In order to be able to compare odds, we need confidence intervals as well. I find the easiest way is to use -predictnl- instead of -predict-, since it can calculate the confidence intervals as well:

clear

webuse bdesop

expand freq

tabodds case alc

xi:logit case i.alc

predictnl odds=predict(p)/(1-predict(p)), ci(lb ub)

label var odds "odds"

tabdisp alc, c(odds lb ub)

Notice that in the intervals we produce this way are close to but not exactly the same as those that -tabodds- calculates (which are from Clayton and Hills "Statistical Models in Epidemiology" (1993) p. 169).

Again I can use -twoway- to get a graph:

twoway rcap lb ub alc || connected odds alc, legend(off) sort

This is essentially the same as the graph we can obtain from -tabodds- using the -ciplot- option. Why go to all this trouble then?

So we can go a little further. In Dan's case he needs to adjust for some covariates. In example dataset I have agegrp to adjust for:

clear

webuse bdesop

expand freq

tabodds case alc

xi:logit case i.alc agegrp

predictnl odds=predict(p)/(1-predict(p)), ci(lb ub)

label var odds "odds"

tabdisp alc agegrp, c(odds)

I can now choose what I would like to graph, but for one example I will

graph the odds for age group 45-54:

clear

webuse bdesop

expand freq

tabodds case alc

xi:logit case i.alc agegrp

predictnl odds=predict(p)/(1-predict(p)), ci(lb ub)

label var odds "odds"

tabdisp alc agegrp, c(odds)

keep if age==3

#d;

twoway rcap lb ub alc

|| connected odds alc,

legend(off) sort

title("Odds for age group 45-54");

#d cr

-- May

mmb@stata.com

*

* 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/

**References**:**st: reporting odds for N categories***From:*Dan Exeter <d.exeter@st-andrews.ac.uk>

- Prev by Date:
**RE: st: Re: collapse syntax error** - Next by Date:
**Re: st: Problems with internet access [was: ... Collapse syntax error]** - Previous by thread:
**st: reporting odds for N categories** - Next by thread:
**Re: st: reporting odds for N categories** - Index(es):

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