Q: What is the mathematical theory behind coding categorical variables for regression analysis?
The situation is this:
For numeric variables, we can code observations via the transformation
$\textrm{coded value} = \frac{\textrm{uncoded value} - \frac{(high+low)}{2}}{\frac{(high-low)}{2}}$.
For categorical variables, the above clearly will not work. I have been given the following codings without justification. For two variables, such as material type A and type B, we code them as
$ Type A = -1 \\ Type B = 1. $
If the there are three variables, we code them as
$ Type A = \{1,0\} \\ Type B = \{0,1\} \\ Type C = \{-1,-1\}. $
Once coded, we can then enter the data into SAS and run PROC REG to determine a regression model.
What is the mathematical basis for this coding? My textbook, Montgomery Design and Analysis of Experiments, 8th Edition, provides little more than a page on coding in general. My instructors cannot provide me with anything more than that it has something to do with orthogonality of vectors.
For the three variable case, we can see that any two vectors are linearly independent, but the three together are dependent. As such if we arrange them in a matrix, the matrix must then be singular.
Just as there is a justification for the numeric case, I want to understand the categorical. I'm not afraid of matrices or linear algebra, although it seems like there could be a simple geometric explanation. If it is too lengthy to explain, I would be happy with a textbook or online reference.