a3_sol.pdf

# A imposing conditions for i 2 n we get i x k 2 p k 1

• Homework Help
• 14
• 100% (1) 1 out of 1 people found this document helpful

This preview shows pages 11–14. Sign up to view the full content.

a) Imposing conditions for i = 2 , ..., n , we get i X k =2 P k - 1 ( t i ) = P i ( t i ) + i X k =2 P k - 1 ( t i ) = P i ( t i ) = 0 i X k =2 P 0 k - 1 ( t i ) = P 0 i ( t i ) + i X k =2 P 0 k - 1 ( t i ) = P 0 i ( t i ) = 0 i X k =2 P 00 k - 1 ( t i ) = i X k =2 P 00 k - 1 ( t i ) + P 00 i ( t i ) = P 00 i ( t i ) = 0 Since P i ( t ) = a i + b i ( t - t i ) + c i ( t - t i ) 2 + d i ( t - t i ) 3 P 0 i ( t ) = b i + 2 c i ( t - t i ) + 3 d i ( t - t i ) 2 P 00 i ( t ) = 2 c i + 6 d i ( t - t i ) we get P i ( t i ) = 0 = a i = 0 P 00 i ( t i ) = 0 = b i = 0 P 000 i ( t i ) = 0 = c i = 0 Therefore f ( t ) = n X i =1 P i ( t ) I i ( t ) = a 1 + b 1 ( t - t 1 ) + c 1 ( t - t 1 ) 2 + n X i =1 d i ( t - t i ) 3 I i ( t ) which has ( n + 3) unknown parameters. b) f 0 ( t 1 ) = 0 = P 0 1 ( t 1 ) = 0 = b 1 = 0 so f ( t ) further reduces to f ( t ) = a 1 + c 1 ( t - t 1 ) 2 + n X i =1 d i ( t - t i ) 3 I i ( t ) 11

This preview has intentionally blurred sections. Sign up to view the full version.

Substituting into ( 6 ) gives P j = K X k =1 C j,k a 1 + c 1 ( τ k - t 1 ) 2 + n X i =1 d 1 ( τ k - t i ) 3 I i ( τ k ) ! = a 1 K X k =1 C j,k + c 1 K X k =1 C j,k ( τ k - t 1 ) 2 + n X i =1 d i K X k =1 C j,k ( τ k - t i ) 3 I i ( τ k ) Code and output for b) and c) 1 % 2 % Setup bond data 3 % 4 5 M = [ 0 , 1 , 2 , 4 , 5 , 8 , 9 , 1 0 ] ' ; % m a t u r i t i e s 6 J = l e n g t h (M) ; % number of bonds 7 8 % p r i c e s 9 P = [100 , 99.821 , 98.3203 , 98.0313 , 97.1172 , 91.3438 , 95.0234 , 9 9 . 0 0 0 0 ] ' ; 10 11 % coupons ( paid semi - a n n u a l l y ) 12 c = [ 0 , 0.6875 , 0.6875 , 1.0000 , 1.0000 , 0.8125 , 1.1250 , 1 . 3 7 2 5 ] ' ; 13 14 % payment times i n y e a r s 15 tau = ( 0 : 0 . 5 :M( end ) ) ' ; 16 17 % 18 % Build payment matrix C ( payment times by no . of bonds ) 19 % - each row corresponds to a payment time ( tau = 0 , 0 . 5 , 1 , 1 . 5 , . . . , 9 . 5 , 1 0 ) 20 % - each column corresponds to a bond 21 % 22 23 C = z e r o s ( l e n g t h ( tau ) , J ) ; 24 25 f o r j = 1: J 26 C( 1:2 * M( j ) , j ) = c ( j ) ; 27 C( 2 * M( j ) +1, j ) = c ( j ) + 100; 28 end 29 30 %C( 1 , 2 : end ) = 0; % should zero out payments f o r bonds 2 to 8 at tau 1=0 31 % ( see note below i n s o l u t i o n ) 32 33 % 34 % Create s p l i n e matrix A 35 % 36 knots = [ 0 , 1 , 2 , 4 , 5 , 8 , 1 0 ] ' ; 37 n = l e n g t h ( knots ) - 1; 38 39 % f i r s t two columns c o r r e s p o n d i n g to parameters a 1 , c 1 40 A = [ sum(C) ' C ' * ( ( tau - knots (1) ) .ˆ2 ) ] ; 41 42 % columns f o r d 1 , . . . , d n 43 f o r i = 1: n 44 dt = max( tau - knots ( i ) , 0) ; 45 a = C '* dt . ˆ 3 ; 46 A = [A a ] ; % stack h o r i z o n t a l l y to A 47 end 12
48 49 % 50 % Solve and d i s p l a y the s o l u t i o n 51 % 52 x = A \ P; % P i s the bond p r i c e s v e c t o r 53 x 54 55 % 56 % Plot the d i s c o u n t curve 57 % 58 t = 0 : 0 . 1 : 1 0 ; 59 60 y = x (1) + x (2) * ( t - knots (1) ) . ˆ 2 ; 61 f o r i = 1: n 62 y = y + x(2+ i ) * max( t - knots ( i ) ,0) . ˆ 3 ; 63 end 64 65 p l o t ( t , y , ' k ' ) 66 x l a b e l ( ' time ' ) 67 y l a b e l ( ' d i s c o u n t curve ' ) 68 69 % 70 % Plot the zero curve ( part c ) 71 % 72 r = - log ( y ) ./ t ; 73 f i g u r e 74 p l o t ( t , r , ' k ' ) ; 75 x l a b e l ( ' time ' ) 76 y l a b e l ( ' zero curve ' ) Coefficients obtained: x = 1.0000e+00 % a_1 -3.5606e-02 % c_1 1.3393e-02 % d_1 -1.5092e-02 % d_2 1.8611e-03 % d_3 -1.0798e-04 % d_4 -2.6758e-04 % d_5 1.6402e-03 % d_6 13

This preview has intentionally blurred sections. Sign up to view the full version.

0 2 4 6 8 10 time 0.7 0.75 0.8 0.85 0.9 0.95 1 discount curve (b) Discount Curve 0 2 4 6 8 10 time 0 0.005 0.01 0.015 0.02 0.025 0.03 0.035 zero curve (c) Yield Curve Note: The C matrix provided in the sample code q6.m should be modified to zero out payments at τ 1 for bonds 2 , ..., 8, i.e. C(1,2:end) = 0; % line 30 in the code above This would result in the slightly modified solution below. Both solutions are acceptable. x = 1.0000e+00 % a_1 -2.0559e-02 % c_1 5.1554e-03 % d_1 -2.6683e-03 % d_2 -3.0829e-03 % d_3 1.0227e-03 % d_4 -4.1884e-04 % d_5 8.1008e-04 % d_6 0 2 4 6 8 10 time 0.75 0.8 0.85 0.9 0.95 1 discount curve (b) Discount Curve 0 2 4 6 8 10 time 0 0.005 0.01 0.015 0.02 0.025 0.03 zero curve (c) Yield Curve 14
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern