# DOE with MATLAB 1

## Contents |

## Abstract

This example shows how to do full and fractional factorial designs with MATLAB. Full and fractional factorial designs are commonly used for Design of Experiments (DOE) approaches, whereby we want to know how certain factors affect responses (both the degree and direction) AND which main effects (due to one factor) and interactions (due to multiple factors) are statistically significant.

Author(s): Mark A. Tschopp

## Full Factorial Design

Let's start with a full factorial design. Let's say that you have 4 different parameters (factors) that you would like to investigate their effect on some response. The easiest design is to consider each factor at two different levels: low and high OR -1 and +1. In order to consider every combination of these four factors at two levels requires 2^4 combinations (i.e., 2 levels ^ 4 factors). So, for MATLAB to construct a design for these different factors and factor levels, use the following script.

nfactor = 4; d = eye(nfactor); generators = fracfactgen(d,2^nfactor); [dfF,confounding] = fracfact(generators); |

Therefore the outputs of these lines of code are the following.

generators = 'a' 'b' 'c' 'd' dfF = -1 -1 -1 -1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 1 1 -1 1 -1 -1 -1 1 -1 1 -1 1 1 -1 -1 1 1 1 1 -1 -1 -1 1 -1 -1 1 1 -1 1 -1 1 -1 1 1 1 1 -1 -1 1 1 -1 1 1 1 1 -1 1 1 1 1 confounding = 'Term' 'Generator' 'Confounding' 'X1' 'a' 'X1' 'X2' 'b' 'X2' 'X3' 'c' 'X3' 'X4' 'd' 'X4' 'X1*X2' 'ab' 'X1*X2' 'X1*X3' 'ac' 'X1*X3' 'X1*X4' 'ad' 'X1*X4' 'X2*X3' 'bc' 'X2*X3' 'X2*X4' 'bd' 'X2*X4' 'X3*X4' 'cd' 'X3*X4' |

First, the variable 'generators' are used to produce the intended design matrix. In this case, we have four factors: a, b, c, and d. Second, the variable 'dfF' contains the different combinations of the levels (-1 and 1) of our four factors. Third, the variable 'confounding' contains the confounding effects. In the case of full factorials, there are no confounding effects. That is, notice that Term 'X1' is confounded with only 'X1'. In this case, 'X1' refers to the effect of Generator (factor) 'a' on our responses. When this is confounded with factors other than itself, this means that we cannot tell the difference between the effect caused by the Term and those effects that may be caused by the confounding effects. In addition, the terms 'X1*X2' denotes a two-factor interaction between X1 and X2.

This can also be used for multiple levels, i.e.,

## Fractional Factorial Design

Let's do a fractional factorial design. Let's continue with this example using 4 different factors at two different levels: -1 and +1. In this case, we don't want to run 16 experiments because it is expensive or time-consuming. So, we are going to run a fraction of these experiments, but still get information about how the factors affect the responses. In this example, we are designing a 2^(4-1) design (i.e., 2 levels ^ 4 factors with a reduction in combinations by one power = 8 combinations) - this is called a 1/2 fractional factorial design. For MATLAB to construct a design for these different factors and factor levels, use the following script.

nfactor = 4; d = eye(nfactor); generators = fracfactgen(d,[]); [dfF,confounding] = fracfact(generators); |

The [] in the fracfactgen operation automatically chooses the smallest design possible, in this case, the 2^4-1 design. The outputs of these lines of code are the following.

generators = 'a' 'b' 'c' 'abc' dfF = -1 -1 -1 -1 -1 -1 1 1 -1 1 -1 1 -1 1 1 -1 1 -1 -1 1 1 -1 1 -1 1 1 -1 -1 1 1 1 1 confounding = 'Term' 'Generator' 'Confounding' 'X1' 'a' 'X1' 'X2' 'b' 'X2' 'X3' 'c' 'X3' 'X4' 'abc' 'X4' 'X1*X2' 'ab' 'X1*X2 + X3*X4' 'X1*X3' 'ac' 'X1*X3 + X2*X4' 'X1*X4' 'bc' 'X1*X4 + X2*X3' 'X2*X3' 'bc' 'X1*X4 + X2*X3' 'X2*X4' 'ac' 'X1*X3 + X2*X4' 'X3*X4' 'ab' 'X1*X2 + X3*X4' |

First, notice that the 'generators' now contain a, b, c, and 'abc'. Notice that 'd' was replaced with 'abc' (i.e., 'd=abc'). So, the design uses a, b, and c to generate a full factorial, and the fourth at a level specified by the multiplicative product of a, b, and c. That is, the first row has values of -1, -1, -1 for a, b, c AND a value of -1 (-1*-1*-1) for the 'd' factor column. So, the variable 'dfF' contains 8 different combinations of the levels (-1 and 1) of our four factors. Notice that the variable 'confounding' now contains confounding effects. The two-factor interaction 'X1*X2' is now confounded with 'X3*X4'. So, in our results, we cannot tell the difference between whether a response is caused by 'X1*X2' or 'X3*X4'. However, in some cases, we may not care. Our single factor effects are still confounded with no other effects, so we can tell with statistic significance how they affect our responses. Plus, if we find that a two-factor effect is statistically significant, we can always run another design matrix to investigate whether it was really 'X1*X2' or if it was 'X3*X4'.

Another word for describing confounding effects that is often used is 'alias'.