Modeling & Regression Errors
Singular or rank-deficient fit
Matches: (nearly )?singular fit|rank-deficient
WHAT THIS ERROR MEANS
Your model has perfect multicollinearity — some predictors are exact linear combinations of others, making the model unsolvable. This often happens with dummy variable traps or redundant features.
HOW TO FIX IT
1. Remove redundant or perfectly correlated predictors.
2. Check for dummy variable traps (drop one level of each factor).
3. Use alias() to identify which coefficients are aliased.
CODE EXAMPLES
BAD — THIS CAUSES THE ERROR
# pct_male + pct_female always = 100 lm(y ~ pct_male + pct_female, data = df)
GOOD — CORRECT APPROACH
lm(y ~ pct_male, data = df) # drop one redundant predictor
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...
GLM did not converge The iterative algorithm used to fit the generalized linear model failed to find ...
Fitted probabilities 0 or 1 In logistic regression, some predicted probabilities are extremely close to 0 or...
Factor has new levels in predict Your prediction data contains factor levels that weren't present in the training...