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:
constrained regression/optimization

Subject: constrained regression/optimization

From: Jelena Ivanovic

Date: 31 Jan, 2013 19:15:09

Message: 1 of 6

Dear all,

I am relatively new Matlab user, and I need to find a solution for coefficients a and b in the following equation:

X=a*Y + (1-a) * [Z + b*Q + (1-b) * W]

where:

- X, Y, Z, Q and W are data vectors;
- constant should ideally be equal to zero (but this isn't necessary);
- 1-a, b and 1-b all need to be positive.

Is there maybe something that could be done with lsqlin from the Optimization toolbox?

Many thanks,

Jelena

Subject: constrained regression/optimization

From: Matt J

Date: 31 Jan, 2013 19:58:08

Message: 2 of 6

"Jelena Ivanovic" <ivanovic.jelena@yahoo.com> wrote in message <keefrt$m0f$1@newscl01ah.mathworks.com>...
> Dear all,
>
> I am relatively new Matlab user, and I need to find a solution for coefficients a and b in the following equation:
>
> X=a*Y + (1-a) * [Z + b*Q + (1-b) * W]
>
> where:
>
> - X, Y, Z, Q and W are data vectors;
> - constant should ideally be equal to zero (but this isn't necessary);
> - 1-a, b and 1-b all need to be positive.
>
> Is there maybe something that could be done with lsqlin from the Optimization toolbox?
==================

Yes. You can rewrite this as

 min. norm([Y Z Q W]*c - X)
 s.t.
  c(1)+c(2)=1;
  c(3)+c(4) - c(2)=0;
  c(i)>=0

Now it is exactly in the form requested by LSQLIN

Subject: constrained regression/optimization

From: Torsten

Date: 1 Feb, 2013 13:05:08

Message: 3 of 6

"Jelena Ivanovic" <ivanovic.jelena@yahoo.com> wrote in message <keefrt$m0f$1@newscl01ah.mathworks.com>...
> Dear all,
>
> I am relatively new Matlab user, and I need to find a solution for coefficients a and b in the following equation:
>
> X=a*Y + (1-a) * [Z + b*Q + (1-b) * W]
>
> where:
>
> - X, Y, Z, Q and W are data vectors;
> - constant should ideally be equal to zero (but this isn't necessary);
> - 1-a, b and 1-b all need to be positive.
>
> Is there maybe something that could be done with lsqlin from the Optimization toolbox?
>
> Many thanks,
>
> Jelena

Setting
c1=a and c2=(1-a)*b,
your expression for X becomes
X=c1*Y+(1-c1)*Z+c2*Q+(1-c1-c2)*W.
Thus you want to minimize the norm of
c1*(Y-Z-W)+c2*(Q-W)+(Z+W-X)
under the constraints
c1 >= 0
1-c1 >= 0
c2 >= 0
1-c1-c2 >= 0

After solving the above problem, you can recover a and b via
a=c1, b=c2/(1-c1)

Best wishes
Torsten.

Subject: constrained regression/optimization

From: Jelena Ivanovic

Date: 1 Feb, 2013 19:15:08

Message: 4 of 6

Thanks a lot!

Subject: constrained regression/optimization

From: Jelena Ivanovic

Date: 1 Feb, 2013 19:20:08

Message: 5 of 6

"Torsten" wrote in message <kegei4$2m1$1@newscl01ah.mathworks.com>...
> "Jelena Ivanovic" <ivanovic.jelena@yahoo.com> wrote in message <keefrt$m0f$1@newscl01ah.mathworks.com>...
> > Dear all,
> >
> > I am relatively new Matlab user, and I need to find a solution for coefficients a and b in the following equation:
> >
> > X=a*Y + (1-a) * [Z + b*Q + (1-b) * W]
> >
> > where:
> >
> > - X, Y, Z, Q and W are data vectors;
> > - constant should ideally be equal to zero (but this isn't necessary);
> > - 1-a, b and 1-b all need to be positive.
> >
> > Is there maybe something that could be done with lsqlin from the Optimization toolbox?
> >
> > Many thanks,
> >
> > Jelena
>
> Setting
> c1=a and c2=(1-a)*b,
> your expression for X becomes
> X=c1*Y+(1-c1)*Z+c2*Q+(1-c1-c2)*W.
> Thus you want to minimize the norm of
> c1*(Y-Z-W)+c2*(Q-W)+(Z+W-X)
> under the constraints
> c1 >= 0
> 1-c1 >= 0
> c2 >= 0
> 1-c1-c2 >= 0
>
> After solving the above problem, you can recover a and b via
> a=c1, b=c2/(1-c1)
>
> Best wishes
> Torsten.

Thanks, Torsten!

Subject: constrained regression/optimization

From: Jelena Ivanovic

Date: 1 Feb, 2013 19:22:07

Message: 6 of 6

Thanks a lot, Matt!

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