Yield to maturity in Stata

The approximate yield to maturity for a coupon bond can be found using the following formula.

Equation 1

However, the above formula does not provide the exact value of YTM. Exact value can be found by solving for rate in the following equation

Equation 2

There are several tools in Stata that can be used to solve for the rate in an iterative process, including the suite of optimizer() functions in the Mata language, the group of solvenl() functions for solving systems of nonlinear equations or the mm_root() function from the moremata package of Ben Jann. It is to acknowledge that setting up these functions is usually not straight forward and require a significant amount of time in understanding the way these functions work.



Our Codes

Our codes use the solvenl() group of function to solve for YTM in Equation 2, given above. The code takes an iterative path until the bond price and the present value of the future cash flows of the bond converge. The code is not only fast but produces results that are highly accurate


These codes are available with two options. If you need the codes as is, the price is $100. The second option has a price of $150, where we adjust the code according to your data and variable names so that the application of the codes is smooth.


Customization of the code

The codes can be further customized as per a given research design. For further details and pricing, please contact us at

attaullah.shah@imsciences.edu.pk