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)
X |
|
---|
Returns the residual maker matrix \(\left( \mathbf{M} \right)\) .
Ivan Jacob Agaloos Pesigan
# Simple regression------------------------------------------------ X <- jeksterslabRdatarepo::wages.matrix[["X"]] X <- X[, c(1, ncol(X))] M <- M(X = X) str(M, list.len = 6)#> num [1:1289, 1:1289] 0.999224 -0.00077 -0.000775 -0.000783 -0.000777 ...# Multiple regression---------------------------------------------- X <- jeksterslabRdatarepo::wages.matrix[["X"]] # age is removed X <- X[, -ncol(X)] M <- M(X = X) str(M, list.len = 6)#> num [1:1289, 1:1289] 9.98e-01 -6.81e-04 5.85e-05 1.41e-03 -4.75e-04 ...