Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Maarten Buis <maartenlbuis@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: How to improve accuracy in numerical integrations using Stata |
Date | Fri, 23 Dec 2011 14:37:35 +0100 |
On Fri, Dec 23, 2011 at 1:40 PM, Tiago V. Pereira wrote: > Do you have any ideas on how to further increase the precision for > numerical integration in Stata? The problem is that I am working on heavy > tails (alpha levels below 10^-8). You can use a rule for choosing your knots such that the maximal error is (approximately) less than some level that you set, see: (Hoermann and Leydold 2003). If you can also analytically compute the derivative of the function, than you can use that information while setting up the spline that approximates your function. An example of a combination of these approaches can be found in -margdistfit-, available from SSC, in particular see the Mata functions in margdistfit_mata_approxF.do. There are some differences: in those functions I only approximate the function, you need to take an extra step by computing the integral. I have a function that I know to be monotonically increasing, so I continue adding knots till the approximate function is also monotonically increasing. You will probably want to exclude that check. Hope this helps, Maarten Hoermann, Wolfgang and Leydold, Josef. (2003). Continuous random variate generation by fast numerical inversion. ACM transactions on Modeling and Computer Simulation, 13(4): 347--362. -------------------------- Maarten L. Buis Institut fuer Soziologie Universitaet Tuebingen Wilhelmstrasse 36 72074 Tuebingen Germany http://www.maartenbuis.nl -------------------------- * * 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/