Main Content


D-optimal design with fixed covariates


dCV = dcovary(nfactors,fixed)
[dCV,X] = dcovary(nfactors,fixed)
[dCV,X] = dcovary(nfactors,fixed,model)
[dCV,X] = dcovary(...,param1,val1,param2,val2,...)


dCV = dcovary(nfactors,fixed) uses a coordinate-exchange algorithm to generate a D-optimal design for a linear additive model with nfactors factors, subject to the constraint that the model include the fixed covariate factors in fixed. The number of runs in the design is the number of rows in fixed. The design dCV augments fixed with initial columns for treatments of the model terms.

[dCV,X] = dcovary(nfactors,fixed) also returns the design matrix X associated with the design.

[dCV,X] = dcovary(nfactors,fixed,model) uses the linear regression model specified in model. model is one of the following:

  • 'linear' — Constant and linear terms. This is the default.

  • 'interaction' — Constant, linear, and interaction terms

  • 'quadratic' — Constant, linear, interaction, and squared terms

  • 'purequadratic' — Constant, linear, and squared terms

The order of the columns of X for a full quadratic model with n terms is:

  1. The constant term

  2. The linear terms in order 1, 2, ..., n

  3. The interaction terms in order (1, 2), (1, 3), ..., (1, n), (2, 3), ..., (n – 1, n)

  4. The squared terms in order 1, 2, ..., n

Other models use a subset of these terms, in the same order.

Alternatively, model can be a matrix specifying polynomial terms of arbitrary order. In this case, model should have one column for each factor and one row for each term in the model. The entries in any row of model are powers for the factors in the columns. For example, if a model has factors X1, X2, and X3, then a row [0 1 2] in model specifies the term (X1.^0).*(X2.^1).*(X3.^2). A row of all zeros in model specifies a constant term, which can be omitted.

[dCV,X] = dcovary(...,param1,val1,param2,val2,...) specifies additional parameter/value pairs for the design. Valid parameters and their values are listed in the following table.


Lower and upper bounds for each factor, specified as a 2-by-nfactors matrix. Alternatively, this value can be a cell array containing nfactors elements, each element specifying the vector of allowable values for the corresponding factor.


Indices of categorical predictors.


Either 'on' or 'off' to control display of the iteration counter. The default is 'on'.


Handle to a function that excludes undesirable runs. If the function is f, it must support the syntax b = f(S), where S is a matrix of treatments with nfactors columns and b is a vector of Boolean values with the same number of rows as S. b(i) is true if the ith row S should be excluded.


Initial design as an mruns-by-nfactors matrix. The default is a randomly selected set of points.


Vector of number of levels for each factor.


Maximum number of iterations. The default is 10.


The value is a structure that contains options specifying whether to compute multiple tries in parallel, and specifying how to use random numbers when generating the starting points for the tries. Create the options structure with statset. Applicable statset parameters are:

  • 'UseParallel' — If true and if Parallel Computing Toolbox™ is installed, compute in parallel. If the Parallel Computing Toolbox is not installed, then computation occurs in serial mode. Default is false, meaning serial computation.

  • UseSubstreams — Set to true to compute in a reproducible fashion. Default is false. To compute reproducibly, set Streams to a type allowing substreams: 'mlfg6331_64' or 'mrg32k3a'.

  • Streams — A RandStream object or cell array of such objects. If you do not specify Streams, dcovary uses the default stream or streams. If you choose to specify Streams, use a single object except in the case

    • UseParallel is true

    • UseSubstreams is false

    In that case, use a cell array the same size as the Parallel pool.


Number of times to try to generate a design from a new starting point. The algorithm uses random points for each try, except possibly the first. The default is 1.


collapse all

The following example uses the dummyvar function to block an eight-run experiment into 4 blocks of size 2 for estimating a linear additive model with two factors:

fixed = dummyvar([1 1 2 2 3 3 4 4]);
dCV2 = dcovary(2,fixed(:,1:3),'linear')
dCV2 = 8×5

    -1     1     1     0     0
     1    -1     1     0     0
    -1    -1     0     1     0
     1     1     0     1     0
     1     1     0     0     1
    -1    -1     0     0     1
    -1     1     0     0     0
     1    -1     0     0     0

The first two columns of dCV2 contain the settings for the two factors; the last three columns are the dummy variable encodings for the four blocks.

Suppose you want a design to estimate the parameters in a three-factor linear additive model, with eight runs that necessarily occur at different times. If the process experiences temporal linear drift, you may want to include the run time as a variable in the model. Produce the design as follows:

time = linspace(-1,1,8)';
[dCV1,X] = dcovary(3,time,'linear')
dCV1 = 8×4

   -1.0000    1.0000    1.0000   -1.0000
    1.0000   -1.0000   -1.0000   -0.7143
   -1.0000   -1.0000   -1.0000   -0.4286
    1.0000   -1.0000    1.0000   -0.1429
    1.0000    1.0000   -1.0000    0.1429
   -1.0000    1.0000   -1.0000    0.4286
    1.0000    1.0000    1.0000    0.7143
   -1.0000   -1.0000    1.0000    1.0000

X = 8×5

    1.0000   -1.0000    1.0000    1.0000   -1.0000
    1.0000    1.0000   -1.0000   -1.0000   -0.7143
    1.0000   -1.0000   -1.0000   -1.0000   -0.4286
    1.0000    1.0000   -1.0000    1.0000   -0.1429
    1.0000    1.0000    1.0000   -1.0000    0.1429
    1.0000   -1.0000    1.0000   -1.0000    0.4286
    1.0000    1.0000    1.0000    1.0000    0.7143
    1.0000   -1.0000   -1.0000    1.0000    1.0000

The column vector time is a fixed factor, normalized to values between ±1. The number of rows in the fixed factor specifies the number of runs in the design. The resulting design dCV gives factor settings for the three controlled model factors at each time.

Extended Capabilities

Version History

Introduced before R2006a