[R] Reversing the Equation to find value of variable

2014-01-06 Thread Katherine Gobin
Dear R forum I have following variables - EAD = 1 LGD = 0.45 PD = 0.47 M = 3 # Equation 1 R = 0.12*(1-exp(-50*PD))/(1-exp(-50)) + 0.24*(1-(1-exp(-50*PD))/(1-exp(-50))) b = (0.11852 - 0.05478 * log(PD))^2 K = (LGD * pnorm((1 - R)^(-0.5) * qnorm(PD) + (R / (1 - R))^0.5 * qnorm(0.999)) -

Re: [R] Reversing the Equation to find value of variable

2014-01-06 Thread Berend Hasselman
On 06-01-2014, at 12:41, Katherine Gobin katherine_go...@yahoo.com wrote: Dear R forum I have following variables - EAD = 1 LGD = 0.45 PD = 0.47 M = 3 # Equation 1 R = 0.12*(1-exp(-50*PD))/(1-exp(-50)) + 0.24*(1-(1-exp(-50*PD))/(1-exp(-50))) b = (0.11852 - 0.05478 *

Re: [R] Reversing the Equation to find value of variable

2014-01-06 Thread Frede Aakmann Tøgersen
Hi Reading the error message carefully you can see that f() is not defined at 0: uniroot(f, c(0, 1)) Error in uniroot(f, c(0, 1)) : f.lower = f(lower) is NA f(0) [1] NaN If you plot f() in the interval (0,1) then you'll see there is two solutions: uniroot(f, c(0.0001, 1)) Error in

Re: [R] Reversing the Equation to find value of variable

2014-01-06 Thread Katherine Gobin
Dear Sir, Thanks a lot for your wonderful guidance. It gave me a new vision to look at teh equations. Really appreciate. Thanks a lot once again. Katherine On Monday, 6 January 2014 5:31 PM, Frede Aakmann Tøgersen fr...@vestas.com wrote: Hi Reading the error message carefully you can