Brownian {qrmtools}R Documentation

Brownian and Related Motions

Description

Simulate paths of dependent Brownian motions, geometric Brownian motions and Brownian bridges.

Usage

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))

Arguments

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 rBrownian() contains the values at the time points 0, t_1, ..., t_n then.

d

dimension d of the stochastic process, so the number of components (positive integer).

U

(N*n, d)-matrix of copula realizations to be converted to the joint increments of the stochastic process.

drift

d-vector of drifts (typically denoted by mu). Note that risk-neutral drifts are r - sigma^2/2, where r is the risk-free interest rate and sigma the volatility.

vola

d-vector of volatilities (typically denoted by sigma).

type

character string indicating whether a Brownian motion ("BM"), geometric Brownian motion ("GBM") or Brownian bridge ("BB") is to be simulated.

init

initial values (typically stock prices at time 0) for type = "GBM".

Value

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).

Author(s)

Marius Hofert

Examples

## 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)

[Package qrmtools version 0.0-14 Index]