mlmc.test: Multi-level Monte Carlo estimation test suite

View source: R/mlmc.test.R

mlmc.testR Documentation

Multi-level Monte Carlo estimation test suite

Description

Computes a suite of diagnostic values for an MLMC estimation problem.

Usage

mlmc.test(
  mlmc_l,
  N,
  L,
  N0,
  eps.v,
  Lmin,
  Lmax,
  parallel = NA,
  silent = FALSE,
  ...
)

Arguments

mlmc_l

a user supplied function which provides the estimate for level l. It must take at least two arguments, the first is the level number to be simulated and the second the number of paths. Additional arguments can be taken if desired: all additional ... arguments to this function are forwarded to the user defined mlmc_l function.

The user supplied function should return a named list containing one element named sums and second named cost, where:

sums

is a vector of length six \left(\sum Y_i, \sum Y_i^2, \sum Y_i^3, \sum Y_i^4, \sum X_i, \sum X_i^2\right) where Y_i are iid simulations with expectation E[P_0] when l=0 and expectation E[P_l-P_{l-1}] when l>0, and X_i are iid simulations with expectation E[P_l]. Note that this differs from the main mlmc() driver, which only requires the first two of these elements in order to calculate the estimate. The remaining elements are required by mlmc.test() since they are used for convergence tests, kurtosis, and telescoping sum checks.

cost

is a scalar with the total cost of the paths simulated. For example, in the financial options samplers included in this package, this is calculated as NM^l, where N is the number of paths requested in the call to the user function mlmc_l, M is the refinement cost factor (M=2 for mcqmc06_l() and M=4 for opre_l()), and l is the level being sampled.

See the function (and source code of) opre_l() and mcqmc06_l() in this package for an example of user supplied level samplers.

N

number of samples to use in the tests

L

number of levels to use in the tests

N0

initial number of samples which are used for the first 3 levels and for any subsequent levels which are automatically added. Must be > 0.

eps.v

a vector of one or more target accuracies for the tests. Must all be > 0.

Lmin

the minimum level of refinement. Must be \ge 2.

Lmax

the maximum level of refinement. Must be \ge Lmin.

parallel

if an integer is supplied, R will fork parallel parallel processes. This is done for the convergence tests section by splitting the N samples as evenly as possible across cores when sampling each level. This is also done for the MLMC complexity tests by passing the parallel argument on to the mlmc() driver when targeting each accuracy level in eps.

silent

set to TRUE to supress running output (identical output can still be printed by printing the return result)

...

additional arguments which are passed on when the user supplied mlmc_l function is called

Details

See one of the example level sampler functions (e.g. opre_l()) for example usage.

This function is based on GPL-2 'Matlab' code by Mike Giles.

Value

An mlmc.test object which contains all the computed diagnostic values. This object can be printed or plotted (see plot.mlmc.test).

Author(s)

Louis Aslett <louis.aslett@durham.ac.uk>

Mike Giles <Mike.Giles@maths.ox.ac.uk>

Tigran Nagapetyan <nagapetyan@stats.ox.ac.uk>

Examples


# Example calls with realistic arguments
# Financial options using an Euler-Maruyama discretisation
tst <- mlmc.test(opre_l, N = 2000000,
                 L = 5, N0 = 1000,
                 eps.v = c(0.005, 0.01, 0.02, 0.05, 0.1),
                 Lmin = 2, Lmax = 6,
                 option = 1)
tst
plot(tst)

# Financial options using a Milstein discretisation
tst <- mlmc.test(mcqmc06_l, N = 20000,
                 L = 8, N0 = 200,
                 eps.v = c(0.005, 0.01, 0.02, 0.05, 0.1),
                 Lmin = 2, Lmax = 10,
                 option = 1)
tst
plot(tst)


# Toy versions for CRAN tests
tst <- mlmc.test(opre_l, N = 10000,
                 L = 5, N0 = 1000,
                 eps.v = c(0.025, 0.1),
                 Lmin = 2, Lmax = 6,
                 option = 1)

tst <- mlmc.test(mcqmc06_l, N = 10000,
                 L = 8, N0 = 1000,
                 eps.v = c(0.025, 0.1),
                 Lmin = 2, Lmax = 10,
                 option = 1)


mlmc documentation built on Sept. 11, 2024, 5:27 p.m.

Related to mlmc.test in mlmc...