Hi,
I'm trying to use mata to calculate a bond yield. I have seen this post http://www.stata.com/statalist/archi.../msg01113.html which explains how to calculate an IRR when the formula is stationary (that is, there are a set number of periods, in that case just two). In my data, I have different maturities for all of my bonds. Can I write a mata function that sums up (from t=1 to floor(years to bond maturity))?
I want be able to use mm_root to solve for
C/(1+r)+C/(1+r)^2+...C/(1+r)^t+F/(1+r)^t where t varies for each of the rows in my data, and am not sure how to do this within the mata function.
Thanks!
I'm trying to use mata to calculate a bond yield. I have seen this post http://www.stata.com/statalist/archi.../msg01113.html which explains how to calculate an IRR when the formula is stationary (that is, there are a set number of periods, in that case just two). In my data, I have different maturities for all of my bonds. Can I write a mata function that sums up (from t=1 to floor(years to bond maturity))?
I want be able to use mm_root to solve for
C/(1+r)+C/(1+r)^2+...C/(1+r)^t+F/(1+r)^t where t varies for each of the rows in my data, and am not sure how to do this within the mata function.
Thanks!
Comment