# How do I calculate the odds ratio in a logistic model with an interaction term (categorical)?

In the following logistic regression model, I am trying to model the logit of Y, where Y is a binary variable (Yes or No).

Let my model be: logit($Y$) = $\beta_0$ + $\beta_1$*$x_1$+ $\beta_2$*$x_2$+ $\beta_3$$x_1*x_2$

Both $x_1$ and $x_2$ are binary variables which are used as covariates to the logistic model. $x_1$ is the treatment term (Treatment A and Treatment B), while $x_2$ is the gender (Male vs Female)

If I need to calculate the odds ratio of Treatment A vs Treatment B, what I learned from school is that I would actually compute both Treatment A vs Treatment B at $x_2$ = Male" and Treatment A vs Treatment B at $x_2$ = Female. So my first question: is this approach correct?

Second question: If I must produce 1 single odds ratio of "Treatment A vs Treatment B" with this model, would it make sense for me to take the mean of the 2 odds ratios? Let's assume I cannot produce another model taking away the interaction term. If not, is there anyway to produce that single Odds Ratio in SAS with this model?

Thank you very much!

• If you work out the math by hand I think you will see that the gender term will cancel out. So my suggest is write out the OR by hand and see what cancels out and what terms you are left with :) – Lauren Goodwin Jul 24 '15 at 15:53
• Thanks Lauren, I realized that I probably worded my question incorrectly. I am not just finding the OR from the beta1. I would want to find an OR (if there is one), where I can produce the OR for "Treatment A vs Treatment B" considering the interaction. Would the OR for that be exp(beta1+beta3/2 )? – Redman Jul 24 '15 at 16:55
• Why do you want to consider the interaction? Is there a specific question you are trying to answer? – Lauren Goodwin Jul 24 '15 at 17:42
• after working it out on paper you do have to do it for both genders. So if male is coded as 0 then the OR of trt A vs B would be exp(beta1) and for female (coded as 1) exp(beta1 + beta3). – Lauren Goodwin Jul 24 '15 at 17:56
• Thanks, so here I have exp(beta1) which is (Treatment A vs B for Male) and exp(beta1+beta3) which is (Treatment A vs B for Female). However, is there a way to combine these two ORs, to create (Treatment A v B for everyone)? This would be something obtainable if I remove the interaction term from the model, but could I still get that in this interaction model? I want to only use 1 model, hence I chose this model with the interaction term because it would contain information on whether any interaction terms would be needed for further exploratory analyses. – Redman Jul 24 '15 at 19:25

If the interaction term is statistically significant or otherwise important based on knowledge of the subject matter, then an attempt to produce a "single odds ratio of 'Treatment A vs Treatment B'" is at best uninformative and at worst misleading.

The point of the interaction term is that the effect of the treatment might depend on gender. If that is the case, then the "single odds ratio" however determined is going to depend on the gender balance in your sample. Averaging coefficients, as noted by others, is not reliable. With an interaction of treatment by gender, even repeating the analysis by omitting the gender and interaction terms would lead to results tilted in the direction of the more prevalent gender in your sample. I suppose you could try to ensure that the gender balance in the underlying population is taken somehow into account in your analysis, but that also would tend to hide the important information about the treatment by gender interaction.

The best advice here would be to avoid reporting a single odds ratio and present separately the results for males and females.

It is perfectly fine to average the coefficients in some cases if what you want is a summary measure of the effect size of the treatment. In particular, if had fit a Bayesian logistic regression model, say with the bayesglm package in R, you could take many samples from the posterior distribution of the coefficients. Then for each sampled coefficient vector, you could compute the sex-specific treatment effect by summing the interaction coefficient and treatment effect. Then again for each sample, you could average the sex-specific treatment effects. You could then compute the expectation and credible intervals of this estimate to get a summary measure of the treatment effect and its posterior distribution. If you wanted to weight the average by the proportion of males versus females in a population of interest, you could do that, too.

Edit

On second thought, if you want an odds ratio that represents the average effect over the two sexes, you should just build another model without a sex predictor in it and present the treatment effect. Thanks to @FrankHarrell for noting that I had led myself and potentially other people astray.

• I'm not sure how to interpret that average, or whether I'd want to interpret it. – Frank Harrell Dec 29 '15 at 21:53
• Yeah, on second thought, it is a bit weird. – Brash Equilibrium Dec 30 '15 at 21:07