Finding the least square solution with only positive coefficients

Click For Summary

Discussion Overview

The discussion revolves around finding a least squares solution for a system of equations represented by Ax = b, where the solution x must contain only positive coefficients. Participants explore methods to achieve this under the constraints of their specific problem, which involves measured weights of products and component weights.

Discussion Character

  • Exploratory
  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • Jocke inquires about methods to ensure all values in the least squares solution x are positive, given that the standard least squares solution yields negative values.
  • One participant suggests that since there is an explicit formula for the least squares solution, achieving all positive entries may require a change of basis, which could complicate the problem.
  • Jocke elaborates that the matrix A represents component amounts and b represents measured product weights, indicating the context of the problem.
  • Another participant questions the correlation of fits, suggesting that a correlation coefficient less than 0.9 might indicate other issues affecting the results.
  • Jocke shares that he has tried various methods in Matlab, including lsqnonneg, which provides non-negative solutions but does not yield satisfactory results.
  • Concerns are raised about high correlations among components and the potential rank deficiency of matrix A, which Jocke attempts to address by adding additional measurements.

Areas of Agreement / Disagreement

Participants express differing views on the feasibility of obtaining a least squares solution with only positive coefficients. There is no consensus on the best approach, and multiple competing methods and concerns are presented.

Contextual Notes

Participants note limitations related to the rank deficiency of matrix A and the potential impact of correlations among components on the least squares solution. The discussion includes unresolved mathematical steps and assumptions regarding the data and methods used.

Who May Find This Useful

This discussion may be of interest to those working with least squares problems in applied mathematics, data fitting, or optimization, particularly in contexts requiring non-negative solutions.

Marvin_MKII
Messages
3
Reaction score
0
Hi everyone.

Is there any way to set demands on least square solutions?

I have an equation on the form Ax=b, which is solved for x as:

x=(A'*A)^-1*A'*b

I do know for a fact that all values in x should be positive, but the least square solution for my particular system contains a number of negative x-values.
Is there some way to find the least square solution with only positive coefficients?

Thanks in advance
Jocke
 
Physics news on Phys.org
Hi Jocke,

It seems to me that since you have an explicit formula there for the least squares solution. Presumably because the rank of A equals the number of coefficients in x. You can only have one least squares solution.

So the only way to somehow get all positive entries for x may be to just perform a change of basis to make all the entries positive. Then also you would need to change A. This is if you look at the question in terms of spaces. If you just look at the problem in terms of a set of equations than it would seem one answer means one answer whether you agree with it or not.

So it may be that there is something about your problem I don't understand, it kind of seems like wanting something impossible.
 
Thanks for the quick reply.

I think I have to expand my problem a bit.

What I have in b is a set of measured weights of products, and in A i have the amounts of different components used to create these weights, x is the component weights I want to find. In a smaller scale it could look something like this:
Axx=number of components, xx=component weight, bx =product weight

b1 = A11*x1+A12*x2+A13*x3
b2=A21*x1+A22*x2+A23*x3
...
bn=An1*x1+An2*x2+An3*x3

which in matrix-form would be:


\begin{bmatrix}
A11 & A12 & A13 \\
A21 & A22 & A23 \\
... & ... & ... \\
An1 & An2 & An3
\end{bmatrix}
\begin{bmatrix}
x1 \\
x2 \\
x3
\end{bmatrix} = \begin{bmatrix}
b1 \\
b2 \\
b3 \\
... \\
bn
\end{bmatrix}


To evaluate this method, I simulate values of x(say between 50 and 150) and combine them with A to get simulated b-values. Then I try to find the x-values again.
This approach works fine when I use simulated values of x without variation. When I simulate values of x with some variation, say ± 5%, I get some negative x-values in the results which it turn make other values way too high.
Since I'm dealing with simulated data I know that all values should be positive, and I want to find the "least square" with only positive x-values. I know there is no guarantee that this answer will be the correct one, but I still would like to try it.

Hope this clarifyed the problem a little bit.

Thanks again
Jocke
 
What sort of correlation are you getting with your fits? If r < 0.9, there may be other factors in play.

Also, forming normal equations can lead to round off error in certain situations.
For the ill-behaved data sets, you may wish to try a different method for least squares, say using the QR method to solve for the coefficients rather than forming the normal equations.
 
I'm using Matlab to solve this problem and have tried

x=(A'A)^-1A'b
x=A\b
x=lsqnonneg(A,b)

The first two generates roughly the same answer, which contains negative values. The third one, which i found only yesterday, gives an answer with only positive or 0-values in x but it is still not even close to the "correct" one.

I was under the impression that A\b utilized the QR-method to some extent.

I have used Minitab to identify correlations between components, and removed one component of each pair with a correlation value of 1(always appear together). Do you think that high correlations amongst the remaining components could be a problem?

Am currently running a rather large lsqnonneg(A,b) in Matlab(A is 15541x1841 and b is 15541x1) so i haven't been able to check the correlations again.

Another possible problem might be that in the original data A was rank defficient, rank(A) was 1511 with 1845 columns.
To solve this I added 334 additional "measurements", each one containing only one of the components that lacked a pivot-element in rref(A) and nothing else.
(Rref(A) produces the row reduced echelon form of A)
Do you think that this approach might be problematic too?

I would be happy to explain the problem in further detail if needed, but I hope this is enough for now.Jocke
 

Similar threads

  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 0 ·
Replies
0
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K