今週も特にありません

進捗どうですか?

CIRモデルの債券価格とイールド

Vasicekモデルの方はやったので、CIRモデルの債券価格とイールドについて

CIRモデルの債券価格もVasicekモデルの場合と同様にアフィン型となり、解析的に求めることができる

# zero coupon bond price and yield under Cox-Ingersoll-Ross model
# 
# Args:
#   kappa : speed of reversion
#   mu    : long term mean level
#   sigma : instaneous volatility
#   r0    : current short rate
#   t     : current time
#   T     : bond maturity
#
# Return:
#   data.frame of maturity, bond price and yield
#
CIRZCBond <- function(kappa, mu, sigma, r0, t, T) {
  tau <- T - t
  h <- sqrt(kappa^2 + 2 * sigma^2)
  B <- 2 * (exp(tau * h) - 1) / (2 * h + (kappa + h) * (exp(tau * h) - 1))
  A <- ((2 * h * exp((kappa + h) * tau / 2)) / (2 * h + (kappa + h) * 
       (exp(tau * h) - 1)))^(2 * kappa * mu / sigma^2)
  P <- A * exp(-B * r0)
  Y <- ifelse(tau != 0, -log(P) / tau, r0)
  data.frame(maturity = tau, price = P, yield = Y)
}

パラメータをセットする

kappa <- 0.2
mu <- 0.015
sigma <- 0.02
r0 <- 0.001
t <- 0
T <- c(1/12, 1/4, 1/2, 1:10, 15, 20, 30)

債券価格とイールドは次のようになる

> CIRZCBond(kappa, mu, sigma, r0, t, T)
      maturity     price       yield
1   0.08333333 0.9999070 0.001116021
2   0.25000000 0.9996640 0.001344234
3   0.50000000 0.9991617 0.001677218
4   1.00000000 0.9976916 0.002311055
5   2.00000000 0.9931024 0.003460729
6   3.00000000 0.9866763 0.004471087
7   4.00000000 0.9787842 0.005361026
8   5.00000000 0.9697338 0.006146732
9   6.00000000 0.9597787 0.006842082
10  7.00000000 0.9491268 0.007458982
11  8.00000000 0.9379476 0.008007653
12  9.00000000 0.9263789 0.008496884
13 10.00000000 0.9145324 0.008934236
14 15.00000000 0.8537373 0.010542117
15 20.00000000 0.7940308 0.011531650
16 30.00000000 0.6846598 0.012627772

初期金利の値を変えて、イールドカーブをプロットする

library(ggplot2)
library(ggthemes)

r0 <- c(0, 0.01, 0.015, 0.02, 0.03)
tl <- length(T)
irate <- c(rep(r0[1], tl), rep(r0[2], tl), rep(r0[3], tl), rep(r0[4], tl), rep(r0[5], tl))
y1 <- CIRZCBond(kappa, mu, sigma, r0[1], t, T)
y2 <- CIRZCBond(kappa, mu, sigma, r0[2], t, T)
y3 <- CIRZCBond(kappa, mu, sigma, r0[3], t, T)
y4 <- CIRZCBond(kappa, mu, sigma, r0[4], t, T)
y5 <- CIRZCBond(kappa, mu, sigma, r0[5], t, T)
df <- data.frame(irate = factor(irate), rbind(y1, y2, y3, y4, y5))
ggplot(data = df, aes(x = maturity, y = yield, colour = irate)) +
geom_line(size = 1.2) + theme_economist() + scale_colour_economist()

f:id:masaqol:20150321015315p:plain

VasicekモデルとCIRモデルの形を見ての通り、sigma CIR * sqrt(mu) = sigma Vasというようにすれば、ボラティリティの部分がある程度近似されるので、モデルの違いによる価格を比較する場合にはパラメータを調整してセットしてあげればよい

分布の違いによる影響はオプション価格の方が出やすいので、その比較を含めてCIRモデルの債券オプションは次の機会に