Using R in Academic Finance               Sanjiv R. Das     Professor, Santa Clara University         Department of Financ...
Outline •  High‐performance compuGng for Finance •  Modeling the opGmal modificaGon of home    loans using R •  IdenGfying ...
h?p://www.rinfinance.com/RinFinance2010/agenda/ h?p://cran.r‐project.org/web/views/Finance.html 
Calling C from R: An Example of Tax‐opGmized PorOolio Rebalancing 
Calling C from R: An Example of Tax‐opGmized PorOolio Rebalancing 
R CMD SHLIB tax.c 
Topic 1 MODIFYING HOME LOANS WITH R MODELS      THE PRINCIPAL PRINCIPLE: OpGmal ModificaGon of Distressed Home Loans      (...
Game theoreGc problem:   Lender determines the loan modificaGon that maximizes value of loan given that the borrower will a...
Model Home value    HJM CorrelaGon               h?p://algo.scu.edu/~sanjivdas/    14 
“Iso‐Service” Surface                           choose Loan balance = $300,000 Home value = $250,000  Remaining maturity =...
Some R 
Values of Iso‐Service Loans          h?p://algo.scu.edu/~sanjivdas/    17 
Default Put Exercise Region L=225,000 L=250,000              h?p://algo.scu.edu/~sanjivdas/    18 
Cure risk and Re‐default Risk The risk of unnecessary relief, i.e., the                     Providing fuGle relief, leadin...
h?p://algo.scu.edu/~sanjivdas/    20 
Logit: Explaining Re‐default h?p://algo.scu.edu/~sanjivdas/ 
Reduced‐Form Analysis of SAMs                                                        Home values       Normalize iniGal ho...
Default Barrier and Lender Share 23    h?p://algo.scu.edu/~sanjivdas/ 
Barrier Model IntuiGon                                                                    No default                      ...
A Barrier OpGon DecomposiGon        Non‐default         component        Default component        Shared AppreciaGon      ...
The Closed‐Form SoluGon 26               h?p://algo.scu.edu/~sanjivdas/ 
SAM or not?                                   27 h?p://algo.scu.edu/~sanjivdas/ 
Topic 2 MANAGING SYSTEMIC RISK BY ANALYZING NETWORKS USING R   THE MIDAS PROJECT @IBM     Paper: “Unleashing the Power of ...
Midas Financial Insights                                   Proxy Statement                                              In...
Systemic Analysis Systemic Analysis  •  DefiniGon: the measurement and analysis of relaGonships across enGGes    with a vie...
Co‐lending Network •  DefiniGon: a network based on links between banks that lend    together.  •  Loans used are not overn...
Centrality •  Influence relaGons are circular: •  Pre‐mulGply by scalar to get an eigensystem: •  Principal eigenvector of ...
Data •  Five years: 2005—2009. •  Loans between FIs only.  •  Filings made with the SEC. •  No overnight loans. •  Example...
2005  CiGgroup Inc.                    J.P. Morgan Chase                   Bank of America Corp. 
2006      2007 2008      2009         37 
Network Fragility •  DefiniGon: how quickly will the failure of any one bank    trigger failures across the network? •  Met...
Top 25 banks by systemic risk                                  39 
Topic 3 PORTFOLIO OPTIMIZATION USING R    The research papers for this work are on my web page – just google it. h?p://alg...
Standard OpGmizaGon Problem                                   Risk aversion                      Mean                     ...
SoluGon Math      Sanjiv Das    42
Final soluGon      Sanjiv Das    43
Example: ConstrucGon of PorOolios: Available securiGes                      Expected returns        Standard              ...
Investor goals (sub‐porOolios)                   45
Sub‐porOolios and overall porOolio  The expected return of the overall porOolio is the weighted      average of the expect...
Mean‐variance efficient fronGer             Sanjiv Das           47
Real porOolios versus virtual porOolios                 Sanjiv Das                 48
An alternate problem                      For normal returns                       Solve for γ        Sanjiv Das          ...
Risk as probability of losses     Mean-variance problem: Minimize Risk    (variance) subject to minimum level of    Expect...
Efficient FronGers in the BPT   (Mental Account) World            Sanjiv Das           53
Short‐Selling Constraints Linear program with non‐linear constraints. This is not a standard quadraGc programming problem ...
Modified Problem            Standard QP      Standard QP problem     with linear constraintsAmenable to industrial opGmizer...
MV FronGer with Short‐selling              Sanjiv Das          56
DeviaGng from Normality with Copulas                 Sanjiv Das              57
Gaussian Copula       Sanjiv Das   58
Extended OpGmizaGon Problem             Sanjiv Das         59
SoluGon   Sanjiv Das   61
Non‐Linear Products U is a set of states over          r(u) is a n-vector of random returnsn assets                       ...
Restatement of the problem This is a quadratic optimization with linear constraints.Not a quadratic optimization with non-...
Introducing Structured Products     Can we improve the risk-adjusted returns in a    portfolio by using puts and calls?   ...
Are puts opGmal? No, they add very little value to the portfolio.             But …                     Sanjiv Das        ...
Puts are needed when the threshold return is high For high thresholds the investor cannot get an acceptable portfolio with...
Should investors use calls?                Calls are risky too.But have attractive and high mean returns!                 ...
Calls give be?er porOolios      Improvement is greater     than 60 bps !             Sanjiv Das       68
Structured Product:  The Barrier‐M‐note        Sanjiv Das       69
Barrier‐M Note      Sanjiv Das   70
Truncated Straddle              Barrier-M-noteReturn pick-up greater than 250 bps!                Sanjiv Das             71
Equity‐Indexed Product          Sanjiv Das       72
Conclusion •  Investors find it easier to think in terms of mental accounts or sub‐porOolios    when trying to reach their ...
Topic 4 PEDAGOGICAL USES FOR R USING THE WEB               h?p://sanjivdas.wordpress.com/ 
Use the Rcgi package from David Firth: h?p://www.omegahat.org/CGIwithR/  You need two program files to get everything worki...
R Code called from CGI 
h?p://algo.scu.edu/~sanjivdas/Rcgi/mortgage_calc.html 
High-performance   computing (parallelR)                           Network modeling                                Q?     ...
Using R for Analyzing Loans, Portfolios and Risk:  From Academic Theory to Financial Practice
Using R for Analyzing Loans, Portfolios and Risk:  From Academic Theory to Financial Practice
Using R for Analyzing Loans, Portfolios and Risk:  From Academic Theory to Financial Practice
Using R for Analyzing Loans, Portfolios and Risk:  From Academic Theory to Financial Practice
Using R for Analyzing Loans, Portfolios and Risk:  From Academic Theory to Financial Practice
Using R for Analyzing Loans, Portfolios and Risk:  From Academic Theory to Financial Practice
Using R for Analyzing Loans, Portfolios and Risk:  From Academic Theory to Financial Practice
Using R for Analyzing Loans, Portfolios and Risk:  From Academic Theory to Financial Practice
Using R for Analyzing Loans, Portfolios and Risk:  From Academic Theory to Financial Practice
Using R for Analyzing Loans, Portfolios and Risk:  From Academic Theory to Financial Practice
Upcoming SlideShare
Loading in...5
×

Using R for Analyzing Loans, Portfolios and Risk: From Academic Theory to Financial Practice

14,336

Published on

Dr. Sanjiv Das has held positions as at Citibank, Harvard University Professor and Program Director at the FDIC’s Center for Financial Research. His research relies heavily on R for analysis and decision-making. In this webinar, Dr. Das will present a mix of some of his more current and topical research that uses R-based models, and some pedagogical applications of R. He will present:

* An R-based model for optimizing loan modifications on distressed home loans, and the economics of these modifications.

* A goal-based portfolio optimization model for investors who use derivatives.

*Using network modeling tools in R to detect systemically risky financial institutions.

*Using R for web delivery of financial models and random generation of pedagogical problems.

Promising to be entertaining and enlightening, this webinar will emphasize the interplay of mathematical models, economic problems, and R.

0 Comments
6 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
14,336
On Slideshare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
158
Comments
0
Likes
6
Embeds 0
No embeds

No notes for slide

Using R for Analyzing Loans, Portfolios and Risk: From Academic Theory to Financial Practice

  1. 1. Using R in Academic Finance  Sanjiv R. Das  Professor, Santa Clara University  Department of Finance  h?p://algo.scu.edu/~sanjivdas/ 
  2. 2. Outline •  High‐performance compuGng for Finance •  Modeling the opGmal modificaGon of home  loans using R •  IdenGfying systemically risky financial  insGtuGons using R network models. •  Goal‐based porOolio opGmizaGon with R •  Using R to deliver funcGons/models on the  web, and for pedagogical purposes.  R works well with Python and C. 
  3. 3. h?p://www.rinfinance.com/RinFinance2010/agenda/ h?p://cran.r‐project.org/web/views/Finance.html 
  4. 4. Calling C from R: An Example of Tax‐opGmized PorOolio Rebalancing 
  5. 5. Calling C from R: An Example of Tax‐opGmized PorOolio Rebalancing 
  6. 6. R CMD SHLIB tax.c 
  7. 7. Topic 1 MODIFYING HOME LOANS WITH R MODELS  THE PRINCIPAL PRINCIPLE: OpGmal ModificaGon of Distressed Home Loans  (Why Lenders should Forgive, not Foresake Mortgages)    STRATEGIC LOAN MODIFICATION: An OpGons based response to strategic  default  (joint work with Ray Meadows)   
  8. 8. Game theoreGc problem:   Lender determines the loan modificaGon that maximizes value of loan given that the borrower will act strategically in his best interest.  
  9. 9. Model Home value  HJM CorrelaGon  h?p://algo.scu.edu/~sanjivdas/  14 
  10. 10. “Iso‐Service” Surface  choose Loan balance = $300,000 Home value = $250,000  Remaining maturity = 25 years A = $1,933 per month   Amax = $20,000 per year   ($1,667 per month)  2/27/12  h?p://algo.scu.edu/~sanjivdas/  15 
  11. 11. Some R 
  12. 12. Values of Iso‐Service Loans  h?p://algo.scu.edu/~sanjivdas/  17 
  13. 13. Default Put Exercise Region L=225,000 L=250,000  h?p://algo.scu.edu/~sanjivdas/  18 
  14. 14. Cure risk and Re‐default Risk The risk of unnecessary relief, i.e., the  Providing fuGle relief, leading to borrower would not have ulGmately  ulGmate default anyway.  defaulted.  Value of loan accounGng  A: borrower income available for housing  for willingness to pay  service, with mean μ and std. dev σ.   h?p://algo.scu.edu/~sanjivdas/  19 
  15. 15. h?p://algo.scu.edu/~sanjivdas/  20 
  16. 16. Logit: Explaining Re‐default h?p://algo.scu.edu/~sanjivdas/ 
  17. 17. Reduced‐Form Analysis of SAMs  Home values  Normalize iniGal home value to 1. The opGon to default is ITM when (H > L).     There is a home value D at which the borrower will default. D is a “default level”  or default exercise barrier.     D is a funcGon of the lender share θ, we write it as D(L, θ).    D increases in L and in θ.    Foreclosure recovery as a fracGon of H is ϕ. 22  h?p://algo.scu.edu/~sanjivdas/ 
  18. 18. Default Barrier and Lender Share 23  h?p://algo.scu.edu/~sanjivdas/ 
  19. 19. Barrier Model IntuiGon  No default  Payoff=L  Region of  no default  H0 = 1  and gains  to SAM  Default Payoff=фD D=L exp[‐γ(1‐θ)]  Region of default  24  h?p://algo.scu.edu/~sanjivdas/ 
  20. 20. A Barrier OpGon DecomposiGon  Non‐default   component  Default component  Shared AppreciaGon  component 25  PDE  h?p://algo.scu.edu/~sanjivdas/ 
  21. 21. The Closed‐Form SoluGon 26  h?p://algo.scu.edu/~sanjivdas/ 
  22. 22. SAM or not?  27 h?p://algo.scu.edu/~sanjivdas/ 
  23. 23. Topic 2 MANAGING SYSTEMIC RISK BY ANALYZING NETWORKS USING R   THE MIDAS PROJECT @IBM     Paper: “Unleashing the Power of Public Data for Financial Risk Measurement, RegulaGon, and Governance” (with Mauricio A. Hernandez, Howard Ho, Georgia Koutrika, Rajasekar Krishnamurthy, Lucian Popa, Ioana R. Stanoi, Shivakumar Vaithyanathan) IBM Almaden) 
  24. 24. Midas Financial Insights  Proxy Statement Insider TransactionAnnual Report Loan Agreement Raw Unstructured Data  Raw Unstructured Data  Extract IntegrateRelated Companies Data for Analysis  Exposure by subsidiary Loan Exposure …  …  29 
  25. 25. Systemic Analysis Systemic Analysis  •  DefiniGon: the measurement and analysis of relaGonships across enGGes  with a view to understanding the impact of these relaGonships on the  system as a whole.  •  Challenge: requires most or all of the data in the system; therefore, high‐ quality informaGon extracGon and integraGon is criGcal.  Systemic Risk  •  Current approaches: use stock return correlaGons (indirect). [Acharya, et  al 2010; Adrian and Brunnermeier 2009; Billio, Getmansky, Lo 2010;  Kritzman, Li, Page, Rigobon 2010] •  Midas: uses semi‐structured archival data from SEC and FDIC to construct  a co‐lending network; network analysis is then used to determine which  banks pose the greatest risk to the system.    30 
  26. 26. Co‐lending Network •  DefiniGon: a network based on links between banks that lend  together.  •  Loans used are not overnight loans. We look at longer‐term  lending relaGonships.  •  Lending adjacency matrix:  •  Undirected graph, i.e., symmetric   •  Total lending impact for each bank:    31 
  27. 27. Centrality •  Influence relaGons are circular: •  Pre‐mulGply by scalar to get an eigensystem: •  Principal eigenvector of this system gives the  centrality  score for a  bank. •  This score is a measure of the systemic risk of a bank.   32 
  28. 28. Data •  Five years: 2005—2009. •  Loans between FIs only.  •  Filings made with the SEC. •  No overnight loans. •  Example: 364‐day bridge loans, longer‐term credit arrangement,  Libor notes, etc.  •  Remove all edge weights < 2 to remove banks that are minimally  acGve. Remove all nodes with no edges. (This is a choice for the  regulator.)  33 
  29. 29. 2005  CiGgroup Inc.  J.P. Morgan Chase  Bank of America Corp. 
  30. 30. 2006  2007 2008  2009  37 
  31. 31. Network Fragility •  DefiniGon: how quickly will the failure of any one bank  trigger failures across the network? •  Metric: expected degree of neighboring nodes  R!2 averaged across all nodes.  •  Neighborhoods are expected to  expand  when  •  Metric: diameter of the network.  38 
  32. 32. Top 25 banks by systemic risk  39 
  33. 33. Topic 3 PORTFOLIO OPTIMIZATION USING R    The research papers for this work are on my web page – just google it. h?p://algo.scu.edu/~sanjivdas/research.htm/  1.  Das, Markowitz, Scheid, and Statman (JFQA 2010), “PorOolio OpGmizaGon with   Mental Accounts” 2.  Das & Statman (2008), “Beyond Mean‐Variance: PorOolio with    Structured Products and non‐Gaussian returns.”    
  34. 34. Standard OpGmizaGon Problem  Risk aversion Mean Covariance matrix Portfolio weightsSOLUTION: See D, Markowitz, Scheid, Statman (JFQA 2010) Sanjiv Das 41
  35. 35. SoluGon Math  Sanjiv Das  42
  36. 36. Final soluGon  Sanjiv Das  43
  37. 37. Example: ConstrucGon of PorOolios: Available securiGes  Expected returns Standard deviationsBond 5% 5%Low-risk stock 10% 20%High-risk stock 25% 50% The correlation between the two stocks is 0.2. Other correlations are zero. Sanjiv Das 44
  38. 38. Investor goals (sub‐porOolios)  45
  39. 39. Sub‐porOolios and overall porOolio  The expected return of the overall porOolio is the weighted  average of the expected returns of the sub‐porOolios. The risk of the overall porOolio is not the weighted average of  the risk of the sub‐porOolios.  Sanjiv Das 46
  40. 40. Mean‐variance efficient fronGer  Sanjiv Das 47
  41. 41. Real porOolios versus virtual porOolios  Sanjiv Das 48
  42. 42. An alternate problem  For normal returns Solve for γ Sanjiv Das 49
  43. 43. Risk as probability of losses  Mean-variance problem: Minimize Risk (variance) subject to minimum level of Expected Return. Behavioral portfolio theory: Maximize Return subject to a maximum probability of falling below a threshold. Sanjiv Das 52
  44. 44. Efficient FronGers in the BPT   (Mental Account) World  Sanjiv Das 53
  45. 45. Short‐Selling Constraints Linear program with non‐linear constraints. This is not a standard quadraGc programming problem (QP) like the Markowitz model.  MVT uses a standard QP: quadra6c objecGve funcGon with linear constraints.   54
  46. 46. Modified Problem  Standard QP  Standard QP problem with linear constraintsAmenable to industrial opGmizers; we use the R system with the quadprog package and minpack.lm library.  San Diego, 12‐Nov‐2007  55
  47. 47. MV FronGer with Short‐selling  Sanjiv Das 56
  48. 48. DeviaGng from Normality with Copulas  Sanjiv Das 57
  49. 49. Gaussian Copula  Sanjiv Das 58
  50. 50. Extended OpGmizaGon Problem  Sanjiv Das 59
  51. 51. SoluGon  Sanjiv Das 61
  52. 52. Non‐Linear Products U is a set of states over r(u) is a n-vector of random returnsn assets Sanjiv Das 62 Compute p[r(u)]
  53. 53. Restatement of the problem This is a quadratic optimization with linear constraints.Not a quadratic optimization with non-linear constraints. Sanjiv Das 63
  54. 54. Introducing Structured Products  Can we improve the risk-adjusted returns in a portfolio by using puts and calls? Derivatives are very risky. Sanjiv Das And so …. 64
  55. 55. Are puts opGmal? No, they add very little value to the portfolio. But … Sanjiv Das 65
  56. 56. Puts are needed when the threshold return is high For high thresholds the investor cannot get an acceptable portfolio without puts. Sanjiv Das 66
  57. 57. Should investors use calls?  Calls are risky too.But have attractive and high mean returns! Sanjiv Das 67
  58. 58. Calls give be?er porOolios  Improvement is greater than 60 bps ! Sanjiv Das 68
  59. 59. Structured Product:  The Barrier‐M‐note  Sanjiv Das 69
  60. 60. Barrier‐M Note  Sanjiv Das 70
  61. 61. Truncated Straddle   Barrier-M-noteReturn pick-up greater than 250 bps! Sanjiv Das 71
  62. 62. Equity‐Indexed Product  Sanjiv Das 72
  63. 63. Conclusion •  Investors find it easier to think in terms of mental accounts or sub‐porOolios  when trying to reach their separate financial goals.  •  Behavioral porOolio theory deals with maximizing return subject to managing  the risk of loss. This problem has a mathemaGcal mapping into mean‐variance  opGmizaGon, yet is much more general.  •  Even with short‐selling prohibited, the loss from sub‐porOolio opGmizaGon is  smaller than the loss from misesGmaGng investor preferences.  •  ReporGng performance by sub‐porOolio enables investors to track their goals  be?er.  •  Goal‐based opGmizaGon enables choosing porOolios even when normality is  not assumed.  •  Goal‐based opGmizaGon provides a framework for including structured  products in investor porOolios.  The research papers for this work are on my web page – just google it.  h?p://algo.scu.edu/~sanjivdas/research.htm/    1.  Das, Markowitz, Scheid, and Statman (JFQA 2010), “PorOolio OpGmizaGon with   Mental Accounts”  2.  Das & Statman (2008), “Beyond Mean‐Variance: PorOolio with   Sanjiv Das 73  Structured Products and non‐Gaussian returns.”    
  64. 64. Topic 4 PEDAGOGICAL USES FOR R USING THE WEB     h?p://sanjivdas.wordpress.com/ 
  65. 65. Use the Rcgi package from David Firth: h?p://www.omegahat.org/CGIwithR/  You need two program files to get everything working. (a)  The html file that is the web form for input data. (b)  The R file, with special tags for use with the CGIwithR package. 
  66. 66. R Code called from CGI 
  67. 67. h?p://algo.scu.edu/~sanjivdas/Rcgi/mortgage_calc.html 
  68. 68. High-performance computing (parallelR) Network modeling Q?  OptimizationWeb functions Calling C from R Lattice dynamic optimization High-dimensional distributions with copulas
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×