sde

Stochastic Differential Equation (SDE) model

Description

Creates and displays general stochastic differential equation (SDE) models from user-defined drift and diffusion rate functions.

Use sde objects to simulate sample paths of NVars state variables driven by NBROWNS Brownian motion sources of risk over NPeriods consecutive observation periods, approximating continuous-time stochastic processes.

An sde object enables you to simulate any vector-valued SDE of the form:

$d{X}_{t}=F\left(t,{X}_{t}\right)dt+G\left(t,{X}_{t}\right)d{W}_{t}$

where:

• Xt is an NVars-by-1 state vector of process variables.

• dWt is an NBROWNS-by-1 Brownian motion vector.

• F is an NVars-by-1 vector-valued drift-rate function.

• G is an NVars-by-NBROWNS matrix-valued diffusion-rate function.

Creation

Description

example

SDE = sde(DriftRate,DiffusionRate) creates a default SDE object.

example

SDE = sde(___,Name,Value) creates a SDE object with additional options specified by one or more Name,Value pair arguments.

Name is a property name and Value is its corresponding value. Name must appear inside single quotes (''). You can specify several name-value pair arguments in any order as Name1,Value1,…,NameN,ValueN.

The SDE object has the following Properties:

• StartTime — Initial observation time

• StartState — Initial state at time StartTime

• Correlation — Access function for the Correlation input argument, callable as a function of time

• Drift — Composite drift-rate function, callable as a function of time and state

• Diffusion — Composite diffusion-rate function, callable as a function of time and state

• Simulation — A simulation function or method

Input Arguments

expand all

DriftRate is a user-defined drift-rate function and represents the parameter F, specified as a vector or object of class drift.

DriftRate is a function that returns an NVars-by-1 drift-rate vector when called with two inputs:

• A real-valued scalar observation time t.

• An NVars-by-1 state vector Xt.

Alternatively, DriftRate can also be an object of class drift that encapsulates the drift-rate specification. In this case, however, sde uses only the Rate parameter of the object. For more information on the drift object, see drift.

Data Types: double | object

DiffusionRate is a user-defined drift-rate function and represents the parameter G, specified as a matrix or object of class diffusion.

DiffusionRate is a function that returns an NVars-by-NBROWNS diffusion-rate matrix when called with two inputs:

• A real-valued scalar observation time t.

• An NVars-by-1 state vector Xt.

Alternatively, DiffusionRate can also be an object of class diffusion that encapsulates the diffusion-rate specification. In this case, however, sde uses only the Rate parameter of the object. For more information on the diffusion object, see diffusion.

Data Types: double | object

Properties

expand all

Starting time of first observation, applied to all state variables, specified as a scalar

Data Types: double

Initial values of state variables, specified as a scalar, column vector, or matrix.

If StartState is a scalar, sde applies the same initial value to all state variables on all trials.

If StartState is a column vector, sde applies a unique initial value to each state variable on all trials.

If StartState is a matrix, sde applies a unique initial value to each state variable on each trial.

Data Types: double

Correlation between Gaussian random variates drawn to generate the Brownian motion vector (Wiener processes), specified as an NBROWNS-by-NBROWNS positive semidefinite matrix, or as a deterministic function C(t) that accepts the current time t and returns an NBROWNS-by-NBROWNS positive semidefinite correlation matrix. If Correlation is not a symmetric positive semidefinite matrix, use nearcorr to create a positive semidefinite matrix for a correlation matrix.

A Correlation matrix represents a static condition.

As a deterministic function of time, Correlation allows you to specify a dynamic correlation structure.

Data Types: double

User-defined simulation function or SDE simulation method, specified as a function or SDE simulation method.

Data Types: function_handle

This property is read-only.

Drift rate component of continuous-time stochastic differential equations (SDEs), specified as a drift object or function accessible by (t, Xt.

The drift rate specification supports the simulation of sample paths of NVars state variables driven by NBROWNS Brownian motion sources of risk over NPeriods consecutive observation periods, approximating continuous-time stochastic processes.

The drift class allows you to create drift-rate objects (using drift) of the form:

$F\left(t,{X}_{t}\right)=A\left(t\right)+B\left(t\right){X}_{t}$

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.

The displayed parameters for a drift object 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.

When specified as MATLAB® double arrays, the inputs A and B are clearly associated with a linear drift rate parametric form. However, specifying either A or B as a function allows you to customize virtually any drift rate specification.

Note

You can express drift and diffusion classes in the most general form to emphasize the functional (t, Xt) interface. However, you can specify the components A and B as functions that adhere to the common (t, Xt) interface, or as MATLAB arrays of appropriate dimension.

Example: F = drift(0, 0.1) % Drift rate function F(t,X)

Data Types: object

This property is read-only.

Diffusion rate component of continuous-time stochastic differential equations (SDEs), specified as a drift object or function accessible by (t, Xt.

The diffusion rate specification supports the simulation of sample paths of NVars state variables driven by NBROWNS Brownian motion sources of risk over NPeriods consecutive observation periods, approximating continuous-time stochastic processes.

The diffusion class allows you to create diffusion-rate objects (using diffusion):

$G\left(t,{X}_{t}\right)=D\left(t,{X}_{t}^{\alpha \left(t\right)}\right)V\left(t\right)$

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.

The displayed parameters for a diffusion object 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).

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.

Note

You can express drift and diffusion classes in the most general form to emphasize the functional (t, Xt) interface. However, you can specify the components A and B as functions that adhere to the common (t, Xt) interface, or as MATLAB arrays of appropriate dimension.

Example: G = diffusion(1, 0.3) % Diffusion rate function G(t,X)

Data Types: object

Object Functions

 interpolate Brownian interpolation of stochastic differential equations simulate Simulate multivariate stochastic differential equations (SDEs) simByEuler Euler simulation of stochastic differential equations (SDEs)

Examples

collapse all

Construct an SDE object obj to represent a univariate geometric Brownian Motion model of the form: $d{X}_{t}=0.1{X}_{t}dt+0.3{X}_{t}d{W}_{t}$.

Create drift and diffusion functions that are accessible by the common $\left(t,{X}_{t}\right)$ interface:

F = @(t,X) 0.1 * X;
G = @(t,X) 0.3 * X;

Pass the functions to sde 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 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\left(t,{X}_{t}\right)$

• Diffusion: The diffusion-rate function $G\left(t,{X}_{t}\right)$

• Simulation: The simulation method or function.

Of these displayed parameters, only Drift and Diffusion are required inputs.

The only exception to the ($t$, ${X}_{t}$) 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\left(t\right)$. 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.

expand all

Algorithms

When you specify the required input parameters as arrays, they are associated with a specific parametric form. By contrast, when you specify either required input parameter as a function, you can customize virtually any specification.

Accessing the output parameters with no inputs simply returns the original input specification. Thus, when you invoke these parameters with no inputs, they behave like simple properties and allow you to test the data type (double vs. function, or equivalently, static vs. dynamic) of the original input specification. This is useful for validating and designing methods.

When you invoke these parameters with inputs, they behave like functions, giving the impression of dynamic behavior. The parameters accept the observation time t and a state vector Xt, and return an array of appropriate dimension. Even if you originally specified an input as an array, sde treats it as a static function of time and state, by that means guaranteeing that all parameters are accessible by the same interface.

References

[1] Aït-Sahalia, Yacine. “Testing Continuous-Time Models of the Spot Interest Rate.” Review of Financial Studies, vol. 9, no. 2, Apr. 1996, pp. 385–426.

[2] Aït-Sahalia, Yacine. “Transition Densities for Interest Rate and Other Nonlinear Diffusions.” The Journal of Finance, vol. 54, no. 4, Aug. 1999, pp. 1361–95.

[3] Glasserman, Paul. Monte Carlo Methods in Financial Engineering. Springer, 2004.

[4] Hull, John. Options, Futures and Other Derivatives. 7th ed, Prentice Hall, 2009.

[5] Johnson, Norman Lloyd, et al. Continuous Univariate Distributions. 2nd ed, Wiley, 1994.

[6] Shreve, Steven E. Stochastic Calculus for Finance. Springer, 2004.

Introduced in R2008a