Sasha,
> I just started to learn programming in Stata and struggle with this:
>
> I would like to maximize
>
> y=(Ax+B)'(Ax+B) where x=(rho**2, rho, sigma) is a vector 3x1. A (3x3)
> and B(3x1) are known.
>
> I installed amoeba.ado that allows to do this but there is no help on
> how objective function looks. I guess that I need to write a program
> that will take x from amoeba and return y. Can anyone suggest a code
> that will do this.
You would need to -program define- your objective function in the
following way:
program define QForm
args x y
tempname M
mat `M' = (A`x'+B)'(A`x'+B)
scalar `y' = `M'[1,1]
end
(I suspect it wouldn't work if you just coded
scalar `y' = (A`x'+B)'(A`x'+B)
because the result in the RHS is a 1x1 matrix to Stata, even though it may
appear as a number to most of us.)
See if this works.
--- Stas Kolenikov
-- Ph.D. student in Statistics at UNC-Chapel Hill
- http://www.komkon.org/~tacik/ -- [email protected]
* This e-mail and all attachments to it are not intended to provide any
* reasonable point of view and was transmitted to you in error. It
* should be immediately deleted by all recipients unless they really
* enjoy communicating with the author :). Other restrictions apply.
*
* 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/