MATLAB Answers

Error using cross validation with plsregress

6 views (last 30 days)
bruno ebel
bruno ebel on 23 Sep 2020
Commented: bruno ebel on 29 Sep 2020 at 6:55
Hi everyone,
I am running a PLS regression and try to perform cross validation (k-fold) with matlab data.
load spectra
X = NIR;
y = octane;
[XL,yl,XS,YS,beta,PCTVAR,MSE] = plsregress(X,y,10,'CV',10);
Unfortunately, this error appear:
Could you explain to me how to solve it please?
Thank you in advance for your help.
Bruno

  4 Comments

Show 1 older comment
bruno ebel
bruno ebel on 24 Sep 2020
Thank you Adam for your kind answer. I've listed crossval function and and indeed, the main function of matlab is hidden by one of a toolbox:
>> which crossval -all
C:\Program Files\MATLAB\R2017a\toolbox\pls_toolbox_862\crossval.m
C:\Program Files\MATLAB\R2017a\toolbox\stats\stats\crossval.m % Shadowed
How can I fix it?
Thanks again,
Bruno
bruno ebel
bruno ebel on 24 Sep 2020
Ok, i've changed the order of the folder in the set up. Thanks again :-)

Sign in to comment.

Accepted Answer

Adam Danz
Adam Danz on 24 Sep 2020
Edited: Adam Danz on 28 Sep 2020 at 17:02
Based on the results of
which crossval -all
a function with the same name from a 3rd party toolbox (pls toolbox) is shadowing Matlab's crossval function which is called by plsregress.
If you are not using the pls toolbox, remove it from your Matlab path using
rmpath('C:\Program Files\MATLAB\R2017a\toolbox\pls_toolbox_862')
% or
rmpath([matlabroot, '\toolbox\pls_toolbox_862'])
If you are using the pls toolbox, you can use Julian's answer explained here
It grabs the function handle from Matlab's crossval function and assigns it to a variable that you can use in addition to the crossval version in pls toolbox.

  3 Comments

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!