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:
LSQLIN

Subject: LSQLIN

From: anne smith

Date: 17 Feb, 2005 14:44:48

Message: 1 of 5

Hello,

I am using LSQLIN to solve X in the expression:
P(11,1)=M(11,9)*X(9,1)+Error(11,1)
subject to: sum(X)=1 and 0<=X<=1
In MATLAB:

X=LSQLIN(M,P,[],[],Aeq,beq,LB,UB);
Aeq=ones(1,9);
beq=1;
LB=0*ones(1,9);
UB=1*ones(1,9);

and then i am doing a linear transformation of my data by multiplying
P and M times a constant

(A.*P)=(A.*M)*X + Error

Where A is a vector storing 11 constants (recall that P and M have 11
rows)

my question is that i thought that this linear trasnformation should
NOT change my output since i am only introducing a constant factor
per equation but the regressions results for X are changing

can somebody explain me why?

thanks and sorry for being so bad in linear regressions....

Subject: LSQLIN

From: Donald R. Fredkin

Date: 17 Feb, 2005 20:38:57

Message: 2 of 5

"anne smith" <anne.smith@nospam.com> wrote in news:eefc33b.-1@webx.raydaftYaTP:

> Hello,
>
> I am using LSQLIN to solve X in the expression:
> P(11,1)=M(11,9)*X(9,1)+Error(11,1)
> subject to: sum(X)=1 and 0<=X<=1
> In MATLAB:
>
> X=LSQLIN(M,P,[],[],Aeq,beq,LB,UB);
> Aeq=ones(1,9);
> beq=1;
> LB=0*ones(1,9);
> UB=1*ones(1,9);
>
> and then i am doing a linear transformation of my data by multiplying
> P and M times a constant
>
> (A.*P)=(A.*M)*X + Error
>
> Where A is a vector storing 11 constants (recall that P and M have 11
> rows)
>
> my question is that i thought that this linear trasnformation should
> NOT change my output since i am only introducing a constant factor

Let's make the transformation a little more general: Take A to be
an 11 X 11 nonsingular matrix, and make the replacements
P -> A*P, M -> A*M. (In your case, A is diagonal, and the
elements on the diagonal are the elements of your vector A.) Now,
in your original problem you ask LSQLIN to minimize
(P - M*X)' * (P - M*X). In the new problem, you ask to minimize
(P - M*X)' * (A' * A) * (P - M*X), which is different. In your
case of a diagonal A, you have changed the weights in your least
squares problem.

The solution to the new problem is different from the solution to
the old one.

Subject: LSQLIN

From: anne smith

Date: 18 Feb, 2005 02:00:26

Message: 3 of 5

Donald R. Fredkin wrote:
>
>
> "anne smith" <anne.smith@nospam.com> wrote in
> news:eefc33b.-1@webx.raydaftYaTP:
>
>> Hello,
>>
>> I am using LSQLIN to solve X in the expression:
>> P(11,1)=M(11,9)*X(9,1)+Error(11,1)
>> subject to: sum(X)=1 and 0<=X<=1
>> In MATLAB:
>>
>> X=LSQLIN(M,P,[],[],Aeq,beq,LB,UB);
>> Aeq=ones(1,9);
>> beq=1;
>> LB=0*ones(1,9);
>> UB=1*ones(1,9);
>>
>> and then i am doing a linear transformation of my data by
> multiplying
>> P and M times a constant
>>
>> (A.*P)=(A.*M)*X + Error
>>
>> Where A is a vector storing 11 constants (recall that P and M
> have 11
>> rows)
>>
>> my question is that i thought that this linear trasnformation
> should
>> NOT change my output since i am only introducing a constant
> factor
>
> Let's make the transformation a little more general: Take A to be
> an 11 X 11 nonsingular matrix, and make the replacements
> P -> A*P, M -> A*M. (In your case, A is diagonal, and the
> elements on the diagonal are the elements of your vector A.) Now,
> in your original problem you ask LSQLIN to minimize
> (P - M*X)' * (P - M*X). In the new problem, you ask to minimize
> (P - M*X)' * (A' * A) * (P - M*X), which is different. In your
> case of a diagonal A, you have changed the weights in your least
> squares problem.
>
> The solution to the new problem is different from the solution to
> the old one.
>

hello and thanks for your answer,

still i have a problem to see why the problem has a different
solution because MATLAB is minimising
(P - M*X)' * (A' * A) * (P - M*X)
where A' * A is an scalar, just a factor so why the minimum of a
function and the minimum of the same function times a factor is
changing its position (X).
i thought that i was just going to get a bigger residual or RMSE but
no, the solution is different....

thanks,

anne

Subject: LSQLIN

From: Donald R. Fredkin

Date: 18 Feb, 2005 15:39:32

Message: 4 of 5

"anne smith" <anne.smith@nospam.com> wrote in news:eefc33b.1
@webx.raydaftYaTP:

> still i have a problem to see why the problem has a different
> solution because MATLAB is minimising
> (P - M*X)' * (A' * A) * (P - M*X)
> where A' * A is an scalar, just a factor so why the minimum of a
> function and the minimum of the same function times a factor is
> changing its position (X).
> i thought that i was just going to get a bigger residual or RMSE but
> no, the solution is different....
>

If A is a diagonal matrix (in other words, if your vector A is not
proportional to [1,1,1...]), A'*A is not a scalar. It is a diagonal matrix,
and the diagonal contains the weights you are giving the different
"equations".

Subject: LSQLIN

From: anne smith

Date: 20 Feb, 2005 10:28:54

Message: 5 of 5

Donald R. Fredkin wrote:
>
>
> "anne smith" <anne.smith@nospam.com> wrote in news:eefc33b.1
> @webx.raydaftYaTP:
>
>> still i have a problem to see why the problem has a different
>> solution because MATLAB is minimising
>> (P - M*X)' * (A' * A) * (P - M*X)
>> where A' * A is an scalar, just a factor so why the minimum of
a
>> function and the minimum of the same function times a factor is
>> changing its position (X).
>> i thought that i was just going to get a bigger residual or
RMSE
> but
>> no, the solution is different....
>>
>
> If A is a diagonal matrix (in other words, if your vector A is not
> proportional to [1,1,1...]), A'*A is not a scalar. It is a diagonal
> matrix,
> and the diagonal contains the weights you are giving the different
> "equations".
>

ok, MANY THANKS for your help. now i think that i understand it.
My results after multiplying times A (which stores a sort of
calibration/correcton coeficients) are better but i have a higher
RMSE error too. would you say that the weights coming from A are able
to detect extra noise in the data and that is why i have a high RMSE
but also better regression factors? or if the regression model is
having a high RMSE is just worse?

thanks!

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