Products
  • Wolfram|One

    The definitive Wolfram Language and notebook experience

  • Mathematica

    The original technical computing environment

  • System Modeler

    Multidomain modeling and simulation of complex systems

  • Compute ServicesUse with Mathematica and Wolfram|One
  • AI AccessUse with Mathematica and Wolfram|One
  • Finance Platform
  • Wolfram|Alpha Notebook Edition
  • Application Server
  • Enterprise Private Cloud
  • Wolfram Engine
  • Wolfram Player
  • Wolfram Cloud App
  • Wolfram Player App

More mobile apps

Wolfram|Alpha

  • Wolfram|Alpha Website
  • Wolfram|Alpha APIs

AI Products

  • Wolfram AI Ecosystem
  • Wolfram Foundation Tool
  • Wolfram Cloud MCP
  • Wolfram Local MCP
  • Agent One API
  • CAG Component APIs

Core Technologies of Wolfram Products

  • Wolfram Language
  • Computable Data
  • Wolfram Notebooks
  • Linguistic Understanding

Additional Deployment Options

  • Wolfram Cloud
  • Wolfram Web Engine
  • wolframscript
  • WSTPServer
  • Group & Organizational Licensing
  • All Products
Consulting & Solutions

We deliver solutions for the AI era—combining symbolic computation, data-driven insights and deep technical expertise

Wolfram Consulting

Data Science, Finance & Business

  • Artificial Intelligence
  • Data Science
  • Healthcare
  • Real Estate

Engineering

  • Civil Engineering
  • Automotive Engineering
  • Sustainable Energy

Science & Technology

  • AgTech
  • Biosciences
  • Environmental Science
  • Food Science
  • Quantum Computation
  • Social and Behavioral Sciences

More Wolfram Solutions

Technology for Education

  • Research Universities
  • Colleges & Teaching Universities
  • High Schools
  • Resources for Students

Education Initiatives

  • Next-Gen EdTech
  • Computer-Based Math

More Solutions for Education

  • Contact Us
Learning & Support

Get Started

  • Wolfram Language Introduction
  • Fast Intro for Programmers
  • Fast Intro for Math Students
  • Wolfram Language Documentation

More Learning

  • Highlighted Core Areas
  • Demonstrations
  • YouTube
  • Daily Study Groups
  • Wolfram Schools and Programs
  • Books

Grow Your Skills

  • Wolfram U

    Courses in computing, science, life and more

  • Community

    Learn, solve problems and share ideas.

  • Blog

    News, views and insights from Wolfram

  • Resources for

    Software Developers

Tech Support

  • Contact Us
  • Support FAQs
  • Support FAQs
  • Contact Us
Company
  • About Wolfram
  • Career Center
  • All Sites & Resources
  • Connect & Follow
  • Contact Us

Work with Us

  • Student Ambassador Initiative
  • Wolfram for Startups
  • Student Opportunities
  • Jobs Using Wolfram Language

Educational Programs for Adults

  • Summer School
  • Winter School

Educational Programs for Youth

  • Middle School Camp
  • High School Research Program
  • Computational Adventures

Read

  • Stephen Wolfram's Writings
  • Wolfram Blog
  • Wolfram Tech | Books
  • Wolfram Media
  • Complex Systems

Educational Resources

  • Wolfram MathWorld
  • Wolfram in STEM
  • Wolfram Challenges
  • Wolfram Problem Generator

Wolfram Initiatives

  • Wolfram Science
  • Wolfram Foundation
  • History of Mathematics Project

Events

  • Stephen Wolfram Livestreams
  • Online & In-Person Events
  • Contact Us
  • Connect & Follow
For AIs
  • Your Account
  • User Portal
  • Wolfram Cloud
  • Products
    • Wolfram|One
    • Mathematica
    • System Modeler
    • Compute ServicesUse with Mathematica and Wolfram|One
    • AI AccessUse with Mathematica and Wolfram|One
    • Finance Platform
    • Wolfram|Alpha Notebook Edition
    • Application Server
    • Enterprise Private Cloud
    • Wolfram Engine
    • Wolfram Player
    • Wolfram Cloud App
    • Wolfram Player App

    More mobile apps

    • Wolfram|Alpha
      • Wolfram|Alpha Website
      • Wolfram|Alpha APIs
    • AI Products
      • Wolfram AI Ecosystem
      • Wolfram Foundation Tool
      • Wolfram Cloud MCP
      • Wolfram Local MCP
      • Agent One API
      • CAG Component APIs
    • Core Technologies
      • Wolfram Language
      • Computable Data
      • Wolfram Notebooks
      • Linguistic Understanding
    • Additional Deployment Options
      • Wolfram Cloud
      • Wolfram Web Engine
      • wolframscript
      • WSTPServer
    • Group & Organizational Licensing
    • All Products
  • Consulting & Solutions
    • Wolfram Consulting

    Data Science, Finance & Business

    • Artificial Intelligence
    • Data Science
    • Healthcare
    • Real Estate

    Engineering

    • Civil Engineering
    • Automotive Engineering
    • Sustainable Energy

    Science & Technology

    • AgTech
    • Biosciences
    • Environmental Science
    • Food Science
    • Quantum Computation
    • Social and Behavioral Sciences

    More Wolfram Solutions

    Technology for Education

    • Research Universities
    • Colleges & Teaching Universities
    • High Schools
    • Resources for Students

    Education Initiatives

    • Next-Gen EdTech
    • Computer-Based Math

    More Solutions for Education

    • Contact Us
  • Learning & Support

    Get Started

    • Wolfram Language Introduction
    • Fast Intro for Programmers
    • Fast Intro for Math Students
    • Wolfram Language Documentation

    Grow Your Skills

    • Wolfram U

      Courses in computing, science, life and more

    • Community

      Learn, solve problems and share ideas.

    • Blog

      News, views and insights from Wolfram

    • Resources for

      Software Developers
    • Tech Support
      • Contact Us
      • Support FAQs
    • More Learning
      • Highlighted Core Areas
      • Demonstrations
      • YouTube
      • Daily Study Groups
      • Wolfram Schools and Programs
      • Books
    • Support FAQs
    • Contact Us
  • Company
    • About Wolfram
    • Career Center
    • All Sites & Resources
    • Connect & Follow
    • Contact Us

    Work with Us

    • Student Ambassador Initiative
    • Wolfram for Startups
    • Student Opportunities
    • Jobs Using Wolfram Language

    Educational Programs for Adults

    • Summer School
    • Winter School

    Educational Programs for Youth

    • Middle School Camp
    • High School Research Program
    • Computational Adventures

    Read

    • Stephen Wolfram's Writings
    • Wolfram Blog
    • Wolfram Tech | Books
    • Wolfram Media
    • Complex Systems
    • Educational Resources
      • Wolfram MathWorld
      • Wolfram in STEM
      • Wolfram Challenges
      • Wolfram Problem Generator
    • Wolfram Initiatives
      • Wolfram Science
      • Wolfram Foundation
      • History of Mathematics Project
    • Events
      • Stephen Wolfram Livestreams
      • Online & In-Person Events
    • Contact Us
    • Connect & Follow
  • For AIs
  • Wolfram Cloud
  • Your Account
  • User Portal
Wolfram Language & System Documentation Center
DesignMatrix
  • See Also
    • LinearModelFit
    • GeneralizedLinearModelFit
    • LogitModelFit
    • ProbitModelFit
    • LeastSquares
  • Related Guides
    • Statistical Model Analysis
    • See Also
      • LinearModelFit
      • GeneralizedLinearModelFit
      • LogitModelFit
      • ProbitModelFit
      • LeastSquares
    • Related Guides
      • Statistical Model Analysis

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 Options
Details and Options Details and Options
Examples  
Basic Examples  
Scope  
Options  
IncludeConstantBasis  
NominalVariables  
Properties & Relations  
See Also
Related Guides
History
Cite this Page
BUILT-IN SYMBOL
  • See Also
    • LinearModelFit
    • GeneralizedLinearModelFit
    • LogitModelFit
    • ProbitModelFit
    • LeastSquares
  • Related Guides
    • Statistical Model Analysis
    • See Also
      • LinearModelFit
      • GeneralizedLinearModelFit
      • LogitModelFit
      • ProbitModelFit
      • LeastSquares
    • Related Guides
      • Statistical Model Analysis

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 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:
  • IncludeConstantBasis Truewhether to include a constant basis function
    NominalVariables Nonevariables 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. »

Examples

open all close all

Basic Examples  (3)

Design matrix for a linear model:

Wolfram Language code: data = Table[{i, i ^ (3 / 2) + RandomReal[]}, {i, 5}]
Wolfram Language code: DesignMatrix[data, x, x]//MatrixForm

Add a quadratic term:

Wolfram Language code: DesignMatrix[data, {x, x ^ 2}, x]//MatrixForm

Leave out the constant term:

Wolfram Language code: DesignMatrix[data, {x, x ^ 2}, x, IncludeConstantBasis -> False]//MatrixForm

Design matrix with two predictor variables:

Wolfram Language code: data2 = Table[{RandomInteger[10], RandomInteger[10], RandomReal[]}, {10}]
Wolfram Language code: DesignMatrix[data2, {x, y}, {x, y}]//MatrixForm

Include a product term:

Wolfram Language code: DesignMatrix[data2, {x, y, x * y}, {x, y}]//MatrixForm

Assume predictor values 1, 2, …:

Wolfram Language code: DesignMatrix[RandomReal[10, 5], x, x]//MatrixForm

Scope  (2)

Use any numeric functions of the predictors:

Wolfram Language code: data = Table[{i, RandomReal[]}, {i, 5}]
Wolfram Language code: DesignMatrix[data, {Sin[x], Sqrt[x]}, x]//MatrixForm

Get the design matrix using exact arithmetic:

Wolfram Language code: data = RandomInteger[99, {5, 2}]
Wolfram Language code: DesignMatrix[data, {x, Sin[x]}, x] //MatrixForm

Use machine arithmetic:

Wolfram Language code: DesignMatrix[N[data], {x, Sin[x]}, x] //MatrixForm

Use arbitrary-precision arithmetic:

Wolfram Language code: DesignMatrix[N[data, 24], {x, Sin[x]}, x] //MatrixForm

Use fixed 24-digit precision arithmetic:

Wolfram Language code: DesignMatrix[data, {x, Sin[x]}, x, WorkingPrecision -> 24] //MatrixForm

Options  (3)

IncludeConstantBasis  (1)

A constant term is included by default:

Wolfram Language code: data = Table[{i, RandomReal[]}, {i, 10}]
Wolfram Language code: DesignMatrix[data, x, x]//MatrixForm

Construct a design matrix without a constant term:

Wolfram Language code: DesignMatrix[data, x, x, IncludeConstantBasis -> False]//MatrixForm

NominalVariables  (2)

Treat x as a numeric variable:

Wolfram Language code: data = {{0, 1.5}, {2, 2.3}, {2, 1.8}, {0, 2.5}};
Wolfram Language code: DesignMatrix[data, x, x]//MatrixForm

Treat x as nominal:

Wolfram Language code: DesignMatrix[data, x, x, NominalVariables -> x]//MatrixForm

Use nominal variables that are not numeric:

Wolfram Language code: DesignMatrix[{{a, 1.5}, {b, 2.3}, {b, 1.8}, {a, 2.5}}, x, x, NominalVariables -> x]//MatrixForm

Treat only x as nominal:

Wolfram Language code: DesignMatrix[{{a, 0, 1.5}, {b, 2, 2.3}, {a, 2, 1.8}, {b, 0, 2.5}}, {x, y}, {x, y}, NominalVariables -> x]//MatrixForm

Treat all predictors as nominal:

Wolfram Language code: DesignMatrix[{{a, 0, 1.5}, {b, 2, 2.3}, {a, 2, 1.8}, {b, 0, 2.5}}, {x, y}, {x, y}, NominalVariables -> All]//MatrixForm

Properties & Relations  (1)

DesignMatrix constructs the design matrix used by LinearModelFit:

Wolfram Language code: data = Table[{i, RandomReal[]}, {i, 5}]
Wolfram Language code: DesignMatrix[data, x, x]//MatrixForm
Wolfram Language code: lm = LinearModelFit[data, x, x];
Wolfram Language code: lm["DesignMatrix"]//MatrixForm

The matrix is the same for GeneralizedLinearModelFit:

Wolfram Language code: glm = GeneralizedLinearModelFit[data, x, x];
Wolfram Language code: glm["DesignMatrix"]//MatrixForm

See Also

LinearModelFit  GeneralizedLinearModelFit  LogitModelFit  ProbitModelFit  LeastSquares

Related Guides

    ▪
  • Statistical Model Analysis

History

Introduced in 2008 (7.0)

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.

CMS

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

BibTeX

@misc{reference.wolfram_2026_designmatrix, author="Wolfram Research", title="{DesignMatrix}", year="2008", howpublished="\url{https://reference.wolfram.com/language/ref/DesignMatrix.html}", note=[Accessed: 01-September-2026]}

BibLaTeX

@online{reference.wolfram_2026_designmatrix, organization={Wolfram Research}, title={DesignMatrix}, year={2008}, url={https://reference.wolfram.com/language/ref/DesignMatrix.html}, note=[Accessed: 01-September-2026]}

Top
Introduction for Programmers
Introductory Book
Wolfram Function Repository | Wolfram Data Repository | Wolfram Data Drop | Wolfram Language Products
Top
  • Products
  • Wolfram|One
  • Mathematica
  • AI Access
  • Compute Services
  • System Modeler

  • Wolfram|Alpha Notebook Edition
  • Wolfram|Alpha Pro
  • Mobile Apps

  • Wolfram Engine
  • Wolfram Player

  • Volume & Site Licensing
  • Server Deployment Options
  • Consulting
  • Wolfram Consulting
  • Repositories
  • Data Repository
  • Function Repository
  • Community Paclet Repository
  • Neural Net Repository
  • Prompt Repository

  • Wolfram Language Example Repository
  • Notebook Archive
  • Wolfram GitHub
  • Learning
  • Wolfram U
  • Wolfram Language Documentation
  • Webinars & Training
  • Educational Programs

  • Wolfram Language Introduction
  • Fast Introduction for Programmers
  • Fast Introduction for Math Students
  • Books

  • Wolfram Community
  • Wolfram Blog
  • Public Resources
  • Wolfram|Alpha
  • Wolfram Problem Generator
  • Wolfram Challenges

  • Computer-Based Math
  • Computational Thinking
  • Computational Adventures

  • Demonstrations Project
  • Wolfram Data Drop
  • MathWorld
  • Wolfram Science
  • Wolfram Media Publishing
  • Customer Resources
  • Store
  • Product Downloads
  • User Portal
  • Your Account
  • Organization Access

  • Support FAQ
  • Contact Support
  • Company
  • About Wolfram
  • Careers
  • Contact
  • Events
Wolfram Community Wolfram Blog
Legal & Privacy Policy
WolframAlpha.com | WolframCloud.com
© 2026 Wolfram
© 2026 Wolfram | Legal & Privacy Policy |
English