Statistics Toolbox | ![]() ![]() |
Transform a factor settings matrix to a design matrix.
Syntax
D = x2fx(X) D = x2fx(X,'model')
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 termsAlternatively 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 should be raised. This allows for models with polynomial terms of arbitrary order.
x2fx is a utility function for rstool
, regstats
, and cordexch
.
Example
x = [1 2 3;4 5 6]'; model = 'quadratic'; D = x2fx(x,model) D = 1 1 4 4 1 16 1 2 5 10 4 25 1 3 6 18 9 36
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
, cordexch
, rowexch
, regstats
![]() | weibstat | xbarplot | ![]() |