[R] Solve matrix with constraints using sum of squares

Scott.Wilkinson at csiro.au Scott.Wilkinson at csiro.au
Wed Aug 1 00:58:16 CEST 2007

I'm trying to solve a system of equations for A and B:

37.07*A + 0.07*B - 36.73*C ~= 0
2.68*A + 24.75*B - 275.77*C ~= 0

The LHS is the product of 2*3 and 3*1 matrices.

Constraints: A+B=1

I want to minimise the sum of squares of the equations together.

The R function solve can solve matrices but not with these constraints.
Lp solves equations with these constraints but doesn't use sum of
squares; just a linear solution which minimises EQN1 to ~-36.66 by the
solution [0,1,1] for example. 

I know from the help file and previous postings that QR.solve, solve.QP
(quadprog) or Optim are able to do this or something similar, but I
can't follow the application of these functions. I could use Excel
solver but my endgame is to run this solution for many many equations.
Would appreciate your help. 


More information about the R-help mailing list