Calculates the residual maker matrix \(\left( \mathbf{M} \right)\) using $$ \mathbf{M} = \mathbf{I} - \mathbf{P} $$ where $$ \mathbf{P} = \mathbf{X} \left( \mathbf{X}^{T} \mathbf{X} \right)^{-1} \mathbf{X}^{T} . $$ The residual maker matrix \(\left( \mathbf{M} \right)\) transforms the \(\mathbf{y}\) vector to the vector of residuals \(\left( \mathbf{e} = \mathbf{My} \right)\) .

.M(X, P = NULL)

Arguments

X

n by k numeric matrix. The data matrix \(\mathbf{X}\) (also known as design matrix, model matrix or regressor matrix) is an \(n \times k\) matrix of \(n\) observations of \(k\) regressors, which includes a regressor whose value is 1 for each observation on the first column.

P

n by n numeric matrix. The \(n \times n\) projection matrix \(\left( \mathbf{P} \right)\).

Value

Returns the residual maker matrix \(\left( \mathbf{M} \right)\) .

Details

If P = NULL, the P matrix is computed using P().

References

Wikipedia: Projection Matrix

See also

Other projection matrix functions: .h(), M(), P(), h()

Author

Ivan Jacob Agaloos Pesigan