[R] Coefficients: (20 not defined because of singularities)

Ott Toomet otoomet at econ.dk
Fri May 30 10:37:04 CEST 2003


Hi,

"singularity" in this case means that your X'X matrix is singular,
i.e. you have multicollinearity in your data.  A common reasons is
selecting observations with a particular binary feature (e.g. only
women) and then including a control variable for the same feature
(e.g. including child*women cross effect).  You seem to be working
with the continuous variables, so this may not be the case.

A way to check collinearity is using condition numbers (look
kappa() in R).  First, make the model matrix (you may use
model.matrix() but if you have only variables and no special effects,
you may use cbind() instead).  Then take a single column out of the
matrix and calculate the condition number (this is definitely 1).  Now
add the second column, and calculate again.  Print out condition
numbers, corresponding to the number of columns you used.  You should
see where the number explodes, it means corresponding variable is
collinear with some of the previous ones.

Perhaps it helps.

Ott

 | From: Thomas Fischer <th.fischer at gmx.net>
 | Date: Fri, 30 May 2003 10:44:55 +0200
 | 
 | Hello,
 | 
 | I am trying to run a linear regression analysis on my data set. For some 
 | reason most variables are removed due to singularities.
 | 
 | My linear regression looks this way (I am using only partial data, which 
 | is selected by flags):
 | 
 | fm<-lm(log(cplex6.time..sec..[flags]) ~ cplex6.cities[flags] + 
 | log(1/features.meanOver.frust[flags]) + 
 | log(1/features.meanOver.minDist[flags]) +

 | The summary of one of the removed coefficients looks like this:
 | 
 | > summary(features.spanOver.quart1SpanDist[flags])
 |    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
 | 0.05584 0.05797 0.06366 0.06311 0.06674 0.07290
 | > summary(log(1/features.spanOver.quart1SpanDist[flags]))
 |    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
 |   2.619   2.707   2.754   2.767   2.848   2.885
 | 
 | The summary of a coefficient that was kept looks this way:
 | 
 | > summary(features.quant25Over.minDist[flags])
 |     Min.  1st Qu.   Median     Mean  3rd Qu.     Max.
 | 0.001030 0.001030 0.001030 0.001032 0.001030 0.001040
 | > summary(log(1/features.quant25Over.minDist[flags]))
 |    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
 |   6.869   6.878   6.878   6.877   6.878   6.878
 | 
 | So, I don't see the difference. Why has the first coefficient been 
 | removed and the second one kept?
 | Please help me.
 | 
 | I'm using R 1.6.2 on a Linux x86 machine.
 | 
 | Greetings,
 | Thomas Fischer




More information about the R-help mailing list