course bg
EduPristine>Blog>CFA Fixed Income: Mortgage Backed Securities Valuation: Part 3

CFA Fixed Income: Mortgage Backed Securities Valuation: Part 3

November 5, 2013

This blog is an extension of our blog on #CFA Fixed Income: Mortgage Backed Securities: Part 2

Consider a freshly issued MBS with C coupon and that has mortgage loans of 30-year maturity. To value this security, we would perform the following steps:

1. Generate an interest rate path using Hull-White

In the area of financial mathematics, the Hull-White model endeavors to predict future interest rates. It can be of great help in valuing interest rate derivatives or bonds in an open market.

2. Calculate expected principal and interest payment for a given month

3. Using interest rate projections and prepayment model, project cash-flow due to prepayments for the same month

4. Get the total cashflow for the month

5. Similarly, project monthly cash flows for all the 30 years

6. Discount the cashflow to get the present value

7. This value is actually value of the MBS on a given path

Repeat steps 1-7 several times and average the value of MBS to get final value of MBS


Let us write a code in R language to value MBS through Two Factor Hull-White Model:

Let’s create a function with two inputs

#WAC – Weighted Average Coupon

MBS_pricing_withPP = function (WAC,r0) {

SYset=c(0.94, 0.76, 0.74, 0.95, 0.98, 0.92, 0.98, 1.1, 1.18, 1.22, 1.23, 0.98);

#Seasonality: Generally, monthly seasonality affects prepayments.


sigma=0.02;kappa=0.2;rbar=0.06;T=30;#These are CIR model specification

N=200;#We are going to generate 200 simulation paths

n=T*12;#There are in total 12 months in year, each month is a time step

dt=1/12;#Time step is equal to a month



r=matrix(0, N,n);




for (t in 1:n) { # months

if (t>1)


r[,t]=r[,t-1]+kappa*(rbar-r[,t-1])*dt+sigma*sqrt(r[,t-1])*dz[,t]*sqrtdt;#CIR r(t)=r(t-1)+dr




r[,1]=r0;#for all paths initial r is set to r0



#prepayment part

RI[,t]=0.28+ 0.14*atan(-8.57+430*(WAC-r[,t]));#refinancing Incentive

BM[,t]=0.3+0.7*PV[,t]/borrow;# Burnout Multiplier


if (t%%12==0) { month=12; } else { month=t%%12;}


CPR[,t]=RI[,t]*BM[,t]*Age[t]*SY[t];#conditional prepayment rate

MP[,t]=PV[,t]*WAC/12/(1-1/(1+WAC/12)^(n-t)); #monthly payment part

IP[,t]=PV[,t]*WAC/12;#Interest Payment

SP[,t]=MP[,t]-IP[,t];#Scheduled Principal payment

PP[,t]=(1-(1-CPR[,t])^(1/12))*(PV[,t]-SP[,t]);# prepayment part

C[,t]=IP[,t]+SP[,t]+PP[,t]; #monthly cash flow

if (t==1) {PVcashflow[,t]=exp(-sum(r[,1:t])*dt)*C[,t];} else {PVcashflow[,t]=exp(-rowSums(r[,1:t])*dt)*C[,t];}

if(t<n) {PV[,t+1]=PV[,t]-(SP[,t]+PP[,t]);}#outstanding balance



# outputs




return(list(price=price, cpr=meanCPR,cash=meanCash));


p = MBS_pricing_withPP(0.06,0.04);




Last three steps are for the output and following are the results:

We got the price of the MBS as $105.4626

#CFA Fixed Income MBS

CPR: Conditional Prepayment Rate

#CFA Fixed Income MBS


#CFA Fixed Income MBS


#CFA Fixed Income MBS


#CFA Fixed Income MBS

For any queries, contact us by posting your questions on our forum!

About Author

avatar EduPristine

Trusted by Fortune 500 Companies and 10,000 Students from 40+ countries across the globe, it is one of the leading International Training providers for Finance Certifications like FRM®, CFA®, PRM®, Business Analytics, HR Analytics, Financial Modeling, and Operational Risk Modeling. EduPristine has conducted more than 500,000 man-hours of quality training in finance.


Interested in this topic?

Our counsellors will get in touch with you with more information about this topic.

* Mandatory Field

`````````````````````````````````````````````````` Post ID = 40298