wwwxxch
wwwxxch

Reputation: 3

Plotting odds ratio vs. continuous variable in stata

Is there any way I can plot a graph like this in stata:

linear OR of age;

image

The odds ratio is from a logistic regression.

I want to plotting the odds ratio of every value of the continuous variable and set reference as the lowest value. "margins" seems meet my need, however, I have to list all values of the continuous variable so that it can calculate the OR. Another question is I want plot this graph on another graph plotted by "twoway", and I'm not sure how to do this in stata.

Upvotes: 0

Views: 1651

Answers (1)

Erdne Htábrob
Erdne Htábrob

Reputation: 879

You basically answer your own question, it's an issue of using margins with marginsplot. The details are described in this post, but you would do something like:

logit outcome age, or
margins, at(age=(38(1)82)) expression(exp(xb()))
marginsplot

For your second question take a look at the marginsplot documentation. Similarly to other stata graphs it can be combined with other plots.

Upvotes: 1

Related Questions