Modeling & Regression Errors
Fitted probabilities 0 or 1
Matches: fitted probabilities numerically 0 or 1
WHAT THIS ERROR MEANS
In logistic regression, some predicted probabilities are extremely close to 0 or 1, indicating perfect or near-perfect separation. A predictor perfectly separates the outcome.
HOW TO FIX IT
1. Investigate which predictor causes perfect separation.
2. Remove or combine the problematic predictor.
3. Use penalized regression (e.g., glmnet) to handle separation.
4. Consider if your model is overfit.
CODE EXAMPLES
BAD — THIS CAUSES THE ERROR
# x perfectly predicts y glm(default ~ balance, family = binomial, data = df)
GOOD — CORRECT APPROACH
# Use penalized regression library(glmnet) fit <- cv.glmnet(x_matrix, y, family = "binomial")
Still stuck?
Paste your code in RChat and the AI will fix this error in context.
RELATED MODELING & REGRESSION ERRORS
NA/NaN/Inf in model fit Your data contains NA, NaN, or Inf values that the modeling function cannot hand...
Singular or rank-deficient fit Your model has perfect multicollinearity — some predictors are exact linear comb...
GLM did not converge The iterative algorithm used to fit the generalized linear model failed to find ...
Factor has new levels in predict Your prediction data contains factor levels that weren't present in the training...