Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

re: Re: st: Running Product Function


From   Christopher Baum <[email protected]>
To   "[email protected]" <[email protected]>
Subject   re: Re: st: Running Product Function
Date   Sun, 9 Dec 2012 22:21:44 +0000

<>
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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index