24
$\begingroup$

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?

$\endgroup$
1

3 Answers 3

37
$\begingroup$

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.

$\endgroup$
2
  • 13
    $\begingroup$ Thanks didn't know the alias() function. That's really handy to have. Cheers, O. $\endgroup$
    – OFish
    Jul 17, 2014 at 1:31
  • 1
    $\begingroup$ Didn't know too the function alias. Pretty nice. $\endgroup$
    – igorkf
    Feb 11, 2020 at 22:12
2
$\begingroup$

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.

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

In my (somewhat limited) experiece, it is most likely due to high levels of colinearity between two or more varaibles. I would suggest using the VIF function to identify which varaibles are the most significant contributors in this respect, and take this into consideration when selecting the varaibles for elimination in the next iteration of your model.

In terms of interpreting VIF values, some suggest that under a value of 5 is an okay level, with a value of 5-10 acceptable in some circumstances. I usuaully don't rely on specific value thresholds too much, with the values still giving you a relative indication of issues of potenital colinearity.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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