Design matrix for general linear model (GLM) in Minitab

General Linear Model uses a regression approach to fit the model that you specify. First Minitab creates a design matrix, from the factors and covariates, and the model that you specify. The columns of this matrix are the predictors for the regression.

The design matrix has n rows, where n = number of observations, and one block of columns, often called indicator variables, for each term in the model. There are as many columns in a block as there are degrees of freedom for the term. The first block is for the constant and contains one column, a column of all ones. The block for a covariate also contains one column, the covariate column itself.

Suppose A is a factor with 4 levels and the model uses -1, 0, +1 coding. Then it has 3 degrees of freedom and its block contains 3 columns, call them A1, A2, A3. Each row is coded as one of the following:
Level of A A1 A2 A3
1 1 0 0
2 0 1 0
3 0 0 1
4 -1 -1 -1
Suppose factor B has 3 levels nested within each level of A. Then its block contains (3 - 1) x 4 = 8 columns, call them B11, B12, B21, B22, B31, B32, B41, B42, coded as follows:
Level of A Level of B B11 B12 B21 B22 B31 B32 B41 B42
1 1 1 0 0 0 0 0 0 0
1 2 0 1 0 0 0 0 0 0
1 3 -1 -1 0 0 0 0 0 0
2 1 0 0 1 0 0 0 0 0
2 2 0 0 0 1 0 0 0 0
2 3 0 0 -1 -1 0 0 0 0
3 1 0 0 0 0 1 0 0 0
3 2 0 0 0 0 0 1 0 0
3 3 0 0 0 0 -1 -1 0 0
4 1 0 0 0 0 0 0 1 0
4 2 0 0 0 0 0 0 0 1
4 3 0 0 0 0 0 0 -1 -1

To calculate the indicator variables for an interaction term, multiply all the corresponding dummy variables for the factors and/or covariates in the interaction. For example, suppose factor A has 6 levels, C has 3 levels, D has 4 levels, and Z and W are covariates. Then the term A * C * D * Z * W * W has 5 x 2 x 3 x 1 x 1 x 1 = 30 indicator variables. To obtain them, multiply each indicator variable for A by each for C, by each for D, by the covariates Z one time and W twice.