# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

## Parametric Models

### Creating Brownian Motion (BM) Models

The Brownian Motion (BM) model (`bm`) derives directly from the linear drift (`sdeld`) class:

`$d{X}_{t}=\mu \left(t\right)dt+V\left(t\right)d{W}_{t}$`

### Example: BM Models

Create a univariate Brownian motion (`bm`) object to represent the model using the `bm` constructor:

`$d{X}_{t}=0.3d{W}_{t}.$`

`obj = bm(0, 0.3) % (A = Mu, Sigma)`
```obj = Class BM: Brownian Motion ---------------------------------------- Dimensions: State = 1, Brownian = 1 ---------------------------------------- StartTime: 0 StartState: 0 Correlation: 1 Drift: drift rate function F(t,X(t)) Diffusion: diffusion rate function G(t,X(t)) Simulation: simulation method/function simByEuler Mu: 0 Sigma: 0.3 ```

`bm` objects display the parameter `A` as the more familiar `Mu`.

The`bm` class also provides an overloaded Euler simulation method that improves run-time performance in certain common situations. This specialized method is invoked automatically only if all the following conditions are met:

• The expected drift, or trend, rate `Mu` is a column vector.

• The volatility rate, `Sigma`, is a matrix.

• No end-of-period adjustments and/or processes are made.

• If specified, the random noise process `Z` is a three-dimensional array.

• If `Z` is unspecified, the assumed Gaussian correlation structure is a double matrix.

### Creating Constant Elasticity of Variance (CEV) Models

The Constant Elasticity of Variance (CEV) model (`cev`) also derives directly from the linear drift (`sdeld`) class:

`$d{X}_{t}=\mu \left(t\right){X}_{t}dt+D\left(t,{X}_{t}^{\alpha \left(t\right)}\right)V\left(t\right)d{W}_{t}$`

The `cev` class constrains A to an `NVARS`-by-`1` vector of zeros. D is a diagonal matrix whose elements are the corresponding element of the state vector X, raised to an exponent α(t).

#### Example: Univariate CEV Models

Create a univariate `cev` object to represent the model using the `cev` constructor:

`$d{X}_{t}=0.25{X}_{t}+0.3{X}_{t}^{\frac{1}{2}}d{W}_{t}.$`

`obj = cev(0.25, 0.5, 0.3) % (B = Return, Alpha, Sigma)`
```obj = Class CEV: Constant Elasticity of Variance ------------------------------------------ Dimensions: State = 1, Brownian = 1 ------------------------------------------ StartTime: 0 StartState: 1 Correlation: 1 Drift: drift rate function F(t,X(t)) Diffusion: diffusion rate function G(t,X(t)) Simulation: simulation method/function simByEuler Return: 0.25 Alpha: 0.5 Sigma: 0.3 ```

`cev` and `gbm` objects display the parameter `B` as the more familiar `Return`.

### Creating Geometric Brownian Motion (GBM) Models

The Geometric Brownian Motion (GBM) model (`gbm`) derives directly from the CEV (`cev`) model:

`$d{X}_{t}=\mu \left(t\right){X}_{t}dt+D\left(t,{X}_{t}\right)V\left(t\right)d{W}_{t}$`

Compared to the `cev` object, a `gbm` object constrains all elements of the alpha exponent vector to one such that D is now a diagonal matrix with the state vector X along the main diagonal.

The `gbm` class also provides two simulation methods that can be used by separable models:

• An overloaded Euler simulation method that improves run-time performance in certain common situations. This specialized method is invoked automatically only if all the following conditions are true:

• The expected rate of return (`Return`) is a diagonal matrix.

• The volatility rate (`Sigma`) is a matrix.

• If specified, the random noise process `Z` is a three-dimensional array.

• If `Z` is unspecified, the assumed Gaussian correlation structure is a double matrix.

• An approximate analytic solution (`simBySolution`) obtained by applying a Euler approach to the transformed (using Ito's formula) logarithmic process. In general, this is not the exact solution to this GBM model, as the probability distributions of the simulated and true state vectors are identical only for piecewise constant parameters. If the model parameters are piecewise constant over each observation period, the state vector Xt is lognormally distributed and the simulated process is exact for the observation times at which Xt is sampled.

#### Example: Univariate GBM Models

Create a univariate `gbm` object to represent the model using the `gbm` constructor:

`$d{X}_{t}=0.25{X}_{t}dt+0.3{X}_{t}d{W}_{t}$`

`obj = gbm(0.25, 0.3) % (B = Return, Sigma)`
```obj = Class GBM: Generalized Geometric Brownian Motion ------------------------------------------------ Dimensions: State = 1, Brownian = 1 ------------------------------------------------ StartTime: 0 StartState: 1 Correlation: 1 Drift: drift rate function F(t,X(t)) Diffusion: diffusion rate function G(t,X(t)) Simulation: simulation method/function simByEuler Return: 0.25 Sigma: 0.3 ```

### Creating Stochastic Differential Equations from Mean-Reverting Drift (SDEMRD) Models

The `sdemrd` class derives directly from the `sdeddo` class. It provides an interface in which the drift-rate function is expressed in mean-reverting drift form:

`$d{X}_{t}=S\left(t\right)\left[L\left(t\right)-{X}_{t}\right]dt+D\left(t,{X}_{t}^{\alpha \left(t\right)}\right)V\left(t\right)d{W}_{t}$`

`sdemrd` objects provide a parametric alternative to the linear drift form by reparameterizing the general linear drift such that:

`$A\left(t\right)=S\left(t\right)L\left(t\right),B\left(t\right)=-S\left(t\right)$`

#### Example: SDEMRD Models

Create an `sdemrd` object using the `sdemrd` constructor with a square root exponent to represent the model:

`$d{X}_{t}=0.2\left(0.1-{X}_{t}\right)dt+0.05{X}_{t}^{\frac{1}{2}}d{W}_{t}.$`

`obj = sdemrd(0.2, 0.1, 0.5, 0.05)`
```obj = Class SDEMRD: SDE with Mean-Reverting Drift ------------------------------------------- Dimensions: State = 1, Brownian = 1 ------------------------------------------- StartTime: 0 StartState: 1 Correlation: 1 Drift: drift rate function F(t,X(t)) Diffusion: diffusion rate function G(t,X(t)) Simulation: simulation method/function simByEuler Alpha: 0.5 Sigma: 0.05 Level: 0.1 Speed: 0.2 ```
` % (Speed, Level, Alpha, Sigma)`

`sdemrd` objects display the familiar `Speed` and `Level` parameters instead of `A` and `B`.

### Creating Cox-Ingersoll-Ross (CIR) Square Root Diffusion Models

The Cox-Ingersoll-Ross (CIR) short rate class, `cir`, derives directly from the SDE with mean-reverting drift (`sdemrd`) class:

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

where D is a diagonal matrix whose elements are the square root of the corresponding element of the state vector.

#### Example: CIR Models

Create a `cir` object using the `cir` constructor to represent the same model as in Example: SDEMRD Models:

`obj = cir(0.2, 0.1, 0.05) % (Speed, Level, Sigma)`
```obj = Class CIR: Cox-Ingersoll-Ross ---------------------------------------- Dimensions: State = 1, Brownian = 1 ---------------------------------------- StartTime: 0 StartState: 1 Correlation: 1 Drift: drift rate function F(t,X(t)) Diffusion: diffusion rate function G(t,X(t)) Simulation: simulation method/function simByEuler Sigma: 0.05 Level: 0.1 Speed: 0.2 ```

Although the last two objects are of different classes, they represent the same mathematical model. They differ in that you create the `cir` object by specifying only three input arguments. This distinction is reinforced by the fact that the `Alpha` parameter does not display – it is defined to be `1/2`.

### Creating Hull-White/Vasicek (HWV) Gaussian Diffusion Models

The Hull-White/Vasicek (HWV) short rate class, `hwv`, derives directly from SDE with mean-reverting drift (`sdemrd`) class:

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

#### Example: HWV Models

Using the same parameters as in the previous example, create an `hwv` object using the `hwv` constructor to represent the model:

`$d{X}_{t}=0.2\left(0.1-{X}_{t}\right)dt+0.05d{W}_{t}.$`

`obj = hwv(0.2, 0.1, 0.05) % (Speed, Level, Sigma)`
```obj = Class HWV: Hull-White/Vasicek ---------------------------------------- Dimensions: State = 1, Brownian = 1 ---------------------------------------- StartTime: 0 StartState: 1 Correlation: 1 Drift: drift rate function F(t,X(t)) Diffusion: diffusion rate function G(t,X(t)) Simulation: simulation method/function simByEuler Sigma: 0.05 Level: 0.1 Speed: 0.2 ```

`cir` and `hwv` constructors share the same interface and display methods. The only distinction is that `cir` and `hwv` model objects constrain `Alpha` exponents to `1/2` and `0`, respectively. Furthermore, the`hwv` class also provides an additional method that simulates approximate analytic solutions (`simBySolution`) of separable models. This method simulates the state vector Xt using an approximation of the closed-form solution of diagonal drift `HWV` models. Each element of the state vector Xt is expressed as the sum of `NBROWNS` correlated Gaussian random draws added to a deterministic time-variable drift.

When evaluating expressions, all model parameters are assumed piecewise constant over each simulation period. In general, this is not the exact solution to this `hwv` model, because the probability distributions of the simulated and true state vectors are identical only for piecewise constant parameters. If S(t,Xt), L(t,Xt), and V(t,Xt) are piecewise constant over each observation period, the state vector Xt is normally distributed, and the simulated process is exact for the observation times at which Xt is sampled.

#### Hull-White vs. Vasicek Models

Many references differentiate between Vasicek models and Hull-White models. Where such distinctions are made, Vasicek parameters are constrained to be constants, while Hull-White parameters vary deterministically with time. Think of Vasicek models in this context as constant-coefficient Hull-White models and equivalently, Hull-White models as time-varying Vasicek models. However, from an architectural perspective, the distinction between static and dynamic parameters is trivial. Since both models share the same general parametric specification as previously described, a single`hwv` class encompasses the models.

### Creating Heston Stochastic Volatility Models

The Heston (`heston`) class derives directly from SDE from Drift and Diffusion (`sdeddo`) class. Each Heston model is a bivariate composite model, consisting of two coupled univariate models:

 $d{X}_{1t}=B\left(t\right){X}_{1t}dt+\sqrt{{X}_{2t}}{X}_{1t}d{W}_{1t}$ (17-5)
 $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}$ (17-6)
Equation 17-5 is typically associated with a price process. Equation 17-6 represents the evolution of the price process' variance. Models of type `heston` are typically used to price equity options.

#### Example: Heston Models

Create a `heston` object using the `heston` constructor to represent the model:

`$\begin{array}{l}d{X}_{1t}=0.1{X}_{1t}dt+\sqrt{{X}_{2t}}{X}_{1t}d{W}_{1t}\\ d{X}_{2t}=0.2\left[0.1-{X}_{2t}\right]dt+0.05\sqrt{{X}_{2t}}d{W}_{2t}\end{array}$`

`obj = heston (0.1, 0.2, 0.1, 0.05)`
```obj = Class HESTON: Heston Bivariate Stochastic Volatility ---------------------------------------------------- Dimensions: State = 2, Brownian = 2 ---------------------------------------------------- StartTime: 0 StartState: 1 (2x1 double array) Correlation: 2x2 diagonal 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.1 Speed: 0.2 Level: 0.1 Volatility: 0.05 ```