Statistics Toolbox    
x2fx

Transform a factor settings matrix to a design matrix

Syntax

Description

D = x2fx(X) transforms a matrix of system inputs, X, to a design matrix for a linear additive model with a constant term.

D = x2fx(X,'model') allows control of the order of the regression model. 'model' can be one of these strings:

'interaction'
Includes constant, linear, and cross product terms
'quadratic'
Includes interactions and squared terms
'purequadratic'
Includes constant, linear, and squared terms

Alternatively model can be a matrix of terms. In this case, each row of model represents one term. The value in a column is the exponent to which the same column in X for that term is raised, D(i,j) = prod(x(i,:).^model(j,:)). This allows for models with polynomial terms of arbitrary order.

The order of columns for a quadratic model is:

  1. Constant term
  2. Linear terms (the input X columns 1,2,...,k)
  3. Interaction terms formed by taking pairwise products of X columns (1,2), (1,3), ..., (1,k), (2,3), ..., (k-1,k)
  4. Squared terms in the order 1,2,...,k

Other models use a subset of these terms but keep them in this order.

x2fx is a utility function for rstool, regstats, and cordexch.

Examples

Example 1.

The first column is x to the 0th power. The second column is x to the 1st power. And the last column is x squared.

Example 2.

Let x1 be the first column of x and x2 be the second. Then the first column of D is the constant term, the second column is x1, the third column is x2, the fourth column is x1x2, the fifth column is x12, and the last columns is x22.

See Also
rstool, candexch, candgen, cordexch, rowexch, regstats


  wishrnd xbarplot