[R] residuals from lm
CharlieTheBrown77 at gmail.com
Mon Jul 2 18:52:41 CEST 2012
As you are likely thinking: this doesn't belong here (It just occurred to
me), I am questioning what I did, not the output of lm()
But if someone knows why I am wrong please let me know.
> 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.
> 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)) - H) %*% Y
> # be equal to this:
> # ???
> # thanks
View this message in context: http://r.789695.n4.nabble.com/residuals-from-lm-tp4635155p4635161.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help