KMV – Merton Distance to Default Model through an iterative process in Stata

Our Stata | Mata code implements the Merton distance to default or Merton DD model using the iterative process used by Crosbie and Bohn (2003), Vassalou and Xing (2004), and Bharath and Shumway (2008). Specifically, our code implements the model in the following steps:

1.Generate log returns from stock prices

2. Find volatility for each stock in each year from the daily stock returns and convert it to yearly volatility

3. Use the above stock volatility as a proxy for asset volatility in the first iteration and use the following equation to infer the firm value.

where E is the market value of the firm’s equity, F is the face value of the firm’s debt, r is the risk-free rate, N(.) is the cumulative standard normal distribution function and d1 and d2 are equal to

4. Step 3 is repeated for each observation while using the volatility values of a given firm in a given year. This way the firm values are generated daily. Also note, that we have to find the root for the firm value in Equation 1. For finding the root, we set the iteration limit at 1000.

5. Once the implied firm values are generated, log returns are re-calculated from these values.

6. Daily volatility from the log returns is re-calculated for each firm-year combinations and converted into yearly volatility.

7. The new volatility values are plugged again in Equation 1 to infer firm values.

8. The process is iterated (up to 500 times) until the new volatility value is converged to the previous volatility.

9. After convergence, the firm and volatility values from the last successful iteration are then used to derive the probability of default using the following equation


Accuracy of the Code

The code has been tested with actual and dummy data. The code produces expected results and matches the benchmarks created for it in the dummy data construction.



The code is available available for $139, plus a $50 for raw data processing (in case the data is not in Stata format and variables are not already constructed). For further details, please contact us at:

Pricing Options


  • Source Code
  • Comments
  • Email Support


Most Popular

  • Source Code
  • Data Handling
  • Comments
  • Email Support


  • Source Code
  • Example Dataset
  • Comments
  • Email Support

Package includes the source code, comments, and email support.

Package includes the source code, comments, and an example dataset that matches the code. The example dataset facilitates the application of the code as all the variable names in the code match exactly the variable names in the dataset.

Package includes the source code, comments, and client's data handling which include merging different datasets, importing data from Excel or CSV files, data cleaning, etc.



Bharath, S. T., & Shumway, T. (2008). Forecasting default with the Merton distance to default model. The Review of Financial Studies, 21(3), 1339-1369.

Crosbie, P., & Bohn, J. (2003). Modeling Default Risk: Modeling Methodology, Moody’s KMV Company. available at http:\\www. moodyskmv. com.

Merton, R. C. (1974). On the pricing of corporate debt: The risk structure of interest rates. The Journal of finance, 29(2), 449-470.

Vassalou, M., & Xing, Y. (2004). Default risk in equity returns. The journal of finance59(2), 831-868.

See our full list of completed projects

Leave a Reply