The Wiley Finance series contains books written specifically for finance and investment professionals, as well as sophisticated individual investors and their financial advisors. Book topics range from portfolio management to e-commerce, risk management, financial engineering, valuation and financial instrument analysis, as well as much more. For a list of available titles, visit our website at www.WileyFinance.com.
Founded in 1807, John Wiley & Sons is the oldest independent publishing company in the United States. With offices in North America, Europe, Australia and Asia, Wiley is globally committed to developing and marketing print and electronic products and services for our customers' professional and personal knowledge and understanding.
Investing in
Mortgage-Backed
and Asset-Backed
Securities
Financial Modeling with R and Open Source Analytics + Website
GLENN M. SCHULTZ, CFA
FOREWORD BY
FRANK J. FABOZZI, PH.D., CFA
Published by John Wiley & Sons, Inc., Hoboken, New Jersey.
Published simultaneously in Canada.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning, or otherwise, except as permitted under Section 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600, or on the Web at www.copyright.com. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: While the publisher and author have used their best efforts in preparing this book, they make no representations or warranties with respect to the accuracy or completeness of the contents of this book and specifically disclaim any implied warranties of merchantability or fitness for a particular purpose. No warranty may be created or extended by sales representatives or written sales materials. The advice and strategies contained herein may not be suitable for your situation. You should consult with a professional where appropriate. Neither the publisher nor author shall be liable for any loss of profit or any other commercial damages, including but not limited to special, incidental, consequential, or other damages.
For general information on our other products and services or for technical support, please contact our Customer Care Department within the United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media such as a CD or DVD that is not included in the version you purchased, you may download this material at http://booksupport.wiley.com. For more information about Wiley products, visit www.wiley.com.
Library of Congress Cataloging-in-Publication Data:
Names: Schultz, Glenn M., author.
Title: Investing in mortgage and asset backed securities, $+$ website :
financial modeling with r and open source analytics / Glenn M. Schultz ;
Glenn's 20+ years of experience in structured finance is reflected in this book. Portfolio management, MBS investment banking and structuring, and loan level prepayment modeling are among his expertise. Glenn contributed to The Handbook of Fixed-Income Securities, several editions of The Handbook of Mortgage-Backed Securities, and The Handbook of Nonagency Mortgage-Backed Securities. In 2003, he was honored for his structuring expertise with the IDD/ASR award for the Most Innovative ABS Transaction of the Year.
Glenn's broad experience highlights that investing in mortgage-backed securities requires a multidisciplinary approach including securities law, structuring techniques, and the modeling of econometric data and consumer behavior, both of which fall under the rubric of big data analysis. Furthermore, the proliferation of data and the analysis thereof have brought the concept of reproducible research to the forefront. Ultimately, research or experiments that can be reproduced are more reliable than those which cannot be reproduced. Reproducing the research of others is not only a checking process but it also provides a jump-point for future exploration. Investing in Mortgage-Backed and Asset-Backed Securities was written in the spirit of reproducible research and introduces Bond Lab, the first object-oriented and open source software that Glenn created for the analysis of mortgage- and asset-backed securities.
Bond Lab is programmed in R, the statistical computing language of choice, and allows the reader to replicate the analysis presented herein, view the code that created the results, and extend the analysis in any direction one chooses. Furthermore, the commercial acceptance of R on cloud computing platforms offers the investor a promise of unlimited scalability. By harnessing the power of R and open source computing, Bond Lab charts the course for the investor to create a custom technology stack meeting and expressing one's unique view with respect to the mortgage-backed securities market, thereby creating true alpha.
Frank J. Fabozzi, Ph.D, CFA Professor of Finance, EDHEC Business School and Editor, Journal of Portfolio Management
Preface
It is not the critic who counts;…The credit belongs to the man who is actually in the arena,…who spends himself in a worthy cause; who at the best knows in the end the triumph of high achievement, and who at the worst, if he fails, at least fails while daring greatly, so that his place shall never be with those cold and timid souls who neither know victory nor defeat.
Theodore Roosevelt
Welcome to the arena of structured finance. The purpose of this book is to hone the skills needed to successfully compete in the arena. Bond Lab and the Companion to Investing in MBS are the training tools, both of which are programmed in the R computing language. This analysis presented in this book is based on Bond Lab version 0.0.0.9000. Bond Lab is, to my knowledge, the first open source object-oriented software designed for the analysis of structured securities. Bond Lab allows the reader to replicate the analysis presented herein, as well as extend the analysis in any direction she chooses thereby creating a richer learning experience and greater understanding of the material.
Investing in Mortgage-Backed and Asset-Backed Securities, was written in the spirit of reproducible research and its underlying philosophy is simple: Mortgage-backed securities are not too complex to understand. In fact, the basic valuation techniques applicable to all fixed-income securities also form the foundation for the valuation of mortgage-backed securities (MBS) and asset-backed securities (ABS). The perceived complexity of investing in structured products, like MBS, can be attributed to four sources:
The contingency of residential MBS cash flows, which manifest because the borrower holds the option to prepay and terminate her mortgage obligation early.
Cash flow structuring techniques based on the allocation of principal and interest across real estate mortgage investment conduit (REMIC) structures.
Credit structuring techniques that allocate losses through the capital structure of a transaction.
Valuation techniques that “simulate” the economy—interest rate models.
Organization of the Book
The main goal of this book is to develop a basic framework for the analysis of mortgage- and asset-backed securities using open source software. The financial models presented throughout the book are developed using R [R Core Team 2013], a freely downloaded open source software development environment.
Many people think of R as a statistics package, however it is much more. The R environment is an “integrated suite of software facilities for data manipulation, calculation, and graphical display” [Smith and R Core Team 2013]. As such, R lends itself easily to the development of an integrated financial analysis tool.
Investing in structured products also requires managing large sets of data. Aside from market data, like swap rates and Treasury prices and yields, the structured product investor must also follow borrower transaction data. Examples include voluntary prepayment rates, payment of scheduled principal and interest, and borrower delinquency and default. More often than not the investor must monitor this information at the loan level. Loan level data are becoming more available, and there are a host of vendors that offer the aggregation and delivery of this kind of data. The loan level data that is needed by the investor to monitor collateral performance is also freely available via trustee and/or issuer websites. In this book, we will use MySQL®, also open source, as the data management solution.
Investing in MBS is divided into five parts. Part One, Valuation of Fixed-Income Securities, introduces the reader to the techniques used to value all fixed-income securities.
Chapter 1 begins with the time value of money. It introduces the concept of the present and future value of $1. The concept of the time value of money underlies every investment decision. It is the most basic expression of interest rates that forms the foundation of fixed-income investing.
Chapter 2 covers the theories of the term structure of interest rates, explaining the coupon, spot rate, and forward rate curves. The chapter numerically illustrates the derivation of both spot and forward rates. Numerical examples are provided throughout the chapter to assist the reader in gaining a solid understanding of the term structure of interest rates.
Chapter 3 introduces fixed-income mathematics covering yield to maturity, weighted average life, duration, convexity, and key rate duration. The chapter provides numerical examples as well as the application of each metric.
Chapter 4 integrates Chapters 1 through 3 into a comprehensive framework for the valuation of fixed-income securities; particular attention is paid to assets whose principal amortizes over the life of the investment. Finally, Chapter 5 illustrates fixed income return analysis. The chapter deconstructs horizon return into its components and illustrates how each contributes to the investor's realized rate of return.
Part Two, Residential Mortgage-Backed Securities, introduces the reader to mortgage-backed securities.
Chapter 6 differentiates the characteristics of residential and commercial real estate. The chapter ends by deconstructing the mortgage loan amortization table and outlining key mortgage servicing activities.
Chapter 7 extends the concepts presented in Chapter 6, illustrating mortgage cash flow analysis. Specifically, the chapter takes the reader through the amortization and cash flow analysis of a pool of mortgage loans given borrower prepayment.
Finally, Chapters 8 and 9 provide an overview of the techniques used to analyze the factors influencing mortgage prepayment rates. Chapter 8 illustrates the application of the Cox proportional hazard model to loan level data as a method to explore the drivers of prepayment rates, while Chapter 9 translates the analysis of Chapter 8 into a functioning parametric prepayment model.
Part Three, Valuation of Mortgage-Backed Securities, introduces the reader to the basic valuation techniques used to determine relative value in the mortgage-backed securities market.
Chapter 10 reviews the mortgage dollar roll. The dollar roll is the short-term financing mechanism of the residential mortgage market and represents the starting point of relative value analysis in the residential MBS market.
Chapter 11 presents the tools investors may use to analyze mortgage-backed securities. The chapter addresses liquidity analysis, static cash flow analysis, and finally the application of return analysis to differentiate the relative value of mortgage-backed securities.
Chapter 12 introduces option-adjusted spread (OAS) analysis. OAS analysis is perhaps the least understood and most wrongly applied tool in the mortgage valuation arsenal. The chapter guides the reader through the Cox, Ingersoll, Ross single factor term structure model. The chapter illustrates the motivation of the prepayment model presented in Chapter 9 via the interest rate model and ends with a complete treatment of OAS as an investment decision making tool.
Part Four, Structuring Mortgage-Backed Securities, introduces the reader to the structuring techniques used in the mortgage-backed securities market. MBS structuring relies on the division of principal and interest to create notes derived from MBS cash flows that are tailored to meet investors' unique risk/reward profiles. Further, the structuring techniques used by dealers alter both the timing and valuation of MBS cash flows. Option-adjusted spread analysis is used throughout the section to explore how the division of principal and interest alter mortgage cash flow valuations.
Chapter 13 introduces REMICs and explains the rational for their creation, evolution, and legal structure. The chapter closes by outlining the Bond Lab structuring model.
Chapter 14 kicks off REMIC structuring with stripped mortgage-backed securities (SMBS). A stripped MBS is not a REMIC in terms of its legal formation; however, SMBS are included in the section because they represent the clearest illustration of the division of principal and interest—the key to REMIC structuring and arbitrage.
Chapter 15 presents the sequential REMIC structure, an example of the division of principal via time tranching, which allows a dealer to create bonds of different maturities thereby exploiting investors' term structure preferences to create a profitable arbitrage.
Chapter 16 outlines the planned amortization class (PAC)-companion REMIC. The PAC-companion structure is an example of the division of principal.Rather than time tranching, principal is allocated to each bond within the structure based on the prepayment rate of the underlying MBS.
Chapter 17 completes the sequential REMIC arbitrage illustrating the use of a two-tiered REMIC structure to create an IO class. The structuring difference between the sequential IO and the SMBS IO is explored.
Chapter 18 outlines the PAC-floater-inverse floater structure and completes the PAC-companion arbitrage illustrating the use of derivative execution to create par priced bonds.
Chapter 19 illustrates the use of an accrual bond to “clean-up” the companion bond's tail cash flows and create a long duration security.
Part Five, Mortgage Credit Analysis, covers default modeling, self-insuring mortgage structures, and the basics of sizing mortgage credit enhancement. A self-insuring structure is one whose credit enhancement is internally created which may subject the investor to principal loss resulting from borrower defaults. Thus, it is imperative that the investor understands default modeling, loss simulation, and the allocation of losses across the transaction's capital structure.
Chapter 20 illustrates the use of logistic regression analysis to model mortgage default.
Chapter 21 builds on the analysis presented in Chapter 20 and illustrates the development of a predictive default model.
Chapter 22 introduces the basics of private-label MBS. The chapter covers alternative subordination structures, cross collateralization, as well as the implication of the third-party credit exposure.
Chapter 23 illustrates simulation techniques used to determine mortgage credit enhancement levels. The chapter not only focuses on principal subordination but also illustrates how the investor may use simulation to investigate the adequacy of agency guarantee fees and how those fees relate to principal subordination.
Acknowledgments
The Bond Lab® project would not have been possible without the support of my family and friends. To my wife, Missi, thank your for your neverending support, encouragement, and most importantly, your patience throughout the project. Justin D. Wolf, my best friend, thank you for your tireless efforts editing Investing in Mortgage-Backed and Asset-Backed Securities. You served as a reliable and trusted consultant and editor, meticulously reviewing each sentence, and the conceptual frameworks presented—any remaining ambiguity or grammatical errors are my full responsibility. Frank J. Fabozzi, PhD, CFA—over the years Frank was kind enough to include me in many of his works and together we edited Structured Products and Related Credit Derivatives. This book reflects the insights and experiences gained by working with Frank over many years. Chris J. Carney, your enthusiasm for the Bond Lab project and vision of creating an open source analytic program provided a wellspring of motivation. Steve J. Sinclair, your advice and counsel was invaluable as I navigated the world of object-orientated programming. The R core team, R community, and members of the R-help mailing list provided timely and insightful answers to many of my questions as I developed Bond Lab.
R Software Packages Used
The following R software packages were used for the Bond Lab project. The R packages devtools, roxygen2, and testthat provided the development and documentation environment. In addition, Bond Lab makes use of lubridate, termstrc, and optimx. All the graphics presented herein, with the exception of 13.1, were created using ggplot2 and reshape2, 13.1 was created using GIMP, also open source. I extend my gratitude to the authors and maintainers of these R packages:
devtools, Hadley Wickham and Winston Chang (2015). devtools: Tools to Make Developing R Packages Easier. R package version 1.7.0. http://CRAN.R-project.org/package=devtools.
ggplot2, H. Wickham. ggplot2: elegant graphics for data analysis. New York: Springer, 2009.
lubridate, Garrett Grolemund, Hadley Wickham (2011). Dates and Times Made Easy with lubridate. Journal of Statistical Software 40(3), 1–25.
optimx, John C. Nash, Ravi Varadhan (2011). Unifying Optimization Algorithms to Aid Software System Users: optimx for R. Journal of Statistical Software, 43(9), 1–14. URL http://www.jstatsoft.org/v43/i09/.
reshape2, Hadley Wickham (2007). Reshaping Data with the reshape Package. Journal of Statistical Software, 21(12), 1–20.
roxygen2, Hadley Wickham, Peter Danenberg and Manuel Eugster (2014). roxygen2: In-source Documentation for R. R package version 4.1.0. http://CRAN.R-project.org/package=roxygen2.
termstruc, Robert Ferstl, Josef Hayden (2010). Zero-Coupon Yield Curve Estimation with the Package termstrc. Journal of Statistical Software, 36(1), 1–34. URL http://www.jstatsoft.org/v36/i01/.
testthat, Hadley Wickham, A testing package specifically tailored for R that's fun, flexible, and easy to set up.
survival, Therneau T (2015). A Package for Survival Analysis in S, version 2.38, URL http://CRAN.R-project.org/package=survival.
Introduction
The inspiration for Bond Lab arose from the recommendation on the part of the Structured Finance Industry Group to provide mortgage and consumer asset-backed bond payment rules, commonly referred to as the waterfall, in an open source programming language. Although well intended, the recommendation suffered from the following problems:
First, the waterfall is but one of several structural objects that must come together within the program to define a structured security. Thus, it was rightly pointed out by several providers of commercially available software that a waterfall, in and of itself, is insufficient to analyze structured securities.
Second, the recommendation mentioned Python as an example of a human readable open source programming language. Although only an example, mentioning Python served to pivot the conversation from the viability of open source deal structures to that of a debate on the choice of programming language.
Bond Lab is an example of open source software designed for the analysis of fixed-income securities with an emphasis on structured securities. It defines the classes, superclasses, structural elements, and methods required to create a structured security before the investor can begin to perform cash flow, relative value, and risk analysis.
The examples used in this book assume securities whose factor or origination date occurred sometime during January 2013, a random choice on my part. Swap rate data, taken from the Federal Reserve's website, is available for the month. The examples are:
Bond ID
Bond Type
Structure
bondlab5
Bond
5-year semi-annual coupon
bondlab10
Bond
10-year semi-annual coupon
bondlabMBS4
Mortgage
30-year pass-through
bondlabMBS5
Mortgage
30-year pass-through
BondLabMBSIO
Mortgage
IO strip
BondLabMBSPO
Mortgage
PO strip
BondLabPAC1
PAC
REMIC tranche
BondLabCMP1
companion
REMIC tranche
BondLabSEQ1
sequential
REMIC tranche
BondLabSEQ2
sequential
REMIC tranche
BondLabSEQ3
sequential
REMIC tranche
BondLabSEQ4
sequentialIO
REMIC tranche
BondLabPAC2
PAC
REMIC tranche
BondLabFloater
floater
REMIC tranche
BondLabInverse
inverse
REMIC tranche
BondLabPACZ
PAC
REMIC tranche
BondLabCMP_Z
companion
REMIC tranche
BondLabZ
accrual bond
REMIC tranche
Finally, the Bond Lab structuring tool allows the reader to create any structure by defining the REMIC, its tranches, collateral group, and payment waterfall. Thus, the reader may extend her analysis and investigation in any direction she chooses. The Companion to Investing in MBS (companion2IMBS) provides a gentle introduction to BondLab, calling much of the functionality presented herein.