title: singular contrast matrix error in ANOVA contrasts
body: <p>The short version is this: I am trying to run a series of planned contrasts on a one-way ANOVA with a long list of factors (18) using the contrasts() function. Up to four contrasts seems to work fine, but when the fifth is added we suddenly get a 'singular contrast matrix'</p>
  <pre><code>treat&lt;-as.factor(c(&quot;T09&quot;, &quot;T15&quot;, &quot;T19&quot;, &quot;T20&quot;, &quot;T07&quot;, &quot;T04&quot;, &quot;T22&quot;, &quot;T21&quot;, &quot;T23&quot;, &quot;T08&quot;, &quot;T01&quot;, &quot;T16&quot;, &quot;T03&quot;, &quot;T02&quot;, &quot;T06&quot;, &quot;T10&quot;, &quot;T17&quot;, &quot;T03&quot;, &quot;T16&quot;, &quot;T23&quot;, &quot;T08&quot;, &quot;T20&quot;, &quot;T04&quot;, &quot;T01&quot;, &quot;T19&quot;, &quot;T22&quot;, &quot;T06&quot;, &quot;T09&quot;, &quot;T07&quot;, &quot;T15&quot;, &quot;T02&quot;, &quot;T17&quot;, &quot;T14&quot;, &quot;T21&quot;, &quot;T10&quot;, &quot;T01&quot;,&quot;T09&quot;, &quot;T16&quot;, &quot;T08&quot;, &quot;T19&quot;, &quot;T07&quot;, &quot;T10&quot;, &quot;T20&quot;, &quot;T22&quot;, &quot;T03&quot;, &quot;T14&quot;, &quot;T23&quot;, &quot;T15&quot;, &quot;T04&quot;, &quot;T21&quot;, &quot;T02&quot;, &quot;T17&quot;, &quot;T06&quot;))
  
  
  mat&lt;-cbind(c(2, -1, -1, -1,  2,  2, -1, -1, -1,  2 , -1, -1, -1,  2,  2, -1, -1, -1),
             c(0,  1,  1,  1,  0,  0, -1, -1, -1,  0,  1,  1,  1,  0,  0, -1, -1, -1),
             c(0,  1,  -1,  0,  0,  0, 1, -1, 0,  0,  1,  -1,  0,  0,  0, 1, -1, 0),
             c(0,  1,  0, -1,  0,  0,  1,  0, -1,  0,  1,  0, -1,  0,  0,  1,  0, -1),
             c(0,  0,  1, -1,  0,  0,  0,  1, -1,  0,  0,  1, -1,  0,  0,  0,  1, -1))
  
  contrasts(treat) &lt;- cr.mat[, c(1:5)]
  </code></pre>
  <p>If I remove a contrasts, any of the five, it works fine, so it is not an issue with a particular one.</p>
  <p>From past posts here I have learned that certain combinations of factors/contrasts are going to create singular matrices, but from a practical standpoint, there must be some kind of work-around for this type of problem? I've even tried adding some additional contrasts just to see if I could 'even it out' but I get the same problem.</p>
  <p>Any and all suggestions welcome.</p>