# st: obtaining st.e. when using mata optimize for a covariance structure model/minimum distance estimator

 From Miriam Wüst To Subject st: obtaining st.e. when using mata optimize for a covariance structure model/minimum distance estimator Date Wed, 8 Apr 2009 09:15:06 +0200

```Hello there,
I am using the optimize command in mata to minimize a criterion function similar to the code shown below (I match observed covariances with theoretical covariances/moments). After estimating the parameters (betahat and 3variances/covariances) in the minimization I am in doubt how to use the "optimize_result_V" to option  st.e. - (see earlier question on this list!  http://www.stata.com/statalist/archive/2009-02/msg00325.html)
Anybody who can offer guidance on this topic, i.e. how to obtain st.e.?

Best
Miriam

b=(0,0,0,0) //starting values for parameter estimates
data=(y,X)

variance=variance(data)
c=(variance[1,1], variance[2,1], variance[3,1], variance[4,1])' //sample covariances

W= I(4,4) //weighting matrix

f1=(0,1,1,0\
0,1,0,0\
0,0,0,1\
0,0,0,1
)

f2=(2,0,0,0\
2,0,0,0\
0,0,0,0\
0,0,0,0
)

f2a=(0,0,0,1\
0,0,0,1\
0,0,0,0\
0,0,0,0
)

f2b=(0,0,0,0\
0,0,0,0\
variance[3,3],0,0,0\
variance[4,3],0,0,0
)

f3=(variance[3,3],0,0,0\
variance[4,3],0,0,0\
0,0,0,0\
0,0,0,0
)

void evaluator_gmm(todo, p, crit, g, H)
{
external W
external c
external f1
external f2
external f2a
external f2b
external f3

crit=(c-f1*p'-(f2*p'):*(f2a*p')-f2b*p'-f3*(p':*p')):*(c-f1*p'-(f2*p'):*(f2a*p')-f2b*p'-f3*(p':*p'))
}

S=optimize_init()
optimize_init_evaluator(S,&evaluator_gmm())
optimize_init_which(S,"min")
optimize_init_evaluatortype(S,"v0")
optimize_init_params(S, b)
//optimize_init_technique(bhhh)

ehat=optimize(S)

)

End

optimize_result_V(S)

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```