I define the equation to calculate asset value and volatility as below. In case V_equity > default_point, initial asset value is set to V_equity then it works fine and results the same as Solver's in Excel.
However, in case V_equity < default_point, if initial asset value is set to V_equity, then it results V_asset = V_equity and Solver also cannot solve it. Then I add the condition that initial asset value is set to default_point, then it results V_asset = default_point. Does anyone experience that and how should we set initial guess for asset value in this case? Your comment is highly appreciated. Thank you.
for i, row in df.iterrows():
def equation(x):
d1 = (np.log(x[0]/row["default_point"]) + (row["arf_rate"]+x[1]**2/2)*T)/(x[1] * np.sqrt(T))
d2 = d1 - x[1] * np.sqrt(T)
res1 = x[0] * norm.cdf(d1) - np.exp(-row["arf_rate"]*T) * row["default_point"] * norm.cdf(d2) - row["V_equity"]
res2 = (x[0] * norm.cdf(d1) * x[1])/row["asigma_equity"] - row["V_equity"]
return(res1**2+res2**2)
if row["V_equity"] >= row["default_point"]:
x0 = (row["V_equity"],row["asigma_equity"])
else: x0 = (row["default_point"],row["asigma_equity"])
cons = ({'type': 'ineq', 'fun': lambda x: x[0]}, {'type': 'ineq', 'fun': lambda x: x[1]})
result = minimize(equation, x0, constraints=cons)
question from:
https://stackoverflow.com/questions/65874264/merton-model-using-scipy-optimize-function-choose-initial-values-of-asset-valu 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…