Statalist


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

st: Calculating internal rates of return


From   Lars Holstenkamp <[email protected]>
To   [email protected]
Subject   st: Calculating internal rates of return
Date   Thu, 30 Jul 2009 15:01:35 +0200

Dear all,

I generated random numbers for cash flows (obs=10,000) and tried to compute internal rate of returns for every set of data using -finirr- (user written). Unfortunately, there seem to be some simulation runs where the maximization procedure used by -finirr- fails to converge, i.e. no internal rate of return (IRR) can be calculated or no IRR exists. Therefore, I get a failure message when running my do file. Is there a way how to keep it going and instead produce a missing in case the IRR can't be computed?

Thanks,
Lars

---
My code (I bet there are easier ways to do that, but anyway):
version 10.0
[...]
tsset index time
forv i=1/10000 {
   finirr CF if index==`i'
   scalar IRR`i'=r(irr)
}
generate IRR=0
forv i=1/10000 {
   replace IRR=IRR`i' if index==`i'
}
reshape wide
summ IRR
scalar IRR_m=r(mean)
scalar IRR_sd=r(sd)
*
*   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/



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