Statistics Toolbox | ![]() ![]() |
Including Categorical Factors
Another example where it is useful to call candexch
directly is to generate a design that includes categorical factors. For these designs you create a candidate set containing "dummy variables" for the categorical factors. The dummyvar
function is useful to create such a candidate set.
In this example we have three categorical factors, each taking three levels. We create a candidate set F
containing all 27 combinations of these factor levels. Then we create a matrix C
containing dummy variables for the factors, and we remove enough columns to make the resulting matrix full rank. (We remove one column for each factor except the first factor.) Finally, we use the candexch
function to generate a 9-run design. The resulting design has the property that for each pair of factors, each of the 9 possible combinations of levels appears exactly once.
F = fullfact([3 3 3]); C = dummyvar(F); C(:,[4 7]) = []; rows = candexch(C,9); D = F(rows,:) D = 3 1 3 1 3 2 3 3 1 1 2 3 2 2 1 2 1 2 3 2 2 2 3 3 1 1 1
![]() | Controlling Candidate Points | Demos | ![]() |