# Design/Contrast Matrices and Unestimable Coefficients

I am trying to analyse microarray data from samples with the following characteristics: one of two genotypes, a procedure either carried out or not carried out, and, in the case that the procedure is carried out, the treatment can either be a drug or a negative control.

My design matrix, therefore, has three columns: genotype, procedure, and treatment. What I don't understand is how to construct the design matrix such that contrasts be extracted. Most online guides recommend that the design matrix be transformed into factors, but, since all of my variables have only two values, the two factor columns that come out will necessarily be linearly dependent, which means that the linear fit will come back with a warning saying that not all variables could be modelled. On the other hand, if I leave the design matrix as is—i.e., with three columns of 0/1 variables—how do I create the contrast matrix if there is no subtraction for the makeContrasts() function that can compare genotype == 0 with genotype == 1, for example?

• When you say it will come back, have you actually tried it? I think R is smarter than you give it credit for. – mdewey Jul 14 '16 at 20:40
• Yep, I have tried it and there are basically two options in the end: either you let it create a strange design matrix where it doesn't have every possible level for each variable, or you define the design matrix and then it complains about many of the columns being representative of unestimable coefficients :/ – JCCS Jul 15 '16 at 0:47
• Well that is inevitable. There are only so many linearly independent columns. You can play around with which ones you have but you cannot exceed the limit. – mdewey Jul 15 '16 at 7:57
• Can you elaborate on that? I don't quite understand what you mean. – JCCS Jul 15 '16 at 20:22
• You have eight means (or possibly only six as the design may not be a full factorial one). That means there are only eight independent things you can say about the means (or six). – mdewey Jul 16 '16 at 12:39