Title

This is an R Markdown document. Markdown is a simple formatting syntax for authoring web pages (click the MD toolbar button for help on Markdown).

When you click the Knit HTML button a web page will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:


suppressMessages(require(ggplot2))

cds.value <- function(p.0, p.t, r, recovery = 0.5, T) {
    lambda <- p.t/recovery
    cds.value <- -(p.t - p.0) * ((1 - exp(-(r + lambda) * T))/(r + lambda))

    return(cds.value)
}

x <- seq(0/10000, 10000/10000, 25/10000)
y <- sapply(x, cds.value, p.0 = 100/10000, r = 25/10000, T = 5)
out.df <- data.frame(spread = x, cds.val = y)

p <- qplot(x * 10000, y * 100, data = out.df) + xlab("Spread (in BP)") + ylab("CDS % MtM")
p

plot of chunk cds