# [R] SVD with positivity constraints

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Jul 27 10:12:37 CEST 2004

```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

```