salmanfar
(Salman Zaffar)
July 22, 2022, 7:05am
1
Hi All,
I am trying to numerically solve Black Scholes Equation as it is used in Credit Risk Analysis through KMV method. Enclosed please find the snapshot of the two nonlinear equations that are to be solved simultaneously. Is there anything wrong with the Mathematica code?
Mathematica code is given below
r=10.35;
T=1.0;
Debt=100000.0;
d1=(Log[VA/EqVaVo[[1,1]]]+(r+sigA^2/2)*T)/(sigA*Sqrt[T]);
d2= (Log[VA/EqVaVo[[1,1]]]+(r-sigA^2/2)*T)/(sigA*Sqrt[T]);
F=CDF[d1];
G=CDF[d2];
Equation1=VA*F-Debt*Exp[-r*T]*G;
Equation2=EqVaVo[[1,1]]*EqVaVo[[1,2]]-VA*F*sigA;
NSolve[{Equation1 == 0, Equation2 == 0}, {VA,sigA}]
The result I get is
EqVaVo[[1, 1]] (* and *)EqVaVo[[1, 2]]
not defined ?
paste a full code?
salmanfar
(Salman Zaffar)
July 22, 2022, 7:14pm
3
EqVaVo=Import[“…/HDEqVaVo.csv”];
(*Values of EqVaVo[[1,1]] & EqVaVo[[1,2]] as read from HDEqVaVo.csv file*)
EqVaVo[[1,1]]=48885.7
EqVaVo[[1,2]]=8.752*^-6
r=10.35; T=1.0; Debt=100000.0;
d1=(Log[VA/EqVaVo[[1,1]]]+(r+sigA^2/2)*T)/(sigA*Sqrt[T]);
d2= (Log[VA/EqVaVo[[1,1]]]+(r-sigA^2/2)*T)/(sigA*Sqrt[T]);
F=CDF[d1];
G=CDF[d2];
Equation1=VA*F-Debt*Exp[-r*T]*G;
Equation2=EqVaVo[[1,1]]*EqVaVo[[1,2]]-VA*F*sigA;
NSolve[{Equation1 == 0, Equation2 == 0}, {VA,sigA}]
You have syntax error in CDF !.
From documentation of CDF we have:
CDF[dist,x] gives the cumulative distribution function for the distribution dist evaluated at x.
You must define at first ProbabilityDistribution for example:
d= ProbabilityDistribution[Sqrt[2]/Pi/(1 + x^4), {x, -Infinity, Infinity}];(* and then *)
CDF[d, x]
(*(\[Pi] - ArcTan[1 - Sqrt[2] x] + ArcTan[1 + Sqrt[2] x] +
ArcTanh[(Sqrt[2] x)/(1 + x^2)])/(2 \[Pi])*)
In your case:
CDF[ProbabilityDistribution[(10 (207/2 + sigA^2/2) + Log[(10 VA)/488857])/(
Sqrt[10] sigA), {sigA, -1, 1}], SigA]
or:
CDF[ProbabilityDistribution[(
10 (207/2 + sigA^2/2) + Log[(10 VA)/488857])/(
Sqrt[10] sigA), {VA, -1, 1}], VA]
Hi,
I changed the code a bit as follows. But its still not getting numerically solved. please help
EqVaVo=Import["..../HDEqVaVo.csv"];
(* EqVaVo[[1,1]]=48885.7 and EqVaVo[[1,2]]8.752*^-6 *)
r=0.1035;
T=1.0;
Debt=37100.0;
d1=(Log[VA/EqVaVo[[1,1]]]+(r+sigA^2/2)*T)/(sigA*Sqrt[T]);
d2=(Log[VA/EqVaVo[[1,1]]]+(r-sigA^2/2)*T)/(sigA*Sqrt[T]);
pdf = PDF[NormalDistribution[0, 1], \[Xi]];
F=Integrate[pdf, {\[Xi], -Infinity, d1}]
G=Integrate[pdf, {\[Xi], -Infinity, d2}]
NSolve[{VA*F==Debt*Exp[-r*T]*G,EqVaVo[[1,1]]*EqVaVo[[1,2]]== VA*F*sigA}, {VA,sigA}]
This has syntax errors, check the documentation for PDF.
pdf = PDF[NormalDistribution[0, 1], [Xi]]