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

From |
George Batchelor <george.batchelor@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Delta method using Mata |

Date |
Tue, 9 Jun 2009 14:16:57 +0100 |

Thanks for this suggestion Maarten. This works quite well when there are just one or two coefficients, but in my program I have about 64 price coefficients from which I want to calculate elasticities based on a non-linear transformation and, while I could probably do this using nlcom and a loop, I would ideally like to use Mata. Surely like other languages Mata must be able to calculate the gradient of a function? Many thanks for any other suggestions. George On Tue, Jun 9, 2009 at 11:19 AM, Maarten buis<maartenbuis@yahoo.co.uk> wrote: > > --- 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/ > * * 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/

**References**:**Re: st: Delta method using Mata***From:*Maarten buis <maartenbuis@yahoo.co.uk>

- Prev by Date:
**Re: st: simulation** - Next by Date:
**Re: st: AW: Robust vs Cluster errors using xtreg fe in Stata10** - Previous by thread:
**Re: st: Delta method using Mata** - Next by thread:
**st: Marginal Effects in Tobit witih Interactions** - Index(es):

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