svkucheryavski / mdatools

R package for Multivariate Data Analysis
https://mda.tools
Other
33 stars 11 forks source link

Error: Local model inside cross-validation can not be computed with the same number of components as used for calibration. Limit the number by using parameter 'ncomp' and run the code again. #103

Closed rexdeng closed 2 years ago

rexdeng commented 2 years ago

Train dataset contains 14 concentrations and corresponding NIR spectra (14×1037). I wrote the following codes. library(mdatools) x=spec y=conc m=ipls(x,y,int.num = 200)

But when I run the code, I get an error: Error: Local model inside cross-validation can not be computed with the same number of components as used for calibration. Limit the number by using parameter 'ncomp' and run the code again. When I adjust some parameters (m=ipls(x,y,glob.ncomp = 3,int.num = 200,ncomp=3)), the following error message appears: Error in selectCompNum.pls(model, selcrit = ncomp.selcrit) : Can not estimate correct number of PLS components. What went wrong?

svkucheryavski commented 2 years ago

Hi, looks weird and I can not reproduce the problem with my data.

I can suggest to run the iPLS using full cross-validation. By default ipls() uses systematic split into 10 segments (venetian blinds) but you have only 14 measurements, it is too small for segmented cross-validation, so try to add: cv = 1 to you ipls call.

svkucheryavski commented 2 years ago

Have not heard anything from you since that, so I am closing the issue.