How to solve simultaneous equations?

조회 수: 5 (최근 30일)
Fred
Fred 2011년 4월 24일
Hello, I would like to solve simultaneously the following system of 2 equations for S and T: (fyi, these equations are an application of the Merton model for credit risk)
The first equation is:
P = N(d1) - (1-P)*exp(r*T)*N(d2)
where N(d1) and N(d2) are the cumulative normal function (cdfnorm) as in Black & Scholes with
d1 = (-ln(1-P)-(r-S^2/2)*T)/(S*sqrt(T))
d2 = d1 - S*sqrt(T)
The second equation is:
E = S*N(d1)/P
Is there a way in matlab to find values for S and T (volatility and maturity) that are consistent with the parameter P, E, and r (respectively, the leverage, the volatility of equity and the interest rate) that are known parameters (for instance, P=0.7, E=0.3, and r=0.03)?
Thank you very much for your help!
  댓글 수: 1
bym
bym 2011년 4월 24일
do you have the symbolic toolbox and/or statistic toolbox

댓글을 달려면 로그인하십시오.

답변 (4개)

bym
bym 2011년 4월 24일
I tried
P = .7; E = .3; r = .03;
syms S T real
d1 = (-1*log(1-P)-(r-S^2/2)*T)/(S*sqrt(T));
d2 = d1 - S*sqrt(T);
N1 = 1/2*(1+erf(d1/sqrt(2))); %your N(d1)
N2 = 1/2*(1+erf(d2/sqrt(2))); %your N(d2)
sol = solve(S*N1/(N1-(1-P)*exp(r*T)*N2)-E);
with the following result
Warning: Explicit solution could not be found.
Looks like it needs to be solved numerically w/ fzero. Don't have time tonight, maybe tomorrow
  댓글 수: 1
andreas patsikos
andreas patsikos 2011년 11월 14일
i have the same problem!!!i want EDF???
DO u know the matlab code for EDF?

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2011년 4월 25일
Using Andrew's code as a base, I found an expression for S in terms of T, but solving for T in terms of S was not feasible in the time I spent.
I am currently running a plot over T from 0 to 1000, and it is taking a fair bit of time. The expression for S pretty much has to be solved numerically. Ummm, long enough that I quit out of the plot and now am seeing if I can find a more tractable expression for S.
  댓글 수: 2
Walter Roberson
Walter Roberson 2011년 4월 25일
I worked with the symbolic solution, but the amount of time it takes to come up with any given answer doesn't make it feasible.
You are better off taking S*N1/(N1-(1-P)*exp(r*T)*N2)-E and substituting your T and asking for a numeric solution with a guess of S=0.2 . For sufficiently large T, S rises approximately linearly.
Question: does a negative S make sense? For a range of maturities (up to roughly 10 with the given parameters) there are two real solutions, one negative and one positive.
Walter Roberson
Walter Roberson 2011년 4월 25일
Follow up: with the given parameters, it appears for any given negative S below a certain value, there is a corresponding T such that the pair form a solution. The T is close to being linear in log(S) for sufficiently large (magnitude) of S. With the given parameters, the boundary limit for existence is somewhere between -1/100 (exists) and -1/1000000 (does not)

댓글을 달려면 로그인하십시오.


Fred
Fred 2011년 4월 25일
Looks more complicated than I thought. To answer your question, a negative S would not make sense as it represents a volatility. A typical value would be between 0.1 to 0.3 (but it will always be lower than E which is 0.3 in our example).
In order to assure a starting point for which the numerical method will quickly yield a solution, would it be possible to solve the equations separately for S for a few fixed values of T? Then we can use the intersection of the solution curves S(T)as a starting point for the system of equations.
  댓글 수: 1
Walter Roberson
Walter Roberson 2011년 4월 25일
It turns out that as the time gets longer, more significant digits are required in order to get an answer that is not numeric nonsense. In some cases I needed more than 50 digits. (I might have found a transformation that reduces that requirement.)
What time scales are being considered?
For the particular example parameters given earlier, here are the S values corresponding to T=1:60 :
[.2072590928183311, .2044393299409702, .2016129607336800, .1989365188764057, .1965116411993847, .1943628414410152, .1924755755786901, .1908221440403525, .1893731280492593, .1881015672429913, .1869840994556714, .1860009411324904, .1851354816011146, .1843737955734661, .1837041854608264, .1831167873386968, .1826032442154253, .1821564396382651, .1817702819421725, .1814395297312950, .1811596504570243, .1809267054062888, .1807372557388538, .1805882853256427, .1804771370389273, .1804014598566101, .1803591647003469, .1803483873624612, .1803674572161160, .1804148706684868, .1804892685245436, .1805894165925309, .1807141889913439, .1808625537224179, .1810335601503601, .1812263281018650, .1814400383449575, .1816739242529594, .1819272644918681, .1821993765976739, .1824896113327941, .1827973477292435, .1831219887411948, .1834629574418072, .1838196937091338, .1841916513539489, .1845782956487980, .1849791012227362, .1853935502903118, .1858211311865575, .1862613371822442, .1867136655555605, .1871776168978373, .1876526946320406, .1881384047236041, .1886342555638410, .1891397580067379, .1896544255404400, .1901777745752472, .1907093248304763]
This is almost quadratic looking.
I decided to have a look to see how sensitive the solution is to the other parameters. The first one I looked at was P, but for whatever reason, the symbolic package I was using was unable to isolate S for a symbolic P.
The second one I tried was "r" -- and it turns out the solution is very sensitive to r.
Below, I have used NaN to indicate there is no (real-valued) solution.
Over r=0:0.0025:0.1, with T=25, S is
[.2367869077192663, .2334774001956742, .2299868419834384, .2263010809075183, .2224039543449438, .2182768445411721, .2138980991245670, .2092422631355814, .2042790415947689, .1989718669475625, .1932758698934157, .1871349179656345, .1804771370389273, .1732078401278894, .1651977495076567, .1562619958566648, .1461191355663390, .1343004223448158, .1199064674372540, .1006878125253988, 0.3419789628568295e-1, NaN, 0.8831092249680447e-3, 0.5260340496896748e-3, 0.1079583955841704e-2, 0.1788956732959545e-2, 0.2287174855937050e-2, 0.4388587665304212e-2, 0.1379940252933243e-2, 0.6399063398417710e-3, 0.2419694982600019e-2, 0.1031180824683200e-2, 0.1583211803026529e-2, 0.4178098067335098e-2, 0.2577486078312967e-2, 0.1556143097211814e-2, 0.5175808895800029e-2, 0.4113080725843936e-2, 0.6998707813988716e-2, 0.5442013674273168e-2, 0.4215142482463095e-2]
Zeroing in, over r=0.0475:.0001:0.0550, S is
[.1006878125253988, 0.9974259341536431e-1, 0.9877724005446151e-1, 0.9779052860862733e-1, 0.9678110540419658e-1, 0.9574746677162544e-1, 0.9468793467747240e-1, 0.9360062701619107e-1, 0.9248342105753623e-1, 0.9133390801740799e-1, 0.9014933596584605e-1, 0.8892653718916388e-1, 0.8766183449599609e-1, 0.8635091848826506e-1, 0.8498868397759661e-1, 0.8356900758188733e-1, 0.8208443837911595e-1, 0.8052575607154917e-1, 0.7888131990197861e-1, 0.7713607271755982e-1, 0.7526994658544382e-1, 0.7325516120267416e-1, 0.7105129925951827e-1, 0.6859540577945885e-1, 0.6577910566449783e-1, 0.3419789628568295e-1, 0.3893049485913096e-1, NaN, NaN, NaN, NaN, NaN, 0.1843937661456162e-3, NaN, 0.1275394361371588e-3, NaN, NaN, NaN, 0.2239007614006089e-3, NaN, NaN, NaN, NaN, 0.3999523364767706e-3, NaN, NaN, NaN, 0.7500544155135456e-3, NaN, 0.8716666575457631e-3, NaN, 0.7348839946741266e-3, NaN, NaN, NaN, NaN, NaN, 0.2960633693250945e-3, NaN, NaN, 0.1944568319446463e-3, NaN, NaN, 0.8734373143513995e-3, 0.4175360507625134e-3, 0.5940891524851323e-3, 0.1103532033792065e-2, 0.7104593149570572e-4, 0.2998481217286259e-3, 0.3305483919817678e-3, 0.1136433557052380e-2, 0.6861591898190689e-3, 0.1023329090028364e-2, 0.1434638051142099e-2, 0.1347607839143373e-2, 0.8831092249680447e-3]
Yes, there is a big drop from 0.0499 to 0.0500, and Yes, 0.0501 is slightly higher -- but then there is a gap of values and then a mix of values that exist and that do not.
As I was using a symbolic math package, the exact values at which problems occurred likely depended upon exactly what the decimal r value got reduced to as a fraction.

댓글을 달려면 로그인하십시오.


J.
J. 2011년 12월 16일
Send me an e-mail and I will send you an m-file for it. futrbllnr@gmail.com.

카테고리

Help CenterFile Exchange에서 Conversion Between Symbolic and Numeric에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by