Using SDE Objects to Create Models

SDE Classes

The SDE Class Hierarchy

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 NameFor More Information, See ...
SDE

Creating Base SDE Objects

Drift, Diffusion

Creating Drift and Diffusion Objects

SDEDDO

Creating Stochastic Differential Equations from Drift and Diffusion Objects (SDEDDO)

SDELD

Creating Stochastic Differential Equations from Linear Drift (SDELD)

CEV

Creating Constant Elasticity of Variance (CEV) Models

BM

Creating Brownian Motion (BM) Models

SDEMRD

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

GBM

Creating Geometric Brownian Motion (GBM) Models

HWV

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

CIR

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

The following figure illustrates the inheritance relationships among SDE classes.

SDE Methods

The SDE class provides default simulation and interpolation methods for all derived classes:

The HWV and GBM classes feature an additional method, simBySolution, that simulates approximate solutions of diagonal-drift processes.

For more information, see Method Reference.

SDE Class Constructors

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.

Creating Base SDE Objects

About Base SDE Models

The base SDE class:

represents the most general model.

Constructing an SDE object requires two inputs:

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.

Example: Creating Base SDE Models

Construct an SDE object obj to represent a univariate geometric Brownian Motion model of the form:

(5-5)
  1. 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;
    
  2. 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 simByEuler

obj displays like a MATLAB® structure, with the following information:

The object's displayed parameters are as follows:

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.

Specifying Object Parameters and Simulation Inputs

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.

Creating Drift and Diffusion Objects

About Drift and Diffusion Objects

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:

Example: Creating Drift and Diffusion Rate Objects as Model Inputs

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

Each 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:

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:

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.

Creating Stochastic Differential Equations from Drift and Diffusion Objects (SDEDDO)

About SDEDDO Models

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.

Example: Creating SDEDDO Models

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

Creating Stochastic Differential Equations from Linear Drift (SDELD)

About SDELD Models

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.

Example: Creating SDELD Models

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

Creating Brownian Motion (BM) Models

About BM Models

The Brownian Motion (BM) model derives directly from the linear drift (SDELD) class:

(5-7)

Example: Creating BM Models

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:

Creating Constant Elasticity of Variance (CEV) Models

About CEV Models

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.

Example: Creating Univariate CEV Models

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.

Creating Geometric Brownian Motion (GBM) Models

About GBM Models

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:

Example: Creating Univariate GBM Models

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

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

About 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:

(5-10)

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

Example: Creating SDEMRD Models

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.

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

About CIR Models

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.

Example: Creating CIR Models

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.

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

About HWV Models

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

(5-12)

Example: Creating HWV Models

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.

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.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS