Description Usage Arguments Value Author(s) References See Also Examples
This function makes simulations of diffusion processes, that are building blocks for various risk factors' models.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
n |
number of independent observations. |
horizon |
horizon of projection. |
frequency |
either "annual", "semi-annual", "quarterly", "monthly", "weekly", or "daily" (1, 1/2, 1/4, 1/12, 1/52, 1/252). |
model |
either Geometric Brownian motion-like ( GBM-like (GBM, Merton, Kou, Heston, Bates) dX_t = θ_1(t) X_t dt + θ_2(t) X_t dW_t + X_t JdN_t CIR dX_t = (θ_1 - θ_2 X_t) dt + θ_3√(X_t) dW_t Ornstein-Uhlenbeck dX_t = (θ_1 - θ_2 X_t)dt + θ_3 dW_t Where (W_t)_t is a standard brownian motion : dW_t ~~ ε √(dt) and ε ~~ N(0, 1) The ε is a gaussian increment that
can be an output from For 'GBM-like', θ_1 and θ_2 can be held constant, and the jumps part JdN_t is optional. In case the jumps are used, they arise following a Poisson process (N_t), with intensities J drawn either from lognormal or asymmetric double-exponential distribution. |
x0 |
starting value of the process. |
theta1 |
a |
theta2 |
a |
theta3 |
a |
lambda |
intensity of the Poisson process counting the jumps. Optional. |
mu_z |
mean parameter for the lognormal jumps size. Optional. |
sigma_z |
standard deviation parameter for the lognormal jumps size. Optional. |
p |
probability of positive jumps. Must belong to ]0, 1[. Optional. |
eta_up |
mean of positive jumps in Kou's model. Must belong to ]0, 1[. Optional. |
eta_down |
mean of negative jumps. Must belong to ]0, 1[. Optional. |
eps |
gaussian shocks. If not provided, independent shocks are
generated internally by the function. Otherwise, for custom shocks,
must be an output from |
seed |
reproducibility seed |
a time series object.
Thierry Moudiki
Black, F., Scholes, M.S. (1973) The pricing of options and corporate liabilities, Journal of Political Economy, 81, 637-654.
Cox, J.C., Ingersoll, J.E., Ross, S.A. (1985) A theory of the term structure of interest rates, Econometrica, 53, 385-408.
Iacus, S. M. (2009). Simulation and inference for stochastic differential equations: with R examples (Vol. 1). Springer.
Glasserman, P. (2004). Monte Carlo methods in financial engineering (Vol. 53). Springer.
Kou S, (2002), A jump diffusion model for option pricing, Management Sci- ence Vol. 48, 1086-1101.
Merton, R. C. (1976). Option pricing when underlying stock returns are discontinuous. Journal of financial economics, 3(1), 125-144.
Uhlenbeck, G. E., Ornstein, L. S. (1930) On the theory of Brownian motion, Phys. Rev., 36, 823-841.
Vasicek, O. (1977) An Equilibrium Characterization of the Term Structure, Journal of Financial Economics, 5, 177-188.
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | kappa <- 1.5
V0 <- theta <- 0.04
sigma_v <- 0.2
theta1 <- kappa*theta
theta2 <- kappa
theta3 <- sigma_v
# OU
sim.OU <- simdiff(n = 10, horizon = 5,
frequency = "quart",
model = "OU",
x0 = V0, theta1 = theta1, theta2 = theta2, theta3 = theta3)
head(sim.OU)
par(mfrow=c(2,1))
esgplotbands(sim.OU, xlab = "time", ylab = "values", main = "with esgplotbands")
matplot(time(sim.OU), sim.OU, type = 'l', main = "with matplot")
# OU with simulated shocks (check the dimensions)
eps0 <- simshocks(n = 50, horizon = 5, frequency = "quart", method = "anti")
sim.OU <- simdiff(n = 50, horizon = 5, frequency = "quart",
model = "OU",
x0 = V0, theta1 = theta1, theta2 = theta2, theta3 = theta3,
eps = eps0)
par(mfrow=c(2,1))
esgplotbands(sim.OU, xlab = "time", ylab = "values", main = "with esgplotbands")
matplot(time(sim.OU), sim.OU, type = 'l', main = "with matplot")
# a different plot
esgplotts(sim.OU)
# CIR
sim.CIR <- simdiff(n = 50, horizon = 5,
frequency = "quart",
model = "CIR",
x0 = V0, theta1 = theta1, theta2 = theta2, theta3 = 0.05)
esgplotbands(sim.CIR, xlab = "time", ylab = "values", main = "with esgplotbands")
matplot(time(sim.CIR), sim.CIR, type = 'l', main = "with matplot")
# GBM
eps0 <- simshocks(n = 100, horizon = 5, frequency = "quart")
sim.GBM <- simdiff(n = 100, horizon = 5, frequency = "quart",
model = "GBM",
x0 = 100, theta1 = 0.03, theta2 = 0.1,
eps = eps0)
esgplotbands(sim.GBM, xlab = "time", ylab = "values", main = "with esgplotbands")
matplot(time(sim.GBM), sim.GBM, type = 'l', main = "with matplot")
eps0 <- simshocks(n = 100, horizon = 5, frequency = "quart")
sim.GBM <- simdiff(n = 100, horizon = 5, frequency = "quart",
model = "GBM",
x0 = 100, theta1 = 0.03, theta2 = 0.1,
eps = eps0)
esgplotbands(sim.GBM, xlab = "time", ylab = "values", main = "with esgplotbands")
matplot(time(sim.GBM), sim.GBM, type = 'l', main = "with matplot")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.