# How to code non-exclusive variables for logistic regresion

I have a question about logistic regression in R. I want to study the influence of certain comorbidities in patients in predicting deceased status(Y/N). So far, I formatted all my comorbidities(17) into dummy variables having 'none' as the reference variable. When I see logistic regression tutorials, it all seem to code categorical variables as exclusive, while mine are not, meaning one person might have up to 10 different comorbidities.

Taking the idea from a few posts I have seen, I would have a category named comorbidities, and then repeat each subject ID for each comorbidity present and then let R code the dummies.

Would logistic regression be the correct way to approach this situation? Would I have to group the comorbidities in a way that a subject can only have one and only one comorbidity and none for the others?

• Start with the model with all 17 dummies. You probably want age in there too, which is not a dummy. Age is not linearly related to survival, so you may need to include a quadratic term. Certain combinations of comorbidities can be especially lethal so you need to consider including product terms. Yes, use logistic regression. Depending on your sample size you may need to prune the model, but scientifically, the more complete model is always more accurate as a representation of what is really going on. Commented Jan 5, 2021 at 12:08
• Same Q (no answers): stats.stackexchange.com/questions/456115/… Commented Jan 5, 2021 at 17:56
• stats.stackexchange.com/questions/30818/… Commented Jan 5, 2021 at 17:59

A factor variable with (in your case, 17) possible levels, is meant for the case with mutually exclusive categories. So, in your case, define in its place 17 binary factors, one for each possible level. Then, with a logistic (or other ...) regression model, define the linear predictor $$\eta$$ as $$\eta = \beta_0 +\sum_j \beta_j x_j$$ where each $$x_j$$ is binary $$0/1$$. One binary variable for each comorbidity. This is an additive model, and that is maybe not realistic, as it assumes that the effect of the comorbidity $$x_j$$ is the same irrespective how many other comorbidities are present. So maybe try to introduce interactions: $$\eta = \beta_0 +\sum_j \beta_j x_j + \sum_{j but with 17 different levels that have $$1+16+120$$ parameters, which might be too many ... So you try some kind of structured interaction, for example assuming that all the $$\beta_{jk}$$'s are equal. In that case, note that $$\sum_{j, where $$m=\sum x_j$$ is the number of active comorbidities. Other variants are certainly possible.