`cm.hist`

plots a histogram for the simulated profit / loss distribution.

1 2 3 |

`M` |
one year empirical migration matrix, where the last row gives the default class. |

`lgd` |
loss given default |

`ead` |
exposure at default |

`N` |
number of companies |

`n` |
number of simulated random numbers |

`r` |
riskless interest rate |

`rho` |
correlation matrix |

`rating` |
rating of companies |

`col` |
a colour to be used to fill the bars, the default is 'steelblue4'. |

`main` |
an overall title for the plot, the default is 'Profit / Loss Distribution'. |

`xlab` |
a title for the x axis, the default is 'profit / loss'. |

`ylab` |
a title for the y axis, the defualt is 'frequency'. |

This function gives a histogram of the simulated profits and losses. The 'breaks' of the histogram are obtained through the minimum and the maximum of the simulated values and the number of simulated random numbers. This is

*\mbox{breaks} = (\max (\mbox{SimGV}) - \min (\mbox{SimGV})) / 2n*

A histogram of the the simulated profit and loss distribution.

Andreas Wittmann andreas\_wittmann@gmx.de

Glasserman, Paul, Monte Carlo Methods in Financial Engineering, Springer 2004

`cm.matrix`

, `cm.gain`

, `hist`

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | ```
N <- 3
n <- 50000
r <- 0.03
ead <- c(4000000, 1000000, 10000000)
lgd <- 0.45
rating <- c("BBB", "AA", "B")
firmnames <- c("firm 1", "firm 2", "firm 3")
# correlation matrix
rho <- matrix(c( 1, 0.4, 0.6,
0.4, 1, 0.5,
0.6, 0.5, 1), 3, 3, dimnames = list(firmnames, firmnames),
byrow = TRUE)
# one year empirical migration matrix from standard&poors website
rc <- c("AAA", "AA", "A", "BBB", "BB", "B", "CCC", "D")
M <- matrix(c(90.81, 8.33, 0.68, 0.06, 0.08, 0.02, 0.01, 0.01,
0.70, 90.65, 7.79, 0.64, 0.06, 0.13, 0.02, 0.01,
0.09, 2.27, 91.05, 5.52, 0.74, 0.26, 0.01, 0.06,
0.02, 0.33, 5.95, 85.93, 5.30, 1.17, 1.12, 0.18,
0.03, 0.14, 0.67, 7.73, 80.53, 8.84, 1.00, 1.06,
0.01, 0.11, 0.24, 0.43, 6.48, 83.46, 4.07, 5.20,
0.21, 0, 0.22, 1.30, 2.38, 11.24, 64.86, 19.79,
0, 0, 0, 0, 0, 0, 0, 100
)/100, 8, 8, dimnames = list(rc, rc), byrow = TRUE)
cm.hist(M, lgd, ead, N, n, r, rho, rating,
col = "steelblue4", main = "Profit / Loss Distribution",
xlab = "profit / loss", ylab = "frequency")
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

All documentation is copyright its authors; we didn't write any of that.