# How to select runs from a full factorial experiment design matrix to build a fractional factorial design

I have a design matrix with 18 runs. A and B are three-level categorical variables (low, mid , high and small, medium and large), and C is a two-level categorical variable (male, female). Here's an example

| runs   | low | mid | small | medium | male |
|--------|-----|-----|-------|--------|------|
| run 1  | 1   | -1  | 1     | -1     | 1    |
| run 2  | 1   | -1  | 1     | -1     | -1   |
| run 3  | 1   | -1  | -1    | 1      | 1    |
| run 4  | 1   | -1  | -1    | 1      | -1   |
| run 5  | 1   | -1  | -1    | -1     | 1    |
| run 6  | 1   | -1  | -1    | -1     | -1   |
| run 7  | -1  | 1   | 1     | -1     | 1    |
| run 8  | -1  | 1   | 1     | -1     | -1   |
| run 9  | -1  | 1   | -1    | 1      | 1    |
| run 10 | -1  | 1   | -1    | 1      | -1   |
| run 11 | -1  | 1   | -1    | -1     | 1    |
| run 12 | -1  | 1   | -1    | -1     | -1   |
| run 13 | -1  | -1  | 1     | -1     | 1    |
| run 14 | -1  | -1  | 1     | -1     | -1   |
| run 15 | -1  | -1  | -1    | 1      | 1    |
| run 16 | -1  | -1  | -1    | 1      | -1   |
| run 17 | -1  | -1  | -1    | -1     | 1    |
| run 18 | -1  | -1  | -1    | -1     | -1   |


Is it possible to select runs for a fractional design based on this matrix or is there an algorithm that would allow me to do it for more complex setups?

You could use algorithms for optimal experimental design. Below I give an example, using R.

library(AlgDesign)   # on CRAN

full <- gen.factorial(levels=c(3, 3, 2),
factors="all",
varNames=c("A",  "B", "Sex"))

full
A B Sex
1  1 1   1
2  2 1   1
3  3 1   1
4  1 2   1
5  2 2   1
6  3 2   1
7  1 3   1
8  2 3   1
9  3 3   1
10 1 1   2
11 2 1   2
12 3 1   2
13 1 2   2
14 2 2   2
15 3 2   2
16 1 3   2
17 2 3   2
18 3 3   2

frac.D <- optFederov(  ~ A + B + Sex,
data=full,
nTrials=9,  criterion="D")


This makes for a D-optimal half fraction, assuming a linear model without interactions. You can try with first argument ~ (A + B + Sex)^2 for an optimal fraction assuming a model with interactions. We can list the generated design with

 frac.D
$D [1] 0.2594239$A
[1] 5.666667

$Ge [1] 0.857$Dea
[1] 0.846

$design A B Sex 2 2 1 1 3 3 1 1 4 1 2 1 5 2 2 1 7 1 3 1 9 3 3 1 10 1 1 2 15 3 2 2 17 2 3 2$rows
[1]  2  3  4  5  7  9 10 15 17


or make a fuller evaluation with

eval.design(  ~ A + B + Sex,,
design=frac.D$$design, confounding=TRUE, variances=TRUE, X=full) . +$$confounding
[,1] [,2] [,3] [,4] [,5]    [,6]
(Intercept) -1.0000  0.5  0.5  0.5  0.5  0.3333
A2           0.5455 -1.0 -0.5  0.0  0.0  0.0000
A3           0.5455 -0.5 -1.0  0.0  0.0  0.0000
B2           0.5455  0.0  0.0 -1.0 -0.5  0.0000
B3           0.5455  0.0  0.0 -0.5 -1.0  0.0000
Sex2         0.2727  0.0  0.0  0.0  0.0 -1.0000

$determinant [1] 0.2594239$A
[1] 5.666667

$I [1] 6.25$Geff
[1] 0.857

$Deffbound [1] 0.846$diagonality
[1] 0.836

\$gmean.variances
[1] 5.664525


AlgDesign comes with a vignette you should study! Also have a look at the CRAN Task View.