# Doegen

## Contents

### Purpose

Generate a Design of Experiments (DOE) DataSet object.

### Synopsis

- [doe,msg] = doegen(type,factors,scales,levels,options)

### Description

Creates a Design of Experiements of a specified type with named factors designed with a specified number of levels and coding of those levels at specified values or categorical names.

Designs can be a mix of numerical and categorical factors. The type of factor is defined by the "scales" input which specifies either the minimum and maximum values to use (numerical factor), the exact numerical values to be used (numerical factor), or the names of the categories (categorical factor).

Some design types have a specific number of levels which they allow. If one or more categorical factors requires a different number of levels than the design allows, the design is calculated without these categorical factor(s) and then replicated for all levels of the factor(s). This may increase the number of required samples beyond what is expected but provides full resolution of categorical factors in designs which would otherwise be incompatible with them.

#### Inputs

**type**= Type of design to create:

- 'full' = full factorial
- '2' = 1/2 factorial (2-level)
- '4' = 1/4 factorial (2-level)
- '8' = 1/8 factorial (2-level)
- '16' = 1/16 factorial (2-level)
- 'face' = Face-centered Central Composite (3-level)
- 'sphere' = Sperical Central Composite (5-level)
- 'box' = Box-Behnken Design (3-level)

#### Optional Inputs

**factors**= Cell array indicating the name(s) of the factors. The number of strings indicates the total number of factors in the design. If factors is omitted, "levels" or (scales) must be supplied (see below) and simple strings will be provided for each factor's name.

**scales**= Cell array containing either double vectors (for numerical factors) or cell arrays of strings (for categorical factors).**Numerical factors:**the doubles indicate the minimum and maximum values for each factor's levels (if only two values are in a given cell) or the specific level values (if more than two values are in the cell). If only two values are supplied, the number of levels to use must be passed in the (levels) input.**Categorical factors:**number of strings in the cell array defines the number of levels for the given factor.

**Example:**`{ [5 8 9 10] [ 100 200 ] {'treat A' 'treat B'} }`- Defines scaling for three factors. The first two are numerical factors: one with four specific levels (equal to 5 8 9 10), one with a min/max of 100 and 200, and a third categorical factor with the labels indicated for the two categories. If using a full-factorial design and the second factor should have more than two levels, the (levels) input must be provided (see below.) If scales is omitted, "levels" must be supplied (see below).

**levels**= Vector specifying the number of levels to use for each factor in a full-factorial design. This can either be supplied in place of the (scales) input, or along with (scales) when scales is only the minimum and maximum values for each factor.- If (scales) is not provided, this defines the total number of numeric factors and number of levels for each factor. For example:

`[2 3 3]`- indicates one factor of 2 levels and two factors of 3 levels each.

- If scales is provided as min/max values, then levels defines how many levels to have in each factor between those min/max values. This vector must be equal in length to the total number of factors (including both numeric and categorical factors) even though the values defined here for categorical factors will not be used.
**Example:**, if (scales) defines three factors:

`{ [5 8 9 10] [ 100 200 ] {'treat A' 'treat B'} }`- then factors 1 and 3 are unambiguously defined as having 4 and 2 levels, respectively. If the (levels) input is not provided, it will be assumed that factor 2 should have only two levels. If factor 2 should have more levels, for example, 3 levels at 100 150 and 200, the levels input needs to be defined as:
`[ 4 3 2]`

- Notice that this input can be completely dropped if the (scales) input specifically defines the number and values of all factor levels. However, it must be supplied if no scales are supplied.

#### Outputs

**doe**= Design of Experiments DataSet object containing classes, labels, and additional userdata information on the design.**msg**= If requested as an output, design errors (such as incompatible settings between design type and number of levels or factor types) are squelched and returned in this string. When an error is discovered, the (doe) output will be empty. Errors in input format or general usage are still thrown as standard errors.

### Options

options = a structure array with the following fields:

**interactions**: [1] Specify what type interactions to include in the final DOE as a scalar numerical value indicating the highest number of interacting factors to include (A value of 1 (one) indicates no interactions) or as a cell array of numerical vectors indicating which column(s) should be combined an in what way(s) to create the interaction terms. Example:`{ [1] [2] [3] [1 3] }`**randomize**: [ 'no' | {'yes'} ] Specify whether to reorder the output design to a randomized order. Whether or not this randomize option is used, a randomized axisscale is created in the output which can be used to reorder the experiments. In addition, an "original order" axisscale is also created to allow re-ordering to the original unrandomized DOE order.**centerpoints**: [0] Number of additional center points to add to the design. Note that center points are calculated for all numerical factors (whether or not they had a center point to begin with) and these points are replicated for all combinations of categorical factors. Thus, the total number of center points added will be the product of the number requested times the number of combinations of categorical variables in the design.

### Example

Create a face-centered central composite design with one categorical factor named 'Processor' with categories 'J' and 'K', and two numeric factors, one named 'ethylene %' at evenly spaced levels between 1 and 5 and one named 'butene %' at the specific levels 0, 4, and 6.

doe = doegen('face',{'Processor' 'ethylene %' 'butene %'},{{'J' 'K'} [1 5] [0 4 6] });

Create a 1/2 fractional factorial (3-1) screening design with the same factors except the butene is screened at only 0 and 6%.

doe = doegen('1/2',{'Processor' 'ethylene %' 'butene %'},{{'J' 'K'} [1 5] [0 6] });

Create a full-factorial design with the same factors but with specific levels for all factors. Note that ethylene % scales are given as min/max values of 1 and 5 but the (levels) input specifies that it should be evaluated at 4 levels. The other two factors are specifically defined at 2 and 3 levels both by their (scales) input as well as the (levels) input:

doe = doegen('full',{'Processor' 'ethylene %' 'butene %'},{{'J' 'K'} [1 5] [0 3 6] },[2 4 3]);