I am running R 3.0.2 and using the PLS package to build partial least squares models. The problem I am having is that when I apply feature-scaling to my design matrix the resulting coefficient vector does not reproduce the predicted response values on my training and cross-validation samples. Here is my code:
model.train <- cppls(y ~ ., data = data.train, ncomp = 20, scale = TRUE, validation = "none", weights = w) yhat.train <- fitted(model.train) B <- coef(model.train, intercept = TRUE, ncomp = 20) yhat.cv <- predict(model.train, newdata = data.cv, ncomp = 20, type = "response")
If I then take the B vector and multiply by my design matrix, the resulting values do not equal the values generated by the
predict() functions; in other words,
Y != BX. However if I run the exact same code with
scale = FALSE in the
Y = BX.
My question is whether the
coef() function is simply failing to re-scale the betas, or if I'm making some error in my routine. I would really like to be able to apply feature-scaling to my design matrix, but I need the correct beta vector as an output. Would greatly appreciate any advice.