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

Re: st: Delta method using Mata

From   Maarten buis <>
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 drop silly()
void silly() {
	b = 1 , 2
	V = 1 , 0 \
          0 , 1
	st_matrix("b", b)
	st_matrix("V", V)

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

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

Hope this helps,

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


*   For searches and help try:

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