# st: RE: Quadratic programming in Stata

 From "Feiveson, Alan H. \(JSC-SK311\)" To Subject st: RE: Quadratic programming in Stata Date Wed, 13 Sep 2006 08:34:08 -0500

```Mark - This may not be of much use, but a brute-force way to solve your
problem is recognize that in the solution, anywhere from 0 to n of the
inequality constraints would be binding, where n is the dimension of x.
So if n is small, you could solve all 2^n equality-constrained problems
of the form

min 0.5*x'Hx + f'x   subject to:  DAx = b

where D is a diagonal matrix with k ones and the rest zeros; k = 0, 1,
2,..,n (you must try all combinations for each k)

Then discard all solutions where the unconstrained equations
(corresponding to zeros in the diagonal of D) violate
Ax <= b.

Of the remaining solutions, the optimal is the one that has the minimum
value of the objective function.

For each D, a closed-form solution can be found by using La Grange
multipliers.

To do this in Stata, one would need to loop through the 2^n possible
problems and save the results. I think there is an existing program in
Stata for trying all possible subset regressions (I already have one for
trying all regressions of a given size k). Without too much work, such a
program could be modified to do your problem.

Al Feiveson

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Marcello
Pagano
Sent: Tuesday, September 12, 2006 3:32 PM
To: statalist@hsphsun2.harvard.edu; owner-statalist@hsphsun2.harvard.edu

I'm looking for something that would be done in Matlab by the qp
command, available in the Matlab Optimization Toolbox:

%   X=QP(H,f,A,b) solves the quadratic programming problem:
%
%   min 0.5*x'Hx + f'x   subject to:  Ax <= b

I've searched the usual places and come up with almost nothing, which
makes me think that the facility in Stata doesn't exist, and wouldn't be
trivial to implement.

If anybody could offer any suggestions on how the problem could be
approached, or whether it's as non-trivial as I fear, or whether they
know someone who has already written something like this for Stata, I'd
be very grateful to hear about it.

Cheers,
Mark

Prof. Mark E. Schaffer
Director
Centre for Economic Reform and Transformation Department of Economics
School of Management & Languages Heriot-Watt University Edinburgh EH14
4AS  UK
44-131-451-3494 direct
44-131-451-3296 fax
http://www.sml.hw.ac.uk/cert

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```