Hello, I have a matrix equation, Ax=b, that I need to solve for x. x should be a vector of positive numbers (between 0 and 1). A is not a square matrix in general. This lead me to using the SVD. However, using the SVD gives me positive and negative numbers, as well. I have some constraints included in the A matrix itself (i.e., that the sum of some xi should be equal to 1) but I do not know how to include the constraint that each xi should be non-negative. Is there in R (or somewhere else) an SVD that includes this kind of constraint? or some other optimizer that can cope with solving non-square matrix equations, including the positivity constraint? I know that this is not really an R question, sorry for that. Jordi Jordi Molins Short Term Products / Treasury Capital Markets> Dresdner Kleinwort Wassersteinphone +49 69 713 15329 fax +49 69 713 19804 mobile +49 171 171 64 61 mailto:jordi.molins at drkw.com -------------------------------------------------------------------------------- The information contained herein is confidential and is inte...{{dropped}}
If A is not square, which dimension is larger? There will most likely be either no solution or an infinity of solutions. If the latter, I think you are using the Moore-Penrose inverse (depends exactly how you use the SVD), that is the shortest solution, but the SVD will give you the whole space of solutions and you could compute if that intersects the positive orthant. On Tue, 27 Jul 2004, Molins, Jordi wrote:> I have a matrix equation, Ax=b, that I need to solve for x. x should be a > vector of positive numbers (between 0 and 1). A is not a square matrix in > general. This lead me to using the SVD. However, using the SVD gives me > positive and negative numbers, as well. I have some constraints included in > the A matrix itself (i.e., that the sum of some xi should be equal to 1) but > I do not know how to include the constraint that each xi should be > non-negative. > > Is there in R (or somewhere else) an SVD that includes this kind of > constraint? or some other optimizer that can cope with solving non-square > matrix equations, including the positivity constraint?optim(method="L-BFGS-B") can cope with [0, 1] constraints. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Thank you to Prof Brian Ripley and to Ken Knoblauch for your replies. I should explain a little bit more about the problem at hand: in principle, the matrix can have more rows than columns or the other way around. However, I always could include in an artificial way more equations, such that there are more equations than unknowns. So, in practical terms, the first question from Prof Brian Ripley is: more equations than unkowns. I have Additionally, I have seen in several places that is suggested to use La.svd instead of the standard svd. -----Original Message----- From: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk] Sent: 27 July 2004 10:13 To: Molins, Jordi Cc: 'r-help at stat.math.ethz.ch' Subject: Re: [R] SVD with positivity constraints If A is not square, which dimension is larger? There will most likely be either no solution or an infinity of solutions. If the latter, I think you are using the Moore-Penrose inverse (depends exactly how you use the SVD), that is the shortest solution, but the SVD will give you the whole space of solutions and you could compute if that intersects the positive orthant. On Tue, 27 Jul 2004, Molins, Jordi wrote:> I have a matrix equation, Ax=b, that I need to solve for x. x should be a > vector of positive numbers (between 0 and 1). A is not a square matrix in > general. This lead me to using the SVD. However, using the SVD gives me > positive and negative numbers, as well. I have some constraints includedin> the A matrix itself (i.e., that the sum of some xi should be equal to 1)but> I do not know how to include the constraint that each xi should be > non-negative. > > Is there in R (or somewhere else) an SVD that includes this kind of > constraint? or some other optimizer that can cope with solving non-square > matrix equations, including the positivity constraint?optim(method="L-BFGS-B") can cope with [0, 1] constraints. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595 -------------------------------------------------------------------------------- The information contained herein is confidential and is inte...{{dropped}}
Thank you to Prof Brian Ripley and to Ken Knoblauch for your fast replies. I should explain a little bit more about the problem at hand: in principle, the matrix can have more rows than columns or the other way around. However, I always could include in an artificial way more equations, such that there are more equations than unknowns. So, in practical terms, the answer to the first question from Prof Brian Ripley is: more equations than unkowns. I have checked in the "Modern Applied Statistics with S" 4th edition, and in page 62 it is shown the use of svd. It is written that svd gives, as result, u, v and d. If there is a space of solutions (as opposed to a unique solution) how is the solution given? how can I retrieve the whole space of solutions? Additionally, I have seen in several places that is suggested to use La.svd instead of the standard svd. Would the La.svd generate also the whole space of solutions? I have looked the documentation (http://cran.r-project.org/doc/packages/RScaLAPACK.pdf) but it is not explicitly written how to retrieve non-unique solutions. An additional question: in the Numerical Recipes for C++ it is written that the "small" numbers in the diagonal of d should be set manually to 0. Is this done (maybe as an option) in svd or in La.svd? could this resetting have a material effect in the solutions found? thank you J -----Original Message----- From: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk] Sent: 27 July 2004 10:13 To: Molins, Jordi Cc: 'r-help at stat.math.ethz.ch' Subject: Re: [R] SVD with positivity constraints If A is not square, which dimension is larger? There will most likely be either no solution or an infinity of solutions. If the latter, I think you are using the Moore-Penrose inverse (depends exactly how you use the SVD), that is the shortest solution, but the SVD will give you the whole space of solutions and you could compute if that intersects the positive orthant. On Tue, 27 Jul 2004, Molins, Jordi wrote:> I have a matrix equation, Ax=b, that I need to solve for x. x should be a > vector of positive numbers (between 0 and 1). A is not a square matrix in > general. This lead me to using the SVD. However, using the SVD gives me > positive and negative numbers, as well. I have some constraints includedin> the A matrix itself (i.e., that the sum of some xi should be equal to 1)but> I do not know how to include the constraint that each xi should be > non-negative. > > Is there in R (or somewhere else) an SVD that includes this kind of > constraint? or some other optimizer that can cope with solving non-square > matrix equations, including the positivity constraint?optim(method="L-BFGS-B") can cope with [0, 1] constraints. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595 -------------------------------------------------------------------------------- The information contained herein is confidential and is inte...{{dropped}}
Hello, what I wrote below is nonsense: if the matrix has more equations than unknowns, it makes no sense considering the general space of solutions. Sorry for that. Another consideration: could somebody give me an opinion about the following procedure? the simplex algorithm maximizes z=a00x0 + a01x1+...+a0(N-1)x(N-1) subject to x0>=0, ... x(N-1)>=0 and under M=m1+m2+m3 constraints: m1 equations for =< inequalities(with x on the left), m2 equations for >= inequalities, and m3 equations for equalities (=). Consider a00=a01=...=a0(N-1)=0 (degenerate in some sense), and let me choose also m1=m2=0, and then m3 being the number of equations I have. Using the simplex method for linear programing would give me "my" solution, or would this method give me a degenerate solution? thank you, and please bear with me my desesperation ;-> Jordi -----Original Message----- From: Molins, Jordi Sent: 27 July 2004 11:33 To: 'r-help at stat.math.ethz.ch' Cc: 'Prof Brian Ripley'; 'Ken Knoblauch' Subject: RE: [R] SVD with positivity constraints Thank you to Prof Brian Ripley and to Ken Knoblauch for your fast replies. I should explain a little bit more about the problem at hand: in principle, the matrix can have more rows than columns or the other way around. However, I always could include in an artificial way more equations, such that there are more equations than unknowns. So, in practical terms, the answer to the first question from Prof Brian Ripley is: more equations than unkowns. I have checked in the "Modern Applied Statistics with S" 4th edition, and in page 62 it is shown the use of svd. It is written that svd gives, as result, u, v and d. If there is a space of solutions (as opposed to a unique solution) how is the solution given? how can I retrieve the whole space of solutions? Additionally, I have seen in several places that is suggested to use La.svd instead of the standard svd. Would the La.svd generate also the whole space of solutions? I have looked the documentation (http://cran.r-project.org/doc/packages/RScaLAPACK.pdf) but it is not explicitly written how to retrieve non-unique solutions. An additional question: in the Numerical Recipes for C++ it is written that the "small" numbers in the diagonal of d should be set manually to 0. Is this done (maybe as an option) in svd or in La.svd? could this resetting have a material effect in the solutions found? thank you J -----Original Message----- From: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk] Sent: 27 July 2004 10:13 To: Molins, Jordi Cc: 'r-help at stat.math.ethz.ch' Subject: Re: [R] SVD with positivity constraints If A is not square, which dimension is larger? There will most likely be either no solution or an infinity of solutions. If the latter, I think you are using the Moore-Penrose inverse (depends exactly how you use the SVD), that is the shortest solution, but the SVD will give you the whole space of solutions and you could compute if that intersects the positive orthant. On Tue, 27 Jul 2004, Molins, Jordi wrote:> I have a matrix equation, Ax=b, that I need to solve for x. x should be a > vector of positive numbers (between 0 and 1). A is not a square matrix in > general. This lead me to using the SVD. However, using the SVD gives me > positive and negative numbers, as well. I have some constraints includedin> the A matrix itself (i.e., that the sum of some xi should be equal to 1)but> I do not know how to include the constraint that each xi should be > non-negative. > > Is there in R (or somewhere else) an SVD that includes this kind of > constraint? or some other optimizer that can cope with solving non-square > matrix equations, including the positivity constraint?optim(method="L-BFGS-B") can cope with [0, 1] constraints. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595 -------------------------------------------------------------------------------- The information contained herein is confidential and is inte...{{dropped}}