Why do I get different coefficients for each of these methods? Y <- matrix(c(136,144,145,169,176),byrow=F,5,1) X1 <- matrix(c(91,105,109,130,146),byrow=F,5,1) X2 <- matrix(c(11,13,17,19,23),byrow=F,5,1) cY <- scale(Y, scale=FALSE) sX1 <- scale(X1) sX2 <- scale(X2) library(MASS) lm.ridge(cY ~ sX1 + sX2, lambda = 100)
This yields different coefficients than what I get from this, which I thought should be identical (if I set the lambdas to 0 rather than 100 I get identical results): Xmat <- cbind(sX1, sX2) Ymat <- cbind(cY) XXI <- solve(t(Xmat)%*%Xmat + 100*diag(2)) XY <- t(Xmat)%*%Ymat (ridge.coef <- XXI%*%XY) Thanks, Jim ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.