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 fir’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 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.

## Pricing

The code is

attaullah.shah@imsciences.edu.pk

See our full list of completed projects

**References**

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 finance*, *59*(2), 831-868.