M: M Matrix

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/proj.R

Description

Calculates the residual maker matrix ≤ft( \mathbf{M} \right) using

\mathbf{M} = \mathbf{I} - \mathbf{P}

where

\mathbf{P} = \mathbf{X} ≤ft( \mathbf{X}^{T} \mathbf{X} \right)^{-1} \mathbf{X}^{T} .

The residual maker matrix ≤ft( \mathbf{M} \right) transforms the \mathbf{y} vector to the vector of residuals ≤ft( \mathbf{e} = \mathbf{My} \right) .

Usage

1
M(X)

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.

Value

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

Author(s)

Ivan Jacob Agaloos Pesigan

References

Wikipedia: Projection Matrix

See Also

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Simple regression------------------------------------------------
X <- jeksterslabRdatarepo::wages.matrix[["X"]]
X <- X[, c(1, ncol(X))]
M <- M(X = X)
str(M, list.len = 6)

# Multiple regression----------------------------------------------
X <- jeksterslabRdatarepo::wages.matrix[["X"]]
# age is removed
X <- X[, -ncol(X)]
M <- M(X = X)
str(M, list.len = 6)

jeksterslabds/jeksterslabRlinreg documentation built on Jan. 7, 2021, 8:30 a.m.