DesignMatrix

DesignMatrix[{{x11,x12,,y1},{x21,x22,,y2},},{f1,f2,},{x1,x2,}]
constructs the design matrix for the linear model β0+β1 f1+β2 f2+.

Details and OptionsDetails and Options

  • DesignMatrix[{y1,y2,},{f1,f2,},x] assumes data of the form {{1,y1},{2,y2},}. »
  • With data in the form {{x_(11),x_(12),...,y_(1)},{x_(21),x_(22),...,y_(2)},...}, the number of coordinates xi1, xi2, should equal the number of variables xi.
  • The design matrix m is formed from the values of basis functions fi at data points in the form
  • DesignMatrix takes the following options:
  • IncludeConstantBasisTruewhether to include a constant basis function
    NominalVariablesNonevariables considered as nominal or categorical
    WorkingPrecisionAutomaticprecision used in internal computations
  • With the setting IncludeConstantBasis->False, the design matrix for a model of form β1 f1+β2 f2+ is constructed. »

ExamplesExamplesopen allclose all

Basic Examples  (3)Basic Examples  (3)

Design matrix for a linear model:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]//MatrixForm=

Add a quadratic term:

In[3]:=
Click for copyable input
Out[3]//MatrixForm=

Leave out the constant term:

In[4]:=
Click for copyable input
Out[4]//MatrixForm=

Design matrix with two predictor variables:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]//MatrixForm=

Include a product term:

In[3]:=
Click for copyable input
Out[3]//MatrixForm=

Assume predictor values 1, 2, :

In[1]:=
Click for copyable input
Out[1]//MatrixForm=
Introduced in 2008
(7.0)