simByEuler

Simulate Bates sample paths by Euler approximation

Syntax

``[Paths,Times,Z,N] = simByEuler(MDL,NPeriods)``
``[Paths,Times,Z,N] = simByEuler(___,Name,Value)``

Description

example

````[Paths,Times,Z,N] = simByEuler(MDL,NPeriods)` simulates `NTrials` sample paths of Bates bivariate models driven by `NBrowns` Brownian motion sources of risk and `NJumps` compound Poisson processes representing the arrivals of important events over `NPeriods` consecutive observation periods. The simulation approximates continuous-time stochastic processes by the Euler approach.```

example

````[Paths,Times,Z,N] = simByEuler(___,Name,Value)` specifies options using one or more name-value pair arguments in addition to the input arguments in the previous syntax.```

Examples

collapse all

Create a `bates` object.

```AssetPrice = 80; Return = 0.03; JumpMean = 0.02; JumpVol = 0.08; JumpFreq = 0.1; V0 = 0.04; Level = 0.05; Speed = 1.0; Volatility = 0.2; Rho = -0.7; StartState = [AssetPrice;V0]; Correlation = [1 Rho;Rho 1]; batesObj = bates(Return, Speed, Level, Volatility,... JumpFreq, JumpMean, JumpVol,'startstate',StartState,... 'correlation',Correlation)```
```batesObj = Class BATES: Bates Bivariate Stochastic Volatility -------------------------------------------------- Dimensions: State = 2, Brownian = 2 -------------------------------------------------- StartTime: 0 StartState: 2x1 double array Correlation: 2x2 double array Drift: drift rate function F(t,X(t)) Diffusion: diffusion rate function G(t,X(t)) Simulation: simulation method/function simByEuler Return: 0.03 Speed: 1 Level: 0.05 Volatility: 0.2 JumpFreq: 0.1 JumpMean: 0.02 JumpVol: 0.08 ```

Use `simByEuler` to simulate `NTrials` sample paths of this Bates bivariate model driven by `NBrowns` Brownian motion sources of risk and `NJumps` compound Poisson processes representing the arrivals of important events over `NPeriods` consecutive observation periods. This function approximates continuous-time stochastic processes by the Euler approach.

```NPeriods = 2; [Paths,Times,Z,N] = simByEuler(batesObj,NPeriods)```
```Paths = 3×2 80.0000 0.0400 90.8427 0.0873 32.7458 0.1798 ```
```Times = 3×1 0 1 2 ```
```Z = 2×2 0.5377 0.9333 -2.2588 2.1969 ```
```N = 2×1 0 0 ```

The output `Paths` is `3` `x` `2` dimension. Row number `3` is from `NPeriods` `+` `1`. The first row is defined by the `bates` name-value pair argument `StartState`. The remaining rows are simulated data. `Paths` always has two columns because the Bates model is a bivariate model. In this case, the first column is the simulated asset price and the second column is the simulated volatilities.

Input Arguments

collapse all

Stochastic differential equation model, specified as a `bates` object. You can create a `bates` object using `bates`.

Data Types: `object`

Number of simulation periods, specified as a positive scalar integer. The value of `NPeriods` determines the number of rows of the simulated output series.

Data Types: `double`

Name-Value Arguments

Specify optional comma-separated pairs of `Name,Value` arguments. `Name` is the argument name and `Value` is the corresponding value. `Name` must appear inside quotes. You can specify several name and value pair arguments in any order as `Name1,Value1,...,NameN,ValueN`.

Example: ```[Paths,Times,Z,N] = simByEuler(bates,NPeriods,'DeltaTimes',dt)```

Simulated trials (sample paths) of `NPeriods` observations each, specified as the comma-separated pair consisting of `'NTrials'` and a positive scalar integer.

Data Types: `double`

Positive time increments between observations, specified as the comma-separated pair consisting of `'DeltaTimes'` and a scalar or an `NPeriods`-by-`1` column vector.

`DeltaTimes` represents the familiar dt found in stochastic differential equations, and determines the times at which the simulated paths of the output state variables are reported.

Data Types: `double`

Number of intermediate time steps within each time increment dt (specified as `DeltaTimes`), specified as the comma-separated pair consisting of `'NSteps'` and a positive scalar integer.

The `simByEuler` function partitions each time increment dt into `NSteps` subintervals of length dt/`NSteps`, and refines the simulation by evaluating the simulated state vector at `NSteps − 1` intermediate points. Although `simByEuler` does not report the output state vector at these intermediate points, the refinement improves accuracy by allowing the simulation to more closely approximate the underlying continuous-time process.

Data Types: `double`

Flag to use antithetic sampling to generate the Gaussian random variates that drive the Brownian motion vector (Wiener processes), specified as the comma-separated pair consisting of `'Antithetic'` and a scalar numeric or logical `1` (`true`) or `0` (`false`).

When you specify `true`, `simByEuler` performs sampling such that all primary and antithetic paths are simulated and stored in successive matching pairs:

• Odd trials `(1,3,5,...)` correspond to the primary Gaussian paths.

• Even trials `(2,4,6,...)` are the matching antithetic paths of each pair derived by negating the Gaussian draws of the corresponding primary (odd) trial.

Note

If you specify an input noise process (see `Z`), `simByEuler` ignores the value of `Antithetic`.

Data Types: `logical`

Direct specification of the dependent random noise process for generating the Brownian motion vector (Wiener process) that drives the simulation, specified as the comma-separated pair consisting of `'Z'` and a function or as an ```(NPeriods ⨉ NSteps)```-by-`NBrowns`-by-`NTrials` three-dimensional array of dependent random variates.

Note

If you specify `Z` as a function, it must return an `NBrowns`-by-`1` column vector, and you must call it with two inputs:

• A real-valued scalar observation time t

• An `NVars`-by-`1` state vector Xt

Data Types: `double` | `function`

Dependent random counting process for generating the number of jumps, specified as the comma-separated pair consisting of `'N'` and a function or an (`NPeriods``NSteps`) -by-`NJumps`-by-`NTrials` three-dimensional array of dependent random variates.

Note

If you specify a function, `N` must return an `NJumps`-by-`1` column vector, and you must call it with two inputs: a real-valued scalar observation time t followed by an `NVars`-by-`1` state vector Xt.

Data Types: `double` | `function`

Flag that indicates how the output array `Paths` is stored and returned, specified as the comma-separated pair consisting of `'StorePaths'` and a scalar numeric or logical `1` (`true`) or `0` (`false`).

If `StorePaths` is `true` (the default value) or is unspecified, `simByEuler` returns `Paths` as a three-dimensional time-series array.

If `StorePaths` is `false` (logical `0`), `simByEuler` returns `Paths` as an empty matrix.

Data Types: `logical`

Sequence of end-of-period processes or state vector adjustments, specified as the comma-separated pair consisting of `'Processes'` and a function or cell array of functions of the form

`${X}_{t}=P\left(t,{X}_{t}\right)$`

The `simByEuler` function runs processing functions at each interpolation time. The functions must accept the current interpolation time t, and the current state vector Xt and return a state vector that can be an adjustment to the input state.

If you specify more than one processing function, `simByEuler` invokes the functions in the order in which they appear in the cell array. You can use this argument to specify boundary conditions, prevent negative prices, accumulate statistics, plot graphs, and more.

The end-of-period `Processes` argument allows you to terminate a given trial early. At the end of each time step, `simByEuler` tests the state vector Xt for an all-`NaN` condition. Thus, to signal an early termination of a given trial, all elements of the state vector Xt must be `NaN`. This test enables you to define a `Processes` function to signal early termination of a trial, and offers significant performance benefits in some situations (for example, pricing down-and-out barrier options).

Data Types: `cell` | `function`

Output Arguments

collapse all

Simulated paths of correlated state variables, returned as a ```(NPeriods + 1)```-by-`NVars`-by-`NTrials` three-dimensional time series array.

For a given trial, each row of `Paths` is the transpose of the state vector Xt at time t. When `StorePaths` is set to `false`, `simByEuler` returns `Paths` as an empty matrix.

Observation times associated with the simulated paths, returned as an `(NPeriods + 1)`-by-`1` column vector. Each element of `Times` is associated with the corresponding row of `Paths`.

Dependent random variates for generating the Brownian motion vector (Wiener processes) that drive the simulation, returned as an ```(NPeriods ⨉ NSteps)```-by-`NBrowns`-by-`NTrials` three-dimensional time-series array.

Dependent random variates used to generate the jump counting process vector, returned as an ```(NPeriods ⨉ NSteps)```-by-`NJumps`-by-`NTrials` three-dimensional time series array.

collapse all

Antithetic Sampling

Simulation methods allow you to specify a popular variance reduction technique called antithetic sampling.

This technique attempts to replace one sequence of random observations with another that has the same expected value but a smaller variance. In a typical Monte Carlo simulation, each sample path is independent and represents an independent trial. However, antithetic sampling generates sample paths in pairs. The first path of the pair is referred to as the primary path, and the second as the antithetic path. Any given pair is independent other pairs, but the two paths within each pair are highly correlated. Antithetic sampling literature often recommends averaging the discounted payoffs of each pair, effectively halving the number of Monte Carlo trials.

This technique attempts to reduce variance by inducing negative dependence between paired input samples, ideally resulting in negative dependence between paired output samples. The greater the extent of negative dependence, the more effective antithetic sampling is.

Algorithms

Bates models are bivariate composite models. Each Bates model consists of two coupled univariate models.

• One model is a geometric Brownian motion (`gbm`) model with a stochastic volatility function and jumps.

`$d{X}_{1t}=B\left(t\right){X}_{1t}dt+\sqrt{{X}_{2t}}{X}_{1t}d{W}_{1t}+Y\left(t\right){X}_{1t}d{N}_{t}$`

This model usually corresponds to a price process whose volatility (variance rate) is governed by the second univariate model.

• The other model is a Cox-Ingersoll-Ross (`cir`) square root diffusion model.

`$d{X}_{2t}=S\left(t\right)\left[L\left(t\right)-{X}_{2t}\right]dt+V\left(t\right)\sqrt{{X}_{2t}}d{W}_{2t}$`

This model describes the evolution of the variance rate of the coupled Bates price process.

This simulation engine provides a discrete-time approximation of the underlying generalized continuous-time process. The simulation is derived directly from the stochastic differential equation of motion. Thus, the discrete-time process approaches the true continuous-time process only as `DeltaTimes` approaches zero.

References

[1] Deelstra, Griselda, and Freddy Delbaen. “Convergence of Discretized Stochastic (Interest Rate) Processes with Stochastic Drift Term.” Applied Stochastic Models and Data Analysis. 14, no. 1, 1998, pp. 77–84.

[2] Higham, Desmond, and Xuerong Mao. “Convergence of Monte Carlo Simulations Involving the Mean-Reverting Square Root Process.” The Journal of Computational Finance 8, no. 3, (2005): 35–61.

[3] Lord, Roger, Remmert Koekkoek, and Dick Van Dijk. “A Comparison of Biased Simulation Schemes for Stochastic Volatility Models.” Quantitative Finance 10, no. 2 (February 2010): 177–94.

Introduced in R2020a