 Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# st: Mata : getting covariance matrix with moptimize()

 From To Maxime To "statalist@hsphsun2.harvard.edu" Subject st: Mata : getting covariance matrix with moptimize() Date Fri, 25 Feb 2011 11:01:53 +0100

```Hi,

I am using mata to estimate moment based estimators. To do so I use the moptimize() function with a Gauss-Newton method (gn).

When I compare to the use of the gmm()  function, results are correct but I can't obtain vce results. I give you here a simplifyed version of my code that has the same problem.

mata:
mata clear
function i_gmm(M,todo,b,r,S)
{
y1 = moptimize_util_depvar(M, 1)
x1 = moptimize_util_indepvars(M, 1)
p1 = moptimize_calc_xb(M, b, 1)
r  = x1'p1
}

W= st_matrix(W)

M = moptimize_init()
moptimize_init_evaluator(M, &i_gmm())
moptimize_init_which(M,"min")
moptimize_init_technique(M, "gn")
moptimize_init_evaluatortype(M, "q0")
moptimize_init_depvar(M, 1, "devar")
moptimize_init_eq_indepvars(M, 1, "indepar1 indepvar2")
moptimize_init_gnweightmatrix(M,W)
moptimize_query(M)
moptimize(M)
moptimize_result_display(M)
end

Thanks,
Maxime
*
*   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/
```