DesignMatrix
✖
DesignMatrix
constructs the design matrix for the linear model β0+β1 f1+β2 f2+….
Details and Options

- DesignMatrix[{y1,y2,…},{f1,f2,…},x] assumes data of the form {{1,y1},{2,y2},…}. »
- With data in the form
, 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:
-
IncludeConstantBasis True whether to include a constant basis function NominalVariables None variables considered as nominal or categorical WorkingPrecision Automatic precision used in internal computations - With the setting IncludeConstantBasis->False, the design matrix for a model of form β1 f1+β2 f2+⋯ is constructed. »
Examples
open allclose allBasic Examples (3)Summary of the most common use cases
Design matrix for a linear model:

https://wolfram.com/xid/0d6gptryqq-c983bo


https://wolfram.com/xid/0d6gptryqq-el342k


https://wolfram.com/xid/0d6gptryqq-pdx4af


https://wolfram.com/xid/0d6gptryqq-n0gkg

Design matrix with two predictor variables:

https://wolfram.com/xid/0d6gptryqq-cneqwe


https://wolfram.com/xid/0d6gptryqq-f288qe


https://wolfram.com/xid/0d6gptryqq-gffoa2

Assume predictor values 1, 2, …:

https://wolfram.com/xid/0d6gptryqq-fyzmy7

Scope (2)Survey of the scope of standard use cases
Use any numeric functions of the predictors:

https://wolfram.com/xid/0d6gptryqq-i7nkhf


https://wolfram.com/xid/0d6gptryqq-ewjki4

Get the design matrix using exact arithmetic:

https://wolfram.com/xid/0d6gptryqq-b8bq5b


https://wolfram.com/xid/0d6gptryqq-g80850


https://wolfram.com/xid/0d6gptryqq-dmlo52

Use arbitrary-precision arithmetic:

https://wolfram.com/xid/0d6gptryqq-gxom8

Use fixed 24-digit precision arithmetic:

https://wolfram.com/xid/0d6gptryqq-hv6cui

Options (3)Common values & functionality for each option
IncludeConstantBasis (1)
NominalVariables (2)
Treat x as a numeric variable:

https://wolfram.com/xid/0d6gptryqq-6jf3q

https://wolfram.com/xid/0d6gptryqq-bcndyw


https://wolfram.com/xid/0d6gptryqq-ga20p2


Use nominal variables that are not numeric:

https://wolfram.com/xid/0d6gptryqq-ezwp9p



https://wolfram.com/xid/0d6gptryqq-dvr0zy


Treat all predictors as nominal:

https://wolfram.com/xid/0d6gptryqq-bp7prx


Properties & Relations (1)Properties of the function, and connections to other functions
DesignMatrix constructs the design matrix used by LinearModelFit:

https://wolfram.com/xid/0d6gptryqq-iec2z9


https://wolfram.com/xid/0d6gptryqq-9aa8q


https://wolfram.com/xid/0d6gptryqq-jnxrgq

https://wolfram.com/xid/0d6gptryqq-9ucpk

The matrix is the same for GeneralizedLinearModelFit:

https://wolfram.com/xid/0d6gptryqq-dvgeq

https://wolfram.com/xid/0d6gptryqq-fzifxk

Wolfram Research (2008), DesignMatrix, Wolfram Language function, https://reference.wolfram.com/language/ref/DesignMatrix.html.
Text
Wolfram Research (2008), DesignMatrix, Wolfram Language function, https://reference.wolfram.com/language/ref/DesignMatrix.html.
Wolfram Research (2008), DesignMatrix, Wolfram Language function, https://reference.wolfram.com/language/ref/DesignMatrix.html.
CMS
Wolfram Language. 2008. "DesignMatrix." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/DesignMatrix.html.
Wolfram Language. 2008. "DesignMatrix." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/DesignMatrix.html.
APA
Wolfram Language. (2008). DesignMatrix. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DesignMatrix.html
Wolfram Language. (2008). DesignMatrix. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DesignMatrix.html
BibTeX
@misc{reference.wolfram_2025_designmatrix, author="Wolfram Research", title="{DesignMatrix}", year="2008", howpublished="\url{https://reference.wolfram.com/language/ref/DesignMatrix.html}", note=[Accessed: 01-April-2025
]}
BibLaTeX
@online{reference.wolfram_2025_designmatrix, organization={Wolfram Research}, title={DesignMatrix}, year={2008}, url={https://reference.wolfram.com/language/ref/DesignMatrix.html}, note=[Accessed: 01-April-2025
]}