Overview of this book

Introduction to R for Quantitative Finance will show you how to solve real-world quantitative fi nance problems using the statistical computing language R. The book covers diverse topics ranging from time series analysis to fi nancial networks. Each chapter briefl y presents the theory behind specific concepts and deals with solving a diverse range of problems using R with the help of practical examples.This book will be your guide on how to use and master R in order to solve quantitative finance problems. This book covers the essentials of quantitative finance, taking you through a number of clear and practical examples in R that will not only help you to understand the theory, but how to effectively deal with your own real-life problems.Starting with time series analysis, you will also learn how to optimize portfolios and how asset pricing models work. The book then covers fixed income securities and derivatives such as credit risk management.
Introduction to R for Quantitative Finance
Credits
www.PacktPub.com
Preface
Free Chapter
Time Series Analysis
Portfolio Optimization
Asset Pricing Models
Fixed Income Securities
Estimating the Term Structure of Interest Rates
Derivatives Pricing
Credit Risk Management
Extreme Value Theory
References
Index

Migration matrices

Credit rating transition is the migration of a corporate or governmental bond from one rating to another. The well-known industrial application is the CreditMetrics approach. It provides a risk modeling tool for bond portfolios to estimate the Conditional Value-at-Risk (CVaR) and credit spreads of a portfolio due to downgrade and upgrading. In this section, we show how to calculate credit spreads from a transition matrix.

We have to define the loss given default (lgd), the ratings (in this example: `A`, `B`, and `D`) and the one year transition matrix to compute credit spreads:

```> library(CreditMetrics)
> lgd <- 0.5
> rc <- c( "A", "B", "D")
> M <- matrix(c(85, 13, 2, 5, 80, 15, 0, 0, 100 ) /100, 3, 3,
+          dimnames = list(rc, rc), byrow = TRUE)
```

The command `cm.cs` calculates the credit spreads from the migration matrix:

```> cm.cs(M, lgd)
A          B
0.01005034 0.07796154
```

According to this example, a debt instrument with the rating `"A"` has around...