When doing a GLM and you get the "not defined because of singularities" error in the anova output, how does one counteract this error from happening?

Some have suggested that it is due to collinearity between covariates or that one of the levels is not present in the dataset (see: interpreting "not defined because of singularities" in lm)

If I wanted to see which "particular treatment" is driving the model and I have 4 levels of treatment: Treat 1, Treat 2, Treat 3 & Treat 4, which are recorded in my spreadsheet as: when Treat 1 is 1 the rest are zero, when Treat 2 is 1 the rest are zero, etc., what would I have to do?


You're probably getting that error because two or more of your independent variables are perfectly collinear (e.g. mis-coding dummy variables to make identical copies).

Use cor() on your data or alias() on your model for closer inspection.

  • 7
    $\begingroup$ Thanks didn't know the alias() function. That's really handy to have. Cheers, O. $\endgroup$ – OFish Jul 17 '14 at 1:31

Error "not defined because of singularities" will occur due to strong correlation between your independent variables. This can be avoided by having n-1 dummy variables. In your case, for Treatment variable, you should use 3 binary dummy variables (Treat1, Treat2, Treat3).

In R programing, linear regression functin lm() will result in "NA" as co-efficient for highly correlated variables.

  • 1
    $\begingroup$ Can you say how you see this as adding to the existing answer? Perhaps by editing it? $\endgroup$ – mdewey Nov 22 '17 at 12:05

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.