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?
 A: 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<k}\beta_{jk} x_jx_k
$$ 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<k} x_j x_k = \binom{m}{2}$, where $m=\sum x_j$ is the number of active comorbidities. Other variants are certainly possible.
