簡體   English   中英

通過MLE估計CIR模型

[英]CIR model estimation through MLE

我想通過R中的ML來估計CIR模型參數。它看起來如下:

dr =(theta1-theta2 * r)+ theta3 * sqrt(r)* dW。

這種方法在Iacus的著作“帶有R的期權定價和金融模型的估計”的書中補充了。

在那里,在示例(第5章)中,執行速率估算並計算系數theta1-3。 現在,我想對數據集(X2)進行同樣的操作。

library(quantmod)

library(sde)
library(Ecdat)
data(Irates)
X1=Irates[,"r1"]
getSymbols(Symbols="DTB4WK",src="FRED")
X2=interpNA(coredata(DTB4WK))
X2[X2<0]=0

X=X2
CIR.logistic = function(theta1, theta2,theta3) {
  n=length(X)
  dt=deltat(X)
  cat(theta1,"  ",theta2, "  ",theta3,"  \n")
  return(-sum(dcCIR(x=X[2:n],Dt=dt,x0=X[1:(n-1)], theta=c(theta1,theta2,theta3),log=TRUE)))
}
mle(CIR.logistic,start=list(theta1=0.1, theta2=0.1,theta3=0.1),method='L-BFGS-B',
    lower=c(0.01,0.01,0.01),upper=c(1,1,1))

我將不勝感激!

在CIR模型中,速率幾乎肯定是非零的:僅除去負值是不夠的。

# Also remove zeroes (if there are many of them, it is probably not a good idea)
X[ X <= 0 ] <- .1

# Then, you code works
mle( CIR.logistic,
     start = list(theta1=0.1, theta2=0.1, theta3=0.1),
     method = 'L-BFGS-B',
     lower = c(0.01,0.01,0.01),
     upper = c(1,1,1) )

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM