0
$\begingroup$

In my model, I have a Response variable, 0s or 1s.

I have 15 categorical variables, some of which have 150+ levels. Should I potentially exclude them from my model?

When I run full model <- glm(Response ~ Category1 + Category2 + ... + Category15 -1, data=dataframe, family="binomial") I get:

1: glm.fit: algorithm did not converge
2: glm.fit: fitted probabilities numerically 0 or 1 occurred

Should I exclude Categories with many levels? Ideally, I would exclude them by running anova with the full model and model with that category omitted as:

anova(fullmodel, model_test, test="LRT")

Note, that for the model_test the GLM converges fine.

$\endgroup$
  • 1
    $\begingroup$ Problems occur when you don't have the information content to support estimation of the parameters. If you don't use penalized maximum likelihood estimation, you'll need roughly 15 observations times the number of categories (all predictors combined). At a minimum you need at least 15 observations (and ideally 96) in the least frequent category over all predictors. $\endgroup$ – Frank Harrell Sep 17 '17 at 13:27
  • $\begingroup$ My data set has 160,000 observations, but I could still have 1 category, where a single level only has 1 observation... I'm guessing that's where the problem comes from. What do you suggest to do? $\endgroup$ – GRS Sep 17 '17 at 13:32
  • $\begingroup$ Also I have some blanks in categorical variables, I don't how R handles blanks, but I assumed it was okay $\endgroup$ – GRS Sep 17 '17 at 13:33
  • $\begingroup$ @GRS from your explanation, it seems like a problem of sparsity. Perhaps you could collapse some groups. Blanks would be treated as NA. R apply list wise deletion whenever there are blanks. $\endgroup$ – tatami Sep 17 '17 at 13:33
  • 2
    $\begingroup$ You have several fundamental problems including proper multiple imputation of missing values that will require a lot of study. My RMS notes cover many issues related to your goals, and point you to many articles you will need to read to properly understand the issues. It would be a mistake to proceed at this point. $\endgroup$ – Frank Harrell Sep 17 '17 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.