4

Ratgrp stands for lung function (FEV1/FVC)*100 and it has two categories:

  • 1: Lung function less than 70
  • 2: Lung function equal and higher than 70

smkgrp stands for smoking group and it is also categorically represented as:

  • 1: Nonsmokers
  • 2: Ex-smokers
  • 3: Smokers

Based on logit differences, how many odds ratios (ORs) you can compute for the interaction term ratgrp * smkgrp?

Richard Hardy
  • 67,272
Jonathan
  • 41
  • 1

2 Answers2

4

Answer: 2 coefficients for the interaction can be calculated.

Explanation: If you have two categorical variables, one with $L_1$ levels and the other with $L_2$ levels, then you can calculate $(L_1 - 1)*(L_2-1)$ coefficients for the interaction.

Peter Flom
  • 119,535
  • 36
  • 175
  • 383
  • 2
    I upvoted your answer but then realized the short answer isn't correct by this calculation. Since $L_1 = 2$ and $L_2 = 3$, wouldn't this mean it is $(2-1) * (3 - 1) = (1) * (2) = 2$? The estimated coefficients in R from my answer seem to reflect this, but I could be wrong. – Shawn Hemelstrand Mar 04 '24 at 03:31
  • 2
    @ShawnHemelstrand The question seems to have changed since I answered. I could have sworn each had two levels. Thanks for your edit – Peter Flom Mar 04 '24 at 10:21
  • 1
    No worries. Glad we are on the same page in any case. – Shawn Hemelstrand Mar 04 '24 at 10:25
4

Peter has a nice trick for estimating the number of coefficients for the interaction (+1). This can easily be checked in any regression software as well. As an example with some online data from UCLA and some R programming, here I manipulate the data to have three levels in one and two levels in another, ultimately creating two interaction coefficients such as yours would have.

#### Load Library and Data ####
library(tidyverse)
hdp <- read.csv("https://stats.idre.ucla.edu/stat/data/hdp.csv") %>% 
  as_tibble() %>% 
  mutate(CancerStage = factor(CancerStage)) %>% 
  filter(!CancerStage == "IV")
hdp

Fit Model

fit <- glm(remission ~ CancerStage * Sex - 1, data = hdp, family = binomial)

Inspect

exp(coef(fit)) # exponentiate for OR

As shown below, where an OR is calculated for two interaction terms:

         CancerStageI          CancerStageII         CancerStageIII                Sexmale 
             0.6265823              0.4209431              0.3175231              0.9696970 
 CancerStageII:Sexmale CancerStageIII:Sexmale 
             1.1914599              0.9767356 
  • @ Shawn: Are you allowed to calculate the Odds Ratio for some combination of coefficients? e.g. Exp(Beta_5 + Beta_7)? – Uk rain troll Mar 04 '24 at 04:28
  • thanks ... do you think you can please post an explanation about this? I struggle with this point a lot, e.g. fit a simple logistic regression model to some data (with no interactions). does it make sense to calculate the odds ratio of multiple variables together and compare them to some reference level? Can you please post some math about this? I would really appreciate it... thank you so much! – Uk rain troll Mar 04 '24 at 07:37
  • Sorry ignore my previous comment, as I misread what you said (your original statement was correct). If you are trying to get the odds ratio of an event based off multiple predictors, you simply take the sum of the logit-scale coefficients (the original coefficients before transformation) and then transform them to probability or odds ratio after. An example is shown here on the probability scale, you would just use OR instead for your case. Note that my previous comment is still true about how you "toggle" these on/off, as shown in the answer. – Shawn Hemelstrand Mar 04 '24 at 08:06