[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
re: Re: st: Running Product Function
<>
Yuval said
by appt: replace reduct_per=1 if reduct_per==0
by appt: gen y1=exp(sum(ln(reduct_per)))
Note that the first command need not be run under by-control.
On my machine, on a panel of ~18k obs, this runs about twice as fast:
by appt: gen y1=exp(sum(ln(cond(reduct_per==0, 1, reduct_per))))
Also note that in working with log() and exp() it would be a good idea to use doubles in the computation.
KIt
Kit Baum | Boston College Economics & DIW Berlin | http://ideas.repec.org/e/pba1.html
An Introduction to Stata Programming | http://www.stata-press.com/books/isp.html
An Introduction to Modern Econometrics Using Stata | http://www.stata-press.com/books/imeus.html
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/