0

I need to calculate distance to default (using Merton's model) for a time series data set of 424 firms. I have specified the variables:

library(DtD)

S <- BS_call(V, D, T, r, vol)

S <- E1
D <- face
T <- 1
vol <- stock_vol
r <- rf
get_underlying(S,D, T, vol, r)

The last line should calculate V from the first function. But it gives me this error: Error in eval(substitute(expr), data, enclos = parent.frame()) : Assertion on 'D' failed: Element 408 is not >= 1e-016.

What can I do about it? And this is only the first step to the distance to default, I still need to find inferred firm's volatility and then DD. I hope someone knows the answer to this.

Nadja
  • 1
  • Hi welcome to so, did you check that element 408 is greater than 0? – Bruno Apr 15 '21 at 15:49
  • Hi @Bruno ! Thanks for commenting! The data set I have for D has some zeros in it, yes, as it's face value of debt, that can sometimes be 0. Also, I'm not sure which element would be 408, as it's a table of 424 columns and 20 raws. Would it be the 1st raw and column 408 then? – Nadja Apr 15 '21 at 16:18
  • So, yes, I found out what is 408 and yes, it is the first zero in the data set, but there are many more. Is there any way around it? – Nadja Apr 15 '21 at 16:21
  • Hi Nadja. Welcome to SO! This question will be much easier to answer if you include a minimal, reproducible example, as per this guide: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Captain Hat Apr 15 '21 at 21:45
  • I added more info below in the answer – Nadja Apr 16 '21 at 07:28

1 Answers1

0
        A2.MI  AAL.L AALB.AS   ABBN.S  ABF.L ACCP.PA ACE.MI ACPP.WA   ACS.MC ACX.MC

2000-01-01 0.5624 0.3553 0.3252 0.240100 0.3855 0.3007 0.5664 0.8937 0.476700 0.3362 2001-01-01 0.2291 0.3682 0.3974 0.557800 0.2358 0.3998 0.2539 0.7270 0.195600 0.3812 2002-01-01 0.2906 0.3566 0.3155 0.912128 0.2200 0.3886 0.3359 0.5680 0.172600 0.3032 2003-01-01 0.1410 0.2737 0.3840 0.622400 0.1852 0.2581 0.2695 0.4060 0.135700 0.1936 2004-01-01 0.1065 0.2207 0.2246 0.233100 0.1083 0.1435 0.2546 0.4085 0.090216 0.1409 2005-01-01 0.1825 0.2621 0.2349 0.156800 0.1366 0.1576 0.1750 0.3545 0.204300 0.1986 2006-01-01 0.1457 0.1564 0.2924 0.236500 0.1719 0.1651 0.1735 0.3212 0.127600 0.2371 2007-01-01 0.2085 0.2550 0.2479 0.238300 0.1965 0.2046 0.2414 0.3738 0.208800 0.2569 2008-01-01 0.2887 0.4766 0.3929 0.451800 0.2420 0.3731 0.2664 0.2894 0.261100 0.3095 2009-01-01 0.2589 0.4788 0.6687 0.266400 0.1806 0.4180 0.2020 0.2518 0.248400 0.3935 2010-01-01 0.2313 0.3819 0.3134 0.269700 0.1528 0.2243 0.1215 0.1504 0.250700 0.3373 2011-01-01 0.2396 0.2172 0.3035 0.228300 0.1605 0.3468 0.1641 0.2770 0.186400 0.2903 2012-01-01 0.4578 0.2920 0.2016 0.212100 0.1385 0.2822 0.3608 0.2574 0.519700 0.2531 2013-01-01 0.3948 0.2568 0.1376 0.140200 0.2640 0.2069 0.3055 0.1572 0.227200 0.2077 2014-01-01 0.2120 0.2348 0.1613 0.116000 0.2574 0.2142 0.2402 0.1813 0.161700 0.1751 2015-01-01 0.2025 0.4006 0.1864 0.276800 0.1922 0.2689 0.1825 0.1679 0.321400 0.4289 2016-01-01 0.2554 0.8185 0.2334 0.181500 0.2688 0.2669 0.3203 0.1370 0.255700 0.3339 2017-01-01 0.1620 0.3685 0.1298 0.174100 0.2635 0.1348 0.2892 0.1404 0.158000 0.1802 2018-01-01 0.1915 0.2420 0.1444 0.189500 0.2146 0.2027 0.2034 0.2471 0.241400 0.2840 2019-01-01 0.1517 0.2758 0.3030 0.199000 0.2573 0.2049 0.1323 0.1939 0.185500 0.2581

So, since I posted my question yesterday and Bruno pointed out for me to check whether the value is 0 in the element 408, I fixed that. It was in fact 0 and because of the function it's used in, it could not be 0 (because something is divided by it), so I corrected that. However, right after that R shows the same message again, but regarding a different data set (see a sample of it in this message above, it's a time series of stock volatilities of different firms called stock_vol. Here are 20 firms in the subset, but I have 424 in my original set.). And this time the element is not 0. What can I do now?

Here is my code:

S <- E1 D <- face T <- 1 vol <- stock_vol r <- rf get_underlying(S,D, T, vol, r) Error in eval(substitute(expr), data, enclos = parent.frame()) : Assertion on 'vol' failed: Element 20 is not >= 1e-016.

Nadja
  • 1