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

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: How to write a fast code to obtain a specific calculation |

Date |
Wed, 18 Feb 2009 13:13:52 -0000 |

I am not clear whether your variables are really variables or just holders for constants. Beyond that, your search procedure looks like a slow linear crawl towards what you want. Changing that to something smarter, even a binary search, is probably going to be one of the biggest speed-ups possible. Nick n.j.cox@durham.ac.uk Tiago V. Pereira I usually need to compute a value X that satifies a specific condition. A typical example is shown below. But this is only a single example, and ordinarily I have similar, but more complex aims. Hence, I would like to know your expert opinion on how one can make codes these kind of codes faster. Perhaps only Mata helps? In this example, I want to compute the value of tau^2 that imposes the lower limit of my confidence interval to be 0. scalar lower_limit = 999999999 while lower_limit>0 { local tau2 = `tau2'+0.0001 cap drop T_i V_i W_i WT gene T_i= ln(_ES) gene V_i = _selogES^2 gene W_i = 1/(V_i+`tau2') gene WT = W_i*T_i qui summ WT scalar sum_WT = r(sum) qui sum W_i scalar sum_W_i = r(sum) scalar summary_random = sum_WT/sum_W_i scalar lower_limit = summary_random-(1.96/sqrt(sum_W_i)) } * * 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**:**st: How to write a fast code to obtain a specific calculation***From:*"Tiago V. Pereira" <tiago.pereira@incor.usp.br>

- Prev by Date:
**st: multivariate normal regression with ml, linear form** - Next by Date:
**st: DiD with panel data** - Previous by thread:
**st: AW: How to write a fast code to obtain a specific calculation** - Next by thread:
**Re: st: How to write a fast code to obtain a specific calculation** - Index(es):

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