[R] Help: PLSR

wu sz r.shengzhe at gmail.com
Sat Jul 23 01:30:27 CEST 2005


Hello,

I have a data set with 15 variables (first one is the response) and
1200 observations. Now I use pls package to do the plsr with cross
validation as below.

trainSet = as.data.frame(scale(trainSet, center = T, scale = T))
trainSet.plsr = mvr(formula, ncomp = 14, data = trainSet, method = "kernelpls",
                         CV = TRUE, validation = "LOO", model = TRUE, x = TRUE,
                          y = TRUE)

after that I wish to obtain the value of "se", estimated standard
errors of the estimates(cross validation), mentioned in the function
of MSEP, but not implemented yet, so I made the program by myself to
calculate it. The results I got seem not right, and I wonder which
step below is wrong.

y = trainSet.plsr$y
p = as.data.frame(trainSet.plsr$validation$pred)

i = 1; msep_element = matrix(nrow = 1200, ncol = 14)
while(i <= length(p)){
  msep_element[,i] = (p[i]-y)^2
  i = i + 1
}

msep = colMeans(msep_element)
msep_sd = sd(msep_element)

Then I compare "msep" with "trainSet.plsr$validation$MSEP", which are
the same, but the values of "msep_sd" seem much larger than I
expected, is it the same as "se"? If not, how to calculate "se" of
cross validation?

Thank you,
Shengzhe




More information about the R-help mailing list