Brownian {qrmtools} | R Documentation |
Simulate paths of dependent Brownian motions, geometric Brownian motions and Brownian bridges.
rBrownian(N, t, d = 1, U = matrix(runif(N * n * d), ncol = d), drift = rep(0, d), vola = rep(1, d), type = c("BM", "GBM", "BB"), init = rep(1, d))
N |
number N of paths to simulate (positive integer). |
t |
n-vector of the form
(t_1,...,t_n)
with 0 < t_1 < ... < t_n
containing the time points where to simulate the stochastic
process. Note that the return object of |
d |
dimension d of the stochastic process, so the number of components (positive integer). |
U |
(N*n, d)- |
drift |
d- |
vola |
d- |
type |
|
init |
initial values (typically stock prices at time 0)
for |
rBrownian()
returns an (N, n+1, d)-array containing
the N paths of the specified d-dimensional
stochastic process simulated at the n+1 time points
(0, t_1, ..., t_n).
Marius Hofert
## Setup d <- 3 # dimension (3 stock prices) library(copula) tcop <- tCopula(iTau(tCopula(), tau = 0.5), dim = d, df = 4) # t_4 copula vola <- seq(0.05, 0.20, length.out = d) # volatilities sigma r <- 0.01 # risk-free interest rate drift <- r - vola^2/2 # marginal drifts init <- seq(10, 100, length.out = d) # initial stock prices N <- 1000 # number of replications n <- 250 # number of time steps ## Simulate N paths of a cross-sectionally dependent d-dimensional ## geometric Brownian motion over n time steps set.seed(271) U <- rCopula(N * n, copula = tcop) res <- rBrownian(N, t = 1:n, d = d, U = U, drift = drift, vola = vola, type = "GBM", init = init) pairs(res[,2,], gap = 0, pch = ".") # plot after one time step ## Now based on quasi-random numbers library(qrng) set.seed(271) U. <- cCopula(to_array(sobol(N, d = d * n, randomize = "digital.shift"), f = n), copula = tcop, inverse = TRUE) res. <- rBrownian(N, t = 1:n, d = d, U = U., drift = drift, vola = vola, type = "GBM", init = init) pairs(res.[,2,], gap = 0, pch = ".") ## Brownian bridge N <- 8 t <- 1:100/100 B <- rBrownian(N, t = t, type = "BB") plot(NA, xlim = 0:1, ylim = range(B), xlab = "Time t", ylab = expression("Brownian bridge path"~(B[t]))) for(i in 1:N) lines(c(0,t), B[i,,], col = i)