Partial least square error

3 visualizzazioni (ultimi 30 giorni)
Nital Patel
Nital Patel il 31 Mar 2020
Risposto: Chuan Wang il 20 Lug 2021
When I am trying to run the following code the following error occures. what is the reason?
x=load('CODTOCTDS.mat');
y=load('COD.mat');
[XL,YL,XS,YS,BETA,PCTVAR,MSE,stats] = plsregress(x,y)
Error using sum
Invalid data type. First argument must be numeric or logical.
Error in mean (line 127)
y = sum(x, dim, flag) ./ mysize(x,dim);
Error in plsregress (line 176)
meanX = mean(X,1);
Error in CODpred (line 4)
[XL,YL,XS,YS,BETA,PCTVAR,MSE,stats] = plsregress(x,y)

Risposte (2)

Umar farooq Mohammad
Umar farooq Mohammad il 31 Mar 2020
As per the error, it is failing at the sum step. so i know some if the simmilar error due to my previous experience.
In your data you might be having an cell array so You would need to convert the cell array into a double array using cell2mat or something similar. Please check if this helps!!
Or else please share your data which you are trying to load so that it will give a clear picture to help..

Chuan Wang
Chuan Wang il 20 Lug 2021
I also have a similar error when I do the following:
X=readtable('X.xlsx','VariableNamesRange','A2:A301',...
'VariableNamesRange','B1:HZ1','DataRange','B2:HZ301');
Y=readtable('Y.xlsx','VariableNamesRange','A2:A301',...
'VariableNamesRange','B1:B1','DataRange','B2:B301');
[XL,YL,XS,YS,beta,PCTVAR,MSE,stats] = plsregress(X,Y,10);
The error messages are:
Error using sum
Invalid data type. First argument must be numeric or logical.
Error in mean (line 127)
y = sum(x, dim, flag) ./ mysize(x,dim);
Error in plsregress (line 176)
meanX = mean(X,1);
Error in PLSregression (line 7)
[XL,YL,XS,YS,beta,PCTVAR,MSE,stats] = plsregress(X,Y,10);
Does anyone know how to solve the problem?
In the Y cells, there are blanks in the data. Does this cause the problem? If yes, how to handle this?
Thanks,
CB

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by