The cordexch and rowexch functions provide two competing optimization algorithms for computing a D-optimal design given a model specification.

Both cordexch and rowexch are iterative algorithms. They operate by improving a starting design by making incremental changes to its elements. In the coordinate exchange algorithm, the increments are the individual elements of the design matrix. In row exchange, the elements are the rows of the design matrix. Atkinson and Donev [1] is a reference.

To generate a D-optimal design you must specify the number of inputs, the number of runs, and the order of the model you want to fit.

Both cordexch and rowexch take the following strings to specify the model:

  • 'linear' or 'l' - the default model with constant and first order terms
  • 'interaction' or 'i' - includes constant, linear, and cross product terms
  • 'quadratic' or 'q' - interactions plus squared terms
  • 'purequadratic' or 'p' - includes constant, linear and squared terms

Alternatively, you can use a matrix of integers to specify the terms. Details are in the help for the utility function x2fx .

For a simple example using the coordinate-exchange algorithm, consider the problem of quadratic modeling with two inputs. The model form is

Suppose we want the D-optimal design for fitting this model with nine runs.

  • settings = cordexch(2,9,'q') settings = -1 1 1 1 0 1 1 -1 -1 -1 0 -1 1 0 0 0 -1 0

We can plot the columns of settings against each other to get a better picture of the design.

For a simple example using the row-exchange algorithm, consider the interaction model with two inputs. The model form is

Suppose we want the D-optimal design for fitting this model with four runs.

  • [settings, X] = rowexch(2,4,'i') settings = -1 1 -1 -1 1 -1 1 1 X = 1 -1 1 -1 1 -1 -1 1 1 1 -1 -1 1 1 1 1

The settings matrix shows how to vary the inputs from run to run. The X  matrix is the design matrix for fitting the above regression model. The first column of  X is for fitting the constant term. The last column is the element-wise product of the second and third columns.

The associated plot is simple but elegant.