Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
PLSREGRESS

Subject: PLSREGRESS

From: Frank Sabouri

Date: 3 Sep, 2010 01:09:04

Message: 1 of 6

Hello everybody,

Using this function "[XL,YL,XS,YS,B,PC,MSE,stats] = PLSREGRESS(x,y,2,'CV',5)", in that number of cross-validation is five, I would expect to get five different outputs for each output. For example I would like to extract these outputs [XL1, XL2...., and XL5], [YL1, YL2...., and YL5], and so on. Please let me know how I could extract these replicates from the function.

Thanks,
Frank

Subject: PLSREGRESS

From: Peter Perkins

Date: 3 Sep, 2010 15:03:06

Message: 2 of 6

On 9/2/2010 9:09 PM, Frank Sabouri wrote:
> Using this function "[XL,YL,XS,YS,B,PC,MSE,stats] =
> PLSREGRESS(x,y,2,'CV',5)", in that number of cross-validation is five, I
> would expect to get five different outputs for each output. For example
> I would like to extract these outputs [XL1, XL2...., and XL5], [YL1,
> YL2...., and YL5], and so on. Please let me know how I could extract
> these replicates from the function.

That's not how the CV input to PLSREGRESS works. You can, however, use
the CROSSVAL function to do what you want, by passing it a function that
calls PLSREGRESS and returns the outputs you want in a single vector.
CROSSVAL will return a 5xn matrix, which you can then take apart and
reshape to get the 5 sets of things you want.

Hope this helps.

Subject: PLSREGRESS

From: Frank Sabouri

Date: 3 Sep, 2010 17:22:06

Message: 3 of 6

Hi Peter,

I am using this function:

fun=@PLSREGRESS;
vals = crossval(fun,x,y,2);

>> size (x)
ans =
     50 18
>> size (y)
ans =
     50 18

??? Error using ==> crossval at 213
Data arguments X,Y,... must have the same
number of rows.

But, I got this error. Do you have any idea?

Thanks,
Frank

Peter Perkins <Peter.Perkins@MathRemoveThisWorks.com> wrote in message <i5r2na$bua$1@fred.mathworks.com>...
> On 9/2/2010 9:09 PM, Frank Sabouri wrote:
> > Using this function "[XL,YL,XS,YS,B,PC,MSE,stats] =
> > PLSREGRESS(x,y,2,'CV',5)", in that number of cross-validation is five, I
> > would expect to get five different outputs for each output. For example
> > I would like to extract these outputs [XL1, XL2...., and XL5], [YL1,
> > YL2...., and YL5], and so on. Please let me know how I could extract
> > these replicates from the function.
>
> That's not how the CV input to PLSREGRESS works. You can, however, use
> the CROSSVAL function to do what you want, by passing it a function that
> calls PLSREGRESS and returns the outputs you want in a single vector.
> CROSSVAL will return a 5xn matrix, which you can then take apart and
> reshape to get the 5 sets of things you want.
>
> Hope this helps.

Subject: PLSREGRESS

From: Peter Perkins

Date: 3 Sep, 2010 20:16:25

Message: 4 of 6

On 9/3/2010 1:22 PM, Frank Sabouri wrote:
> Hi Peter,
>
> I am using this function:
>
> fun=@PLSREGRESS;
> vals = crossval(fun,x,y,2);
>
>>> size (x)
> ans =
> 50 18
>>> size (y)
> ans =
> 50 18
>
> ??? Error using ==> crossval at 213
> Data arguments X,Y,... must have the same
> number of rows.
>
> But, I got this error. Do you have any idea?

Hard to say without knowing what version you have. That error seems
kind of unlikely on the face of it. I recommend that you set a
breakpoint in CROSSVAL where the error occurs, and see what is happening
in the debugger.

Subject: PLSREGRESS

From: Frank Sabouri

Date: 3 Sep, 2010 20:34:04

Message: 5 of 6


Peter Perkins <Peter.Perkins@MathRemoveThisWorks.com> wrote in message <i5rl2p$1u0$3@fred.mathworks.com>...
> On 9/3/2010 1:22 PM, Frank Sabouri wrote:
> > Hi Peter,
> >
> > I am using this function:
> >
> > fun=@PLSREGRESS;
> > vals = crossval(fun,x,y,2);
> >
> >>> size (x)
> > ans =
> > 50 18
> >>> size (y)
> > ans =
> > 50 18
> >
> > ??? Error using ==> crossval at 213
> > Data arguments X,Y,... must have the same
> > number of rows.
> >
> > But, I got this error. Do you have any idea?
>
> Hard to say without knowing what version you have. That error seems
> kind of unlikely on the face of it. I recommend that you set a
> breakpoint in CROSSVAL where the error occurs, and see what is happening
> in the debugger.

The version that I am using is 7.10.0.499 (R2010a).

Frank

Subject: PLSREGRESS

From: Tom Lane

Date: 7 Sep, 2010 13:59:24

Message: 6 of 6

>> > fun=@PLSREGRESS;
>> > vals = crossval(fun,x,y,2);
...
>> > ??? Error using ==> crossval at 213
>> > Data arguments X,Y,... must have the same
>> > number of rows.
>> >
>> > But, I got this error. Do you have any idea?

Frank, there are several things going on here. First, crossval wants a
function of data arguments that it can subset. It doesn't want the 2 in
there as an argument to be kept constant. You can make this into a function
of only data like this:

   @(x,y) plsregress(x,y,2)

But there are a couple of other things you'll need to do. First, if you use
the crossval(fun,x,y) form, then you need to supply fun as a function that
can take four arguments where the first two are the training data and the
next two are the test data, and it needs to return the criterion being
cross-validated, computed on the test data.

If you use the crossval('mse',x,y,'predfun',fun) form, then fun needs to
take three arguments and compute fitted values.

The plain plsregress function isn't suitable for this, as it returns x
loadings as the first output.

I hope this is helpful. I'm not sure what advice to give next, because I'm
not sure what criterion you want to study with your cross-validation. If
it's related to the mse output from plsregress, then you might want to write
a little function that calls plsregress, getting its six output arguments,
and returning as its output some function of the mse that plsregress
computes.

-- Tom

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us