search for: tp4635155p4635161

Displaying 1 result from an estimated 1 matches for "tp4635155p4635161".

2012 Jul 02
3
residuals from lm
Hi, I was playing around with something else and I noticed this matrix code for residuals in a linear model doesn't say what lm() says. Please tell me if I am completely misguided here. data(mtcars) Y <- as.matrix(mtcars[,1]) X <- as.matrix(mtcars[,c(2:11)]) # shouldnt this: H <- X %*% solve(t(X) %*% X) %*% t(X) (diag(dim(H)[1]) - H) %*% Y # be equal to this: residuals(lm(Y~X))