| GARCH Toolbox™ | ![]() |
The GARCH Toolbox™ SDE class structure represents a generalization and specialization hierarchy. The top-level class provides the most general model interface and offers the default Monte Carlo simulation and interpolation methods. In turn, derived classes offer restricted interfaces that simplify model creation and manipulation while providing detail regarding model structure.
The following table lists the SDE classes. The introductory examples in the accompanying sections show how to use these classes to create objects associated with univariate models. Although the GARCH Toolbox SDE engine supports multivariate models, univariate models facilitate object creation and display, and allow you to easily associate inputs with object parameters.
SDE Classes
| Class Name | For More Information, See ... |
|---|---|
| SDE | |
| Drift, Diffusion | |
| SDEDDO | Creating Stochastic Differential Equations from Drift and Diffusion Objects (SDEDDO) |
| SDELD | Creating Stochastic Differential Equations from Linear Drift (SDELD) |
| CEV | |
| BM | |
| SDEMRD | Creating Stochastic Differential Equations from Mean-Reverting Drift (SDEMRD) |
| GBM | |
| HWV | |
| CIR | Creating Cox-Ingersoll-Ross (CIR) Square Root Diffusion Models |
The following figure illustrates the inheritance relationships among SDE classes.

The SDE class provides default simulation and interpolation methods for all derived classes:
simulate: High-level wrapper around the user-specified simulation method stored in the Simulation method
simByEuler: Default Euler approximation simulation method
interpolate: Stochastic interpolation method (that is, Brownian bridge)
The HWV and GBM classes feature an additional method, simBySolution, that simulates approximate solutions of diagonal-drift processes.
For more information, see Method Reference.
You use class constructors to create SDE objects. The following sections include examples of how to do this.
For more information, see Stochastic Differential Equation (SDE) Class Constructors.
The base SDE class:
![]()
represents the most general model.
Tip The SDE class is not an abstract class. You can instantiate SDE objects directly to extend the set of core models. |
Constructing an SDE object requires two inputs:
A drift-rate function F. F returns an NVARS-by-1 drift-rate vector when run with the following inputs:
A real-valued scalar observation time t.
An NVARS-by-1 state vector Xt.
A diffusion-rate function G. G returns an NVARS-by-NBROWNS diffusion-rate matrix when run with the inputs t and Xt.
Evaluating object parameters by passing (t, Xt) to a common, published interface allows most parameters to be referenced by a common input argument list that reinforces common method programming. You can use this simple function evaluation approach to model or construct powerful analytics, as in the following example.
Construct an SDE object obj to represent a univariate geometric Brownian Motion model of the form:
|
| (5-5) |
Create drift and diffusion functions that are accessible by the common (t,Xt) interface:
F = @(t,X) 0.1 * X; G = @(t,X) 0.3 * X;
Pass the functions to the SDE constructor to create an object obj of class SDE:
obj = sde(F, G) % dX = F(t,X)dt + G(t,X)dW
obj =
Class SDE: Stochastic Differential Equation
-------------------------------------------
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 simByEulerobj displays like a MATLAB® structure, with the following information:
The object's class
A brief description of the object
A summary of the dimensionality of the model
The object's displayed parameters are as follows:
StartTime: The initial observation time (real-valued scalar)
StartState: The initial state vector (NVARS-by-1 column vector)
Correlation: The correlation structure between Brownian process
Drift: The drift-rate function F(t,Xt)
Diffusion: The diffusion-rate function G(t,Xt)
Simulation: The simulation method or function.
Of these displayed parameters, only Drift and Diffusion are required inputs.
The only exception to the (t, Xt) evaluation interface is Correlation. Specifically, when you enter Correlation as a function, the SDE engine assumes that it is a deterministic function of time, C(t). This restriction on Correlation as a deterministic function of time allows Cholesky factors to be computed and stored before the formal simulation. This inconsistency dramatically improves run-time performance for dynamic correlation structures. If Correlation is stochastic, you can also include it within the simulation architecture as part of a more general random number generation function.
The class-naming conventions introduced here, discussed in more detail in subsequent sections, are meant to be meaningful. When you specify object parameters or simulation inputs as functions, the object assumes no knowledge of implementation details. A given function is required only to evaluate properly when you pass time and state to it.
Because base-level SDE objects accept drift and diffusion objects in lieu of functions accessible by (t, Xt), you can create SDE objects with combinations of customized drift or diffusion functions and objects. The drift and diffusion rate classes encapsulate the details of input parameters to optimize run-time efficiency for any given combination of classes.
Although drift and diffusion objects differ in the details of their representation, they are identical in their basic implementation and interface. They look, feel like, and are evaluated as functions:
The drift class allows you to create drift-rate objects of the form:
![]()
where:
A is an NVARS-by-1 vector-valued function accessible using the (t, Xt) interface.
B is an NVARS-by-NVARS matrix-valued function accessible using the (t, Xt) interface.
Similarly, the diffusion class allows you to create diffusion-rate objects:
![]()
where:
D is an NVARS-by-NVARS diagonal matrix-valued function.
Each diagonal element of D is the corresponding element of the state vector raised to the corresponding element of an exponent Alpha, which is an NVARS-by-1 vector-valued function.
V is an NVARS-by-NBROWNS matrix-valued volatility rate function Sigma.
Alpha and Sigma are also accessible using the (t, Xt) interface.
In this example, you create drift and diffusion rate objects to create the same model as in Example: Creating Base SDE Models.
Create a drift-rate function F and a diffusion-rate function G:
F = drift(0, 0.1) % Drift rate function F(t,X)
G = diffusion(1, 0.3) % Diffusion rate function G(t,X)
F =
Class DRIFT: Drift Rate Specification
-------------------------------------
Rate: drift rate function F(t,X(t))
A: 0
B: 0.1
G =
Class DIFFUSION: Diffusion Rate Specification
---------------------------------------------
Rate: diffusion rate function G(t,X(t))
Alpha: 1
Sigma: 0.3Each object displays like a MATLAB structure and contains supplemental information, namely, the object's class and a brief description. However, in contrast to the SDE representation, a summary of the dimensionality of the model does not appear, because drift and diffusion classes create model components rather than models. Neither F nor G contains enough information to characterize the dimensionality of a problem.
The drift object's displayed parameters are:
Rate: The drift-rate function, F(t,Xt)
A: The intercept term, A(t,Xt), of F(t,Xt)
B: The first order term, B(t,Xt), of F(t,Xt)
A and B enable you to query the original inputs. The function stored in Rate fully encapsulates the combined effect of A and B.
The diffusion object's displayed parameters are:
Rate: The diffusion-rate function, G(t,Xt).
Alpha: The state vector exponent, which determines the format of D(t,Xt) of G(t,Xt).
Sigma: The volatility rate, V(t,Xt), of G(t,Xt).
Again, Alpha and Sigma enable you to query the original inputs. (The combined effect of the individual Alpha and Sigma parameters is fully encapsulated by the function stored in Rate.) The Rate functions are the calculation engines for the drift and diffusion objects, and are the only parameters required for simulation.
The SDEDDO class derives from the base SDE class. To use this class, you must pass drift and diffusion-rate objects to the SDEDDO constructor.
Create drift and diffusion rate objects:
F = drift(0, 0.1); % Drift rate function F(t,X) G = diffusion(1, 0.3); % Diffusion rate function G(t,X)
Pass these objects to the SDEDDO constructor:
obj = sdeddo(F, G) % dX = F(t,X)dt + G(t,X)dW
obj =
Class SDEDDO: SDE from Drift and Diffusion Objects
--------------------------------------------------
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
A: 0
B: 0.1
Alpha: 1
Sigma: 0.3
In this example, the object displays the additional parameters associated with input drift and diffusion objects.
The SDELD class derives from the SDEDDO class. These objects allow you to simulate correlated paths of NVARS state variables expressed in linear drift-rate form:
|
| (5-6) |
SDELD objects provide a parametric alternative to the mean-reverting drift form, as discussed in Example: Creating SDEMRD Models. They also provide an alternative interface to the SDEDDO parent class, because you can create an object without first having to create its drift and diffusion-rate components.
Create the same model as in Example: Creating Base SDE Models:
obj = sdeld(0, 0.1, 1, 0.3) % (A, B, Alpha, Sigma)
obj =
Class SDELD: SDE with Linear 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
A: 0
B: 0.1
Alpha: 1
Sigma: 0.3The Brownian Motion (BM) model derives directly from the linear drift (SDELD) class:
|
| (5-7) |
Create a univariate Brownian motion (BM) object to represent the model:
![]()
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. Use the specialized method only if all of 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 3-dimensional array.
If Z is unspecified, the assumed Gaussian correlation structure is a double matrix.
The Constant Elasticity of Variance (CEV) model also derives directly from the linear drift (SDELD) class:
|
| (5-8) |
The CEV class constrains A to an NVARS-by-1 vector of zeros. D is an unrestricted diagonal matrix whose elements are the corresponding element of the state vector X, raised to an exponent alpha.
Create a univariate CEV object to represent the model:
![]()
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.
The Geometric Brownian Motion (GBM) model derives directly from the CEV model:
|
| (5-9) |
Compared to CEV, GBM 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. You can use this specialized method only if all of the following conditions are true:
The expected rate of return (Return) is a diagonal matrix.
The volatility rate (Sigma) is a matrix.
No end-of-period adjustments/processes are made.
If specified, the random noise process Z is a 3-dimensional array.
If Z is unspecified, the assumed Gaussian correlation structure is a double matrix.
An approximate analytic solution (simBySolution) obtained by applying an 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 piece-wise constant parameters. If the model parameters are piece-wise constant over each observation period, the state vector Xt is log-normally distributed and the simulated process is exact for the observation times at which Xt is sampled.
Create a univariate GBM object to represent the model:
![]()
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
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:
|
| (5-10) |
SDEMRD objects provide a parametric alternative to the linear drift form by reparameterizing the general linear drift such that:
![]()
Create an SDEMRD object obj with a square root exponent to represent the model:
![]()
obj = sdemrd(0.2, 0.1, 0.5, 0.05) % (Speed, Level, Alpha, Sigma)
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
SDEMRD objects display the familiar Speed and Level parameters instead of A and B.
The Cox-Ingersoll-Ross (CIR) short rate class derives directly from SDE with mean-reverting drift (SDEMRD):
|
| (5-11) |
where D is a diagonal matrix whose elements are the square root of the corresponding element of the state vector.
Create a CIR object to represent the same model as in Example: Creating 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.
The Hull-White/Vasicek (HWV) short rate class derives directly from SDE with mean-reverting drift (SDEMRD):
|
| (5-12) |
Using the same parameters as in the previous example, create an HWV object to represent the model:
![]()
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 models 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 piece-wise 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 piece-wise constant parameters. If S(t,Xt), L(t,Xt), and V(t,Xt) are piece-wise 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.
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.
![]() | Parametric Specification | Solving Problems with SDE Models | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |