Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Delta method using Mata


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: Delta method using Mata
Date   Tue, 9 Jun 2009 10:19:59 +0000 (GMT)

--- On Tue, 9/6/09, George Batchelor wrote:
> I have an estimator in Mata that produces a set of
> coefficient estimates and also a var-covar matrix. 
> I then transform the coefficients using a non-linear
> process.  Ordinarily I would then use the delta
> method to calculate the var-covar matrix for
> transformed coefficients.  To do this in Stata I
> would use "nlcom" and in Gauss I would use "gradp"
> to find the gradient vector of the new parameters,
> but I can not find a function to do this in Mata.  Any
> advice on how to do this would be much appreciated.

One strategy you could follow is to return these intermediate
estimates into Stata and use -nlcom- within Stata. This is 
illustrated in the silly example below. 

*------------- begin example ---------------
mata
mata drop silly()
void silly() {
	b = 1 , 2
	V = 1 , 0 \
          0 , 1
	st_matrix("b", b)
	st_matrix("V", V)
}
end

capture program drop silly_estimator
program define silly_estimator, eclass
	mata silly()
	matrix colnames b = x _cons
	matrix colnames V = x _cons
	matrix rownames V = x _cons
	
	ereturn post b V
end

silly_estimator
nlcom _b[x]/_b[_cons]
*-------------- end example -----------------

Hope this helps,
Maarten

-----------------------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      

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



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index