Dear R forum I have following variables -
EAD = 10000 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)) - PD * LGD) * (1 - 1.5 * b)^(-1) * (1 + (M - 2.5) * b) RWA = K * 12.5 * EAD > RWA [1] 22845.07 # _________________________________________________________________ # MY Problem In the above part, knowing values of LGD, EAD, M and PD, the value of RWA was calculated. However, I need to go reverse way in the sense knowing the values of LGD, EAD, M and RWA, I need to find value of PD. So I have tried to use uniroot as (RWA - K * 12.5 * EAD and used the above equations i place of K and R) RWA = 22845.07 LGD = 0.45 EAD = 10000 M = 3 f = function(x) RWA - (LGD*pnorm((1-(0.12*(1-exp(-50*x))/(1-exp(-50))+0.24*(1-(1-exp(-50*x))/(1-exp(-50)))))^(-0.5)*qnorm(x)+((0.12*(1-exp(-50*x))/(1-exp(-50))+0.24*(1-(1-exp(-50*x))/(1-exp(-50))))/(1-(0.12*(1-exp(-50*x))/(1-exp(-50))+0.24*(1-(1-exp(-50*x))/(1-exp(-50))))))^0.5*qnorm(0.999))-x*LGD) * (1-1.5*((0.11852-0.05478 * log(x))^2))^(-1)*(1+(M-2.5)*((0.11852-0.05478 * log(x))^2))*12.5*EAD uniroot(f, c(0,1), tol = 0.0000000001) I get following error - > uniroot(f, c(0,1), tol = 0.0000000001) Error in uniroot(f, c(0, 1), tol = 1e-10) : f.lower = f(lower) is NA Kindly guide as I am not sure if uniroot is the correct way of doing it or not. Ideally, I should be getting the PD value of 0.47. With regards Katherine [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.