This is a function to simulate a Cox-Ingersoll-Ross process given via the SDE
dXt=(α−βXt)dt+γXtdWt
with a Brownian motion (Wt)t≥0 and parameters α,β,γ>0. We use an exact CIR simulator for (Xtj)j=1,…,n through the non-central chi-squares distribution.
simCIR(time.points, n, h, alpha, beta, gamma, equi.dist=FALSE)
Arguments
alpha, beta, gamma: numbers given as in the SDE above.
equi.dist: a logical value indicating whether the sampling points are equidistant (default equi.dist=FALSE).
n: a number indicating the quantity of sampling points in the case equi.dist=TRUE.
h: a number indicating the step size in the case equi.dist=TRUE.
time.points: a numeric vector of sampling times (necessary if equi.dist=FALSE).
Returns
A numeric matrix containing the realization of (t0,Xt0),…,(tn,Xtn) with tj denoting the j-th sampling times.
References
S. J. A. Malham and A. Wiese. Chi-square simulation of the CIR process and the Heston model. Int. J. Theor. Appl. Finance, 16(3):1350014, 38, 2013.
## You always need the parameters alpha, beta and gamma## Additionally e.g. time.pointsdata <- simCIR(alpha=3,beta=1,gamma=1, time.points = c(0,0.1,0.2,0.25,0.3))## or n, number of observations, h, distance between observations,## and equi.dist=TRUEdata <- simCIR(alpha=3,beta=1,gamma=1,n=1000,h=0.1,equi.dist=TRUE)plot(data[1,],data[2,], type="l",col=4)## If you input every value and equi.dist=TRUE, time.points are not## used for the simulations.data <- simCIR(alpha=3,beta=1,gamma=1,n=1000,h=0.1, time.points = c(0,0.1,0.2,0.25,0.3), equi.dist=TRUE)## If you leave equi.dist=FALSE, the parameters n and h are not## used for the simulation.data <- simCIR(alpha=3,beta=1,gamma=1,n=1000,h=0.1, time.points = c(0,0.1,0.2,0.25,0.3))