Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: st: Mata : getting covariance matrix with optimize()
From
To Maxime <[email protected]>
To
"'[email protected]'" <[email protected]>
Subject
RE: st: Mata : getting covariance matrix with optimize()
Date
Wed, 9 Mar 2011 09:38:36 +0100
Hi,
1. the function is simply a moment condition of the type:
function i_gmm(M,todo,b,r,S)
{
r = x1'(x2'b)
}
I compute gradients & Hessian numerically.
2. The technique used is "gn" and the evaluator type is "q0":
optimize_init_technique(M, "gn")
optimize_init_evaluatortype(M, "q0")
I introduce the weights with the following instruction:
optimize_init_gnweightmatrix(M,W)
and you can find in the ado file this code:
if (S.gn_A != `OPT_gn_A_default') {
return(J(S.dim,S.dim,0))
}
Where "S.gn_A" stands for the weight matrix.
I guess it means that whenever the weightmatrix is specified, the covariance will be zero (the covariance matrix given by optimize_result_V with any type of method (oim, robust, etc.)).
So my question is why Stata does not give the covariance matrix when I specify the weights (if I understood well what Stata does...)?
Thanks,
Maxime
-----Message d'origine-----
De : [email protected] [mailto:[email protected]] De la part de Gordon Hughes
Envoyé : mardi 8 mars 2011 21:57
À : [email protected]
Objet : Re: st: Mata : getting covariance matrix with optimize()
You haven't provided sufficient information for readers to answer
your question properly. For example:
1. What kind of function are you optimizing? I assume that it is a
likelihood function, but are you relying upon numerical or analytical
gradients & Hessian?
2. When you say that Mata does not compute the covariance matrix,
what are you expecting it to do?
If you use -optimize_result_Hessian(S)- after the optimization is
complete, this should return the value of the Hessian at the
converged values of the parameters. This is available even if
gradients and the Hessian are calculated numerically, but it is, of
course, only an approximation in that case. There is no reason why
this would fail to work with weights, since the Hessian of
log-likelihood is perfectly well defined with or without weights.
Or, have you been relying upon -optimize_result_V with or without
_oim, etc? I find it safer to work with the Hessian and it is
possible that these functions may not work with weights, though I
would be surprised at this.
Gordon Hughes
[email protected]
=============================
Hi all,
I sent a message a couple of weeks ago but have no answer.
I am using mata and the optimize function to estimate a model.
I try to use the Gauss Newton Algorithm to optimize my objective
function. This works well. The problem is that mata does not compute
the covariance matrix.
I had a look to ado files and it seems that since I specifyed a
matrix of weights, stata automatically gives a zero matrix as the
covariance matrix.
Can you tell me why is it so? Is there a way to ask stata/mata to
compute the covariance matrix or do I have to compute it "by hand"?
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/
*
* 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/