0

I have following:

library(pls)
pcr(price ~ X, 6, data=cars, validation="CV")

it works, but because I have a small dataset, I cannot divide in into training and test and therefore I want to perform cross-validation and then extract predicted data for AUC and accuracy. But I could not find how I can extract the predicted data.Which parameter is it?

Christopher Bottoms
  • 11,218
  • 8
  • 50
  • 99
Alina
  • 2,191
  • 3
  • 33
  • 68

1 Answers1

1

When you fit a cross-validated principal component regression model with pcr() and the validation= argument, one of the components of the output list is called validation. This contains the results of the cross validation. This in turn is a list and it has a component called pred, which contains the cross-validated predictions.

An example adapted from example("pcr"):

sens.pcr <- pcr(sensory ~ chemical, data = oliveoil, validation = "CV")

sens.pcr$validation$pred

As an aside, it's generally a good idea to set your random seed immediately prior to performing cross validation to ensure reproducibility of your results.

Alex A.
  • 5,466
  • 4
  • 26
  • 56