hatMatrix {optR} | R Documentation |
Function determines the Hat matrix or projection matrix for given X
Description
Function hatMatrix determines the projection matrix for X from the form yhat=Hy. The projection matrix defines the influce of each variable on fitted value The diagonal elements of the projection matrix are the leverages or influence each sample has on the fitted value for that same observation. The projection matrix is evaluated with I.I.D assumtion ~N(0, 1)
Usage
hatMatrix(X, covmat = NULL)
Arguments
X |
: Input Matrix |
covmat |
: covariance matrix for error, if the error are correlated for I.I.D covmat will be NULL matrix |
Value
X: Projection Matrix
Examples
X<-matrix(c(6,-4,1, -4,6,-4,1,-4,6), nrow=3,ncol=3, byrow = TRUE)
covmat <- matrix(rnorm(3 * 3), 3, 3)
H<-hatMatrix(X)
H<-hatMatrix(X, covmat)
diag(H)
[Package optR version 1.2.5 Index]