Our Stata | Mata code offers a comprehensive implementation of the Merton distance to default or Merton DD model, following the iterative process employed by renowned researchers such as Crosbie and Bohn (2003), Vassalou and Xing (2004), and Bharath and Shumway (2008). By utilizing our code, you can easily apply the model using the following steps:

1.Generate log returns from stock prices.

2. Calculate the volatility for each stock in each year using daily stock returns, subsequently converting it into yearly volatility.

3. Utilize the stock volatility as a proxy for asset volatility in the initial iteration, employing a specific equation to infer the firm value.

E = V\mathcal{N}(d_1) - e^{-rT}F\mathcal{N}(d_2),

Here, E represents the market value of the firm’s equity, F denotes the face value of the firm’s debt, r is the risk-free rate, and \mathcal{N}(.) represents the cumulative standard normal distribution function. Additionally, d_1 and d_2 are defined as follows:

d_1 = \dfrac{ln(V/F) + (r+0.5\sigma_V^2)T}{\sigma{_V}\sqrt{T}}
d_2 = d_1-\sigma{_V}\sqrt{T}

4. Repeat step 3 for each observation while employing the volatility values of a particular firm in a given year. This iterative process generates daily firm values. It’s important to note that the root for the firm value in Equation 1 needs to be found, and we have set the iteration limit at 1000.

5. Once the implied firm values are generated, recalculate log returns based on these values.

6. Re-evaluate daily volatility from the log returns for each firm-year combination, and convert it back into yearly volatility.

7. Plug the new volatility values into Equation 1 to infer firm values.

8. Iterate this process (up to 500 times) until the new volatility value converges to the previous volatility.

9. After achieving convergence, employ the firm and volatility values from the last successful iteration to derive the probability of default using the following equation:

\mathcal{N}\left(-\left(\dfrac{ln(V/F)+(\mu-0.5\sigma_V^2)T}{\sigma{_V}\sqrt{T}}\right)\right)= \mathcal{N}(-DD)


Accuracy of the Code

We have rigorously tested the code with both real and dummy data, and it consistently produces the expected results, accurately matching the benchmarks created during the construction of the dummy data. 


The code is available for purchase at £139. We also offer a data processing service for £49 to help you prepare your data for use with the code. We can modify your data set and convert it to Stata format, or we can construct the required variables if needed.


Buy with PayPalPay Now

Choose Package


For further details and inquiries, please don’t hesitate to contact us at the following:




Why should you buy the code?


Dr. Attaullah Shah
Stata Code is cutomizable
Our Stata code is tested and validated