Instatistics and in particular inregression analysis, adesign matrix, also known asmodel matrix orregressor matrix and often denoted byX, is amatrix of values ofexplanatory variables of a set of objects. Each row represents an individual object, with the successive columns corresponding to the variables and their specific values for that object. The design matrix is used in certainstatistical models, e.g., thegeneral linear model.[1][2][3] It can containindicator variables (ones and zeros) that indicate group membership in anANOVA, or it can contain values ofcontinuous variables.
The design matrix contains data on theindependent variables (also called explanatory variables), in a statistical model that is intended to explain observed data on a response variable (often called adependent variable). The theory relating to such models uses the design matrix as input to somelinear algebra : see for examplelinear regression. A notable feature of the concept of a design matrix is that it is able to represent a number of differentexperimental designs and statistical models, e.g.,ANOVA,ANCOVA, and linear regression.[citation needed]
The design matrix is defined to be a matrix such that (thejth column of theith row of) represents the value of thejth variable associated with theith object.
A regression model may be represented via matrix multiplication as
whereX is the design matrix, is a vector of the model's coefficients (one for each variable), is a vector of random errors with mean zero, andy is the vector of predicted outputs for each object.
The design matrix has dimensionn-by-p, wheren is the number of samples observed, andp is the number of variables (features) measured in all samples.[4][5]
In this representation different rows typically represent different repetitions of an experiment, while columns represent different types of data (say, the results from particular probes). For example, suppose an experiment is run where 10 people are pulled off the street and asked 4 questions. The data matrixM would be a 10×4 matrix (meaning 10 rows and 4 columns). The datum in rowi and columnj of this matrix would be the answer of theith person to thejth question.
The design matrix for anarithmetic mean is acolumnvector of ones.
This section gives an example ofsimple linear regression—that is, regression with only a single explanatory variable—with seven observations.The seven data points are {yi,xi}, fori = 1, 2, …, 7. The simple linear regression model is
where is they-intercept and is the slope of the regression line. This model can be represented in matrix form as
where the first column of 1s in the design matrix allows estimation of they-intercept while the second column contains thex-values associated with the correspondingy-values. The matrix whose columns are 1's andx's in this example is the design matrix.
This section contains an example ofmultiple regression with two covariates (explanatory variables):w andx.Again suppose that the data consist of seven observations, and that for each observed value to be predicted (), valueswi andxi of the two covariates are also observed. The model to be considered is
This model can be written in matrix terms as
Here the 7×3 matrix on the right side is the design matrix.
This section contains an example with a one-way analysis of variance (ANOVA) with three groups and seven observations. The given data set has the first three observations belonging to the first group, the following two observations belonging to the second group and the final two observations belonging to the third group.If the model to be fit is just the mean of each group, then the model is
which can be written
In this model represents the mean of theth group.
The ANOVA model could be equivalently written as each group parameter being an offset from some overall reference. Typically this reference point is taken to be one of the groups under consideration. This makes sense in the context of comparing multiple treatment groups to a control group and the control group is considered the "reference". In this example, group 1 was chosen to be the reference group. As such the model to be fit is
with the constraint that is zero.
In this model is the mean of the reference group and is the difference from group to the reference group. is not included in the matrix because its difference from the reference group (itself) is necessarily zero.