I am fitting an lm() model to a data set that includes indicators for the financial quarter (Q1, Q2, Q3, making Q4 a default). Using lm(Y~., data = data) I get a NA as the coefficient for Q3, and a warning that one variable was exclude because of singularities.

Do I need to add a Q4 column?


NA as a coefficient in a regression indicates that the variable in question is linearly related to the other variables. In your case, this means that $Q3 = a \times Q1 + b \times Q2 + c$ for some $a, b, c$. If this is the case, then there's no unique solution to the regression without dropping one of the variables. Adding $Q4$ is only going to make matters worse.

  • 1
    $\begingroup$ I agree... there seems to be a problem with the dummy variables definitions. $\endgroup$ – Dominic Comtois Apr 3 '12 at 23:42
  • 20
    $\begingroup$ (+1). NA more generally means that the coefficient is not estimable. This can happen due to exact collinearity, as you've mentioned. But, it can also happen due to not having enough observations to estimate the relevant parameters (e.g. if $p > n$). If you predictors are categorical and you're adding interaction terms, an NA can also mean that there are no observations with that combination of levels of the factors. $\endgroup$ – Macro Apr 4 '12 at 0:59
  • 3
    $\begingroup$ $p > n$ is just a special case of colinearity - if there are fewer observations than predictors, colinearity is a given. You're right about interaction terms though, although I'm pretty sure that's not what's happening here. $\endgroup$ – Martin O'Leary Apr 4 '12 at 1:03
  • $\begingroup$ The variables are not linearly related, as Q3=1 iff Q1=Q2=0. Moreover, using stepAIC() and forcing the model to include all three of those variables causes no problems. Also, I have roughly 3x's the number of observations to variables. My best guess is there is colinearity between Q3 and some other variable, which I guess is one not included by the stepAIC. $\endgroup$ – Fraijo Apr 4 '12 at 4:43

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.