I am trying to understand the code for lm.ridge from the MASS package.
Here is the part I am having trouble understanding:
if(Inter <- attr(Terms, "intercept"))
{
Xm <- colMeans(X[, -Inter])
Ym <- mean(Y)
p <- p - 1
X <- X[, -Inter] - rep(Xm, rep(n, p))
Y <- Y - Ym
} else Ym <- Xm <- NA
Xscale <-
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 +
2 matches
Mail list logo