# st: Mata and Optimize Command

 From "Randy Akee " To Subject st: Mata and Optimize Command Date Sun, 23 Sep 2007 12:11:49 +0200

Dear Statlist,

I am trying to use the MATA Optimize command to get a minimum distance
estimator of some parameters of interest.  I have six equations and six
unknown parameters - my actual problem is a bit more complex, but I
can't seem to get the simple version to work below:

I've typed in two matrices, c and f.  I'm trying to find the parameters,
p, that minimize: (c-f(p))'(c-f(p)).

The error that I get is that the function is not conformable, does
anyone have a suggestion on how I could correct this in what I've done?
I believe the issue is that I need somehow to specify the dimensions of
the parameter vector, p.  I'm just not sure if that is possible to do,
any ideas would be appreciated.

c
1
+-----+
1 |  1  |
2 |  2  |
3 |  3  |
4 |  4  |
5 |  5  |
6 |  6  |
+-----+

: f = (1,1,0,
0,0,0\0,1,1,0,0,0\0,0,1,1,0,0\0,0,0,1,1,0\0,0,0,0,1,1\1,0,0,0,0,1)

: f
1   2   3   4   5   6
+-------------------------+
1 |  1   1   0   0   0   0  |
2 |  0   1   1   0   0   0  |
3 |  0   0   1   1   0   0  |
4 |  0   0   0   1   1   0  |
5 |  0   0   0   0   1   1  |
6 |  1   0   0   0   0   1  |
+-------------------------+

: void md0(todo, p, c, f, lnf, S, H)
> {
> lnf = (c-f*p)'*(c-f*p)
> }
note: argument todo unused
note: argument S unused
note: argument H unused

: S = optimize_init()

: optimize_init_evaluator(S, &md0())

: optimize_init_evaluatortype(S, "v0")

: optimize_init_params(S,(0,0))

: optmize_init_which(S, "min")

: optimize_init_argument(S, 1, c)

: optimize_init_argument(S, 2, f)

: p = optimize(S)
md0():  3200  conformability error
opt__calluser2_v():     -  function returned error
opt__eval_nr_v0():     -  function returned error
opt__loop_nr():     -  function returned error
optimize():     -  function returned error
<istmt>:     -  function returned error
r(3200);

-------------------------------------------------
Randall K. Q. Akee, Ph.D.

Research Associate

IZA - Forschungsinstitut zur Zukunft der Arbeit GmbH
IZA - Institute for the Study of Labor
P.O. Box 7240, 53072 Bonn, Germany
Schaumburg-Lippe-Str. 5-9, 53113 Bonn, Germany
Phone: +49 (228) 3894-306; Fax: +49 (228) 3894-510
E-Mail: akee@iza.org
Web: http://www.iza.org
Registered Office Bonn, District Court of Bonn, HRB 7745
Represented by: Prof. Dr. Klaus F. Zimmermann (Director)
-------------------------------------------------

*
*   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/