Serving the Quantitative Finance Community

 
User avatar
aharvey8
Posts: 1
Joined: July 4th, 2005, 8:29 pm

Hull & White CDO model implementation

September 16th, 2005, 6:19 pm

Jennifer,I don't think that's correct. Re-reading pages 27 and 28 of the paper, there is one of two things he could have meant.1) The "Probability Shift" happens each time you add an asset.2) "Probability Shift" happens K times for for each of your assets.I tend to believe it's the later. In other words, P* and A*, refer to the P and A vectors as they stand when considering the kth bucket. If I do (1) above, I get some very strange results.I'm thinking that perhaps I just have the buckets to large, especially for the more senior notes, where my buckets are several times as large as for the equity.Does anyone have a feel for approx. how many buckets you will need in order to get accurate results? Perhaps 1000 is not nearly enough?Andrew
 
User avatar
jenniferlwj
Posts: 4
Joined: February 25th, 2005, 2:35 am

Hull & White CDO model implementation

September 16th, 2005, 8:18 pm

Andrew,I agreed with points (1) and (2). But in your implementation, you fetch the P_star inside the k-loop, and after you update the probability and the mean, P_star changed also. Should P_star refers to the probability for each bucket k, before we add the new name? For j = 0 To (nAssets - 1) DefProb = Range("defaultProbs").Offset(j + 1, timeStep + 1).Value Lj = Range("Notional").Offset(j + 1, 0).Value * (1# - recovery) ALPHAj = CondDefProb(M, T, DefProb, corr) For i = 0 To (nBuckets - 1) P_prev(i) = P(i) A_prev(i) = A(i) Next i For k = 0 To (nBuckets - 1) UK = FindUK(A_prev(k) + Lj, k, Upper, Lower) Pstar = P_prev(k) PUKstar = P_prev(UK) Astar = A_prev(k) AUKstar = A_prev(UK) .....JenQuoteOriginally posted by: aharvey8Jennifer,I don't think that's correct. Re-reading pages 27 and 28 of the paper, there is one of two things he could have meant.1) The "Probability Shift" happens each time you add an asset.2) "Probability Shift" happens K times for for each of your assets.I tend to believe it's the later. In other words, P* and A*, refer to the P and A vectors as they stand when considering the kth bucket. If I do (1) above, I get some very strange results.I'm thinking that perhaps I just have the buckets to large, especially for the more senior notes, where my buckets are several times as large as for the equity.Does anyone have a feel for approx. how many buckets you will need in order to get accurate results? Perhaps 1000 is not nearly enough?Andrew
 
User avatar
aharvey8
Posts: 1
Joined: July 4th, 2005, 8:29 pm

Hull & White CDO model implementation

September 19th, 2005, 4:28 pm

Jen,I understand what you're saying, but when I try that I don't get probabilities that sum to one. I can't quite understand why. I think it must have something to do with the UK == k condition, where you take a probability out of the prior P vector. I'll have to think about this some more this afternoon.Andrew
 
User avatar
anuj76
Posts: 0
Joined: June 6th, 2005, 7:20 pm

Hull & White CDO model implementation

September 20th, 2005, 8:41 pm

Andrew,I haven't taken a careful look at your model as yet, but I did notice that your expression for the conditional default probability seems to be incorrect.Your expression has sqr(1-corr^2) in the denominator. Shouldn't it be sqrt(1-corr^2)?Anuj
 
User avatar
yomi
Posts: 2
Joined: July 14th, 2002, 3:00 am

Hull & White CDO model implementation

September 21st, 2005, 6:43 am

In visual basic, the function, sqr represents square root.
 
User avatar
ljcao
Posts: 0
Joined: September 10th, 2005, 11:52 am

Hull & White CDO model implementation

September 21st, 2005, 9:21 am

Hi, I checked your code. I find that the bucket size in different tranche is different. THe bucket size in Senior Tranche is much larger tghan that of equity tranche. But the paper states that the bucket size is the same for all except for the final one.
 
User avatar
ljcao
Posts: 0
Joined: September 10th, 2005, 11:52 am

Hull & White CDO model implementation

September 21st, 2005, 9:22 am

Hi, Andrew:How come the bucket size in different trache in your code is different? It should be the same.
 
User avatar
ljcao
Posts: 0
Joined: September 10th, 2005, 11:52 am

Hull & White CDO model implementation

September 21st, 2005, 9:58 am

Hi, Andrew: I also feel that the correl in your code should be sqrt(0.4) since the correl in your code is the same as a(i) value.Lijuan
 
User avatar
ljcao
Posts: 0
Joined: September 10th, 2005, 11:52 am

Hull & White CDO model implementation

September 21st, 2005, 12:47 pm

Hi, Andrew: I re_checked your program. I found out another error. When Uk==k, you forget to update the probability of default and mean-loss for UK in your code.Lijuan
 
User avatar
aharvey8
Posts: 1
Joined: July 4th, 2005, 8:29 pm

Hull & White CDO model implementation

September 21st, 2005, 2:20 pm

ljaco,Thanks for the comments,In reference to the correlation, I'm making correlation equal to the square root of the user-supplied number when I read it from the sheet. Also, they make reference to the fact that you can (and probabably should) have different bucket sizes for each of the tranches to make the algorithm more efficient.I've taken a slightly different approach to the problem in getting the probabilities. Here's a snapshot of what I've done more recently: (in C++)int nAssets = Port.getnCredits();double Lj = 0.0;double ALPHAj = 0.0;double corr = sqrt(As.getFlatCorrelation());double tol = 1.00e-300;int UK = 0;double Pstar = 0.0;double PUKstar = 0.0;for (int j = 0; j < nAssets; j++) { Lj = Port.Credits[j].getNotional() * (1.0 - Port.Credits[j].getRecoveryRate()); ALPHAj = CND((invCDF(ST.ReturnSurvTimeDist(j,Period)) - corr * M) / sqrt(1.0 - pow(corr , 2.0))); for (int i = 0; i < nBuckets; i++) { P_prev = P; A_prev = A; } for (int k = 0; k < nBuckets; k++) { UK = FindUK(A_prev[k]+Lj,k,B); Pstar = P_prev[k]; PUKstar = P_prev[UK]; U[k] = UK; if (UK > k) { P[k] = P_prev[k] - P_prev[k] * ALPHAj; Diff[k] = P_prev[k] - P[k]; } else { P[k] = P_prev[k]; Diff[k] = 0.0; } if (Pstar < tol || ALPHAj < tol) { } else { if (UK > k) { A[k] = A_prev[k]; A[UK] = (PUKstar * A_prev[UK] + Pstar * ALPHAj * (A_prev[k] + Lj)) / (PUKstar + Pstar * ALPHAj); } else if (UK == k) { A[k] = A_prev[k] + ALPHAj * Lj; } else { A[k] = A[k]; } } } for (int k = 0; k < nBuckets; k++) { if (k == 0) { P[k] = P[k]; } else { P[U[k-1]] = P[U[k-1]]+ Diff[k-1]; } }}This is perhaps a very inelegant solution, but I think it works. I'll try putting this back into VBA later this week.Cheers,Andrew
 
User avatar
ljcao
Posts: 0
Joined: September 10th, 2005, 11:52 am

Hull & White CDO model implementation

September 22nd, 2005, 2:06 am

Hi, Andrew: Thanks for your reply. Now I am also developing this program using C. Your program gives me a lot of help. In addition, may I ask you a question? 1. As we calculate the conditional PD and thus unconditional PD, shall we calculate Expected loss in each buck by EL= PD( uncondiation)* 0.5(B[k-1]+b[k] ) or EL=PD*mean_loss? If the former one is used, why so we calculate the mean loss? The methods introduced in the paper is not very clear. 2. The second question is the expected loss in each step is the sum of expected loss in each buck, right or not? THen we can allocate the total expected loss into different trache to calculate the spread of the tranche, right or not?Thanks for your help in advance.Lijuan
 
User avatar
ljcao
Posts: 0
Joined: September 10th, 2005, 11:52 am

Hull & White CDO model implementation

September 23rd, 2005, 7:46 am

Hi, Andrew:May I ask you one question regarding the HullWhite Paper? In your spread sheet, why you calculate the Default leg using unconditional PD but the premium leg using conditional PD? Can you pls. give me a little hint?ThanksLJ
 
User avatar
aharvey8
Posts: 1
Joined: July 4th, 2005, 8:29 pm

Hull & White CDO model implementation

September 23rd, 2005, 10:41 pm

ljcao,Both legs are calculated with the unconditional distributions. The PD is the probabability that losses are in bucket K, therefore, to calculate the premium leg, I use PD x remaining principle x Discount factor x YearFrac to take the expectation. For the Default Leg, its i bit more involved. I compute the P(n,T) as they describe in the paper, and then calculate the probability that "a loss equal to the midpoint of bucket K FIRST happens between T1 and T2" using the equation on the top of page 11. Note that the resulting probabilities to not sum to one any longer. This makes sence, since it's not certain that the FIRST time losses enter that bucket will happen anytime within the tenor of the instrument.I think the expectation could be phrased as:(probabiltiy that the losses enter bucket k for the first time at time t)x(Loss, given that you are entering bucket k from bucket k-1,at time t)x (Discount factor)The first line follows from the paper. The second line is the difference in cumulative losses between bucket K and bucket K-1. For the first bucket, taking this difference is not neccessary. Cumulative losses are defined for Tranches, not the enire portfolio. More concretely:CumulativeLosses(k) = MAX(MIN(BucketMidpoint(k)-TrancheLowerThreshold,TranchThickness),0)Hope that answers your question.Andrew
 
User avatar
ljcao
Posts: 0
Joined: September 10th, 2005, 11:52 am

Hull & White CDO model implementation

September 24th, 2005, 12:55 am

Thanks, Andrew. Let me think about it.
 
User avatar
mf42
Posts: 0
Joined: January 13th, 2005, 1:24 pm

Hull & White CDO model implementation

September 26th, 2005, 8:42 am

Dear Andrew,may I ask you a question on your way you implemented the calculation of the mean loss in the kth bucket?Consider the following situation: K = 2, each LGD = 1 with DefProb Alpha1, Alpha2, bucket = [0,2].Performing first iteration step leads to A[1] = 1. Then adding the second instrument you calculate first A[1] = 1(that is (alpha1 * 1 + alpha2*(1-alpha1))/(alpha1 + alpha2*(1-alpha1)) ) which corresponds to the eventdefaulting 1. instrument OR (surviving 1.instrument and defaulting 2.instrument). You continue then to the next bucket, which is in this case [0,2]. You have UK ==k and you reset A[1] = 1 + alpha2, regardless of what you calculated the step before. Doesn't it have to be cumulative in each iteration step like you calculated the conditional probs P[k] ?Cheers,