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
  • 10,669
  • 8
  • 48
  • 97
Alina
  • 2,091
  • 2
  • 31
  • 65

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,346
  • 4
  • 25
  • 56