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:
Multivariate multiple linear regression?

Subject: Multivariate multiple linear regression?

From: Aino

Date: 29 Jul, 2013 14:00:16

Message: 1 of 5

Hi,

how can i do multivariate multiple linear regression with Matlab? I have four dependent (four Ys) and four independent (four Xs) variables. I believe that regress can do multiple regression (several Xs, one Y), and mvregress can do multivariate regression (several Ys, one X), but these doesn't help me much.

Thanks,
Aino

Subject: Multivariate multiple linear regression?

From: dpb

Date: 29 Jul, 2013 14:24:37

Message: 2 of 5

On 7/29/2013 9:00 AM, Aino wrote:
> Hi,
>
> how can i do multivariate multiple linear regression with Matlab? I have
> four dependent (four Ys) and four independent (four Xs) variables. I
> believe that regress can do multiple regression (several Xs, one Y), and
> mvregress can do multivariate regression (several Ys, one X), but these
> doesn't help me much.

My reading of

doc mvgress

leads me to believe your second categorization (mult-Y, 1-X) is in
error. Read it again more carefully. I've not used it, but surely
looks to me like it'll handle it if you set the X/Y up correctly.

Failing that, you can always write the design matrix explicitly and use
backslash to solve the OLS equations assuming your design is
non-singular and of sufficient rank.

--

Subject: Multivariate multiple linear regression?

From: Aino

Date: 29 Jul, 2013 15:10:15

Message: 3 of 5

dpb <none@non.net> wrote in message <kt5tvc$f6k$1@speranza.aioe.org>...
> On 7/29/2013 9:00 AM, Aino wrote:
> > Hi,
> >
> > how can i do multivariate multiple linear regression with Matlab? I have
> > four dependent (four Ys) and four independent (four Xs) variables. I
> > believe that regress can do multiple regression (several Xs, one Y), and
> > mvregress can do multivariate regression (several Ys, one X), but these
> > doesn't help me much.
>
> My reading of
>
> doc mvgress
>
> leads me to believe your second categorization (mult-Y, 1-X) is in
> error. Read it again more carefully. I've not used it, but surely
> looks to me like it'll handle it if you set the X/Y up correctly.
>
> Failing that, you can always write the design matrix explicitly and use
> backslash to solve the OLS equations assuming your design is
> non-singular and of sufficient rank.
>
> --
>

Thank you for your quick reply! I read the instruction more carefully and you seem to be right, mvregress can do multivariate multiple regression. However, I still need to figure out how to construct the "design matrix".

-Aino

Subject: Multivariate multiple linear regression?

From: dpb

Date: 29 Jul, 2013 20:16:16

Message: 4 of 5

On 7/29/2013 10:10 AM, Aino wrote:
...

> Thank you for your quick reply! I read the instruction more carefully
> and you seem to be right, mvregress can do multivariate multiple
> regression. However, I still need to figure out how to construct the
> "design matrix".

Well, only you know what you want as the model...

--

Subject: Multivariate multiple linear regression?

From: Aino

Date: 30 Jul, 2013 11:53:10

Message: 5 of 5

dpb <none@non.net> wrote in message <kt6iil$dum$1@speranza.aioe.org>...
> On 7/29/2013 10:10 AM, Aino wrote:
> ...
>
> > Thank you for your quick reply! I read the instruction more carefully
> > and you seem to be right, mvregress can do multivariate multiple
> > regression. However, I still need to figure out how to construct the
> > "design matrix".
>
> Well, only you know what you want as the model...
>
> --

I think I thought that the design matrix was something mystical because of the eye-matrix that is part of the design matrix in the mvregress example. I found a function that creates a design matrix from a predictor matrix, x2fx. If 'interaction' is the right model for my case, then does this look right:

x=...;%prediction matrix, n x p
Y=...;%responces matrix, n x d
x=x2fx(x,'interaction');
[Yrow,Ycol]=size(Y);
X=cell(Yrow,1);
for j=1:Yrow
    X{j}=[repmat(x(j,:),Ycol,1)];
end
[beta]=mvregress(X,Y);


-Aino

Tags for this Thread

No tags are associated with 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