Hi,
I am trying to implement an optmization using ml, but i am really
confused by the syntax. In my toy example, the optimization has just
two matrices Z1 (t x 1) and Z0 (t x n). These are not variables but
matrices created from variables (since my optimization is based on
these matrices and not on raw variables; In fact I have a data
pre-processing command that returns these matrices using ereturn).
Now I am trying to minimize the real valued function: argmin( (Z1 -
Z0*W)' * (Z1 - Z0*W))
where W is a block diagonal matrix with n elements, w_1,w_2,....,w_n
in the diagonal. So I want the optimizer to give me the w parameters
that minimize this expression. I don't understand how ml lets me pass
these parameteres (w) and matrices (Z) to the loss function? Any help
would be appreciated. All the help files and also the MLE Stata book
is written ito variables and linear combinations. My optimization
deals with matrices however. I am partyciularly interested in how to
specifcy the right command and learn more about the syntax of the b
argument there.
Let's say I got five units so I got starting values mat startval_w =
(1 \ 1 \ 1 \ 1 \ 1 ). I am trying to do something like:
loss_function
args todo b lnf
tempname Z1 Z0 W loss
mat `Z1' = e(Z1)
mat `Z0' = e(Z0)
mat `W' = startval_w
mat `loss' = (`Z1' - `Z0' * `W')' * ( `Z1' - `Z0' * `W' )
`lnf' = `loss'
end
Now I wonder how I can specif the b argument to get all this to run:
ml model d0 myprog ()
Thank you very much. Btw. my actual optimization is more complicated
than this, but I am just trying to understand the syntax properly.
Tom
*
* 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/