# Choosing the number of PLSR components

I am trying to choose how many components to retain in my PLSR. My total variance explained for the response variable is only about 30%, and the first 2 components explain 99% of this. Intuitively I know I should just run the model with the first 2 components, but is there a more rigorous method I can apply? Does the Kaiser-Guttman or scree test apply here since the PLSR computes singular values rather than eigenvalues?

• Cross-validation? – amoeba Jan 2 '17 at 18:16

Use cross-validation.

A quick example: for each number of components(by the way they are called latent variables in PLS unlike principle component in PCA), remove the first sample from your data, and with the remaining data set construct a full PLS model. Use that model to predict the removed sample. Then put the removed sample back remove the next one and predict it and so on. This type of cross-validation is called leave-one-out cross validation.

Finally you will have a prediction for each sample and their real values. Using that information calculate an error which is basically the difference of predicted vs real value or the square of that difference.

Repeat this for each number of components. You can now draw a graph which has number of components in X axis and corresponding errors on Y axis. As a rule of thumb you should NOT go ahead and select the component(latent variable) yielding the least error because it may overfit. You should choose where the drop in error values are not significant any more. Another common case is that: there might be a point where the error values increase. Choose a point right before that increment.

Reference for graph: Brereton, Richard G. Applied chemometrics for scientists. John Wiley & Sons, 2007.

• +1 for cross-validation advice. But is this a plot obtained with some real data or just an illustration sketch? If it's a real plot then I am surprised that there does not seem to be a minimum: the curve is decreasing all the way. – amoeba Jan 26 '17 at 9:01
• This is from a real data. You are right, the PLS models do not behave "ideally" in my case. However, this illustrates an dramatic drop until 8th LV whereas, for instance, with 12 LV there is a lower error but choosing 12 LV is not a good idea, at least in my opinion. Should I replace the graph? – theGD Jan 26 '17 at 9:07
• If it's a real then it's real, it's just that for this graph one could argue that selecting all components (which is equivalent to not using PLS at all but simply using standard OLS regression) is actually beneficial... – amoeba Jan 26 '17 at 9:09
• Well, you are right once again. It is better to be clear. I have updated my answer with a new graph which explains my point better. – theGD Jan 26 '17 at 9:31