P: P Matrix

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

View source: R/proj.R

Description

Calculates the projection matrix ≤ft( \mathbf{P} \right) using

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

Usage

1
P(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.

Details

The projection matrix ≤ft( \mathbf{P} \right), also known as the hat matrix, transforms the \mathbf{y} vector to the vector of predicted values ≤ft( \mathbf{\hat{y}} = \mathbf{Py} \right).

Value

Returns the projection matrix ≤ft( \mathbf{P} \right).

Author(s)

Ivan Jacob Agaloos Pesigan

References

Wikipedia: Projection Matrix

See Also

Other projection matrix functions: .M(), .h(), M(), 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))]
P <- P(X = X)
str(P, list.len = 6)

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

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