Documentation

This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

ts2func

Convert time series arrays to functions of time and state

Synopsis

F = ts2func(Array)

F = ts2func(Array, 'Name1', Value1, 'Name2', Value2, ...)

Description

The ts2func function encapsulates a time series array associated with a vector of real-valued observation times within a MATLAB® function suitable for Monte Carlo simulation of an NVARS-by-1 state vector Xt.

Input Arguments

Array Time series array to encapsulate within a callable function of time and state. Array may be a vector, 2-dimensional matrix, or three-dimensional array.

Optional Input Arguments

Specify optional input arguments as variable-length lists of matching parameter name/value pairs: 'Name1', Value1, 'Name2', Value2, ... and so on. The following rules apply when specifying parameter-name pairs:

  • Specify the parameter name as a character vector, followed by its corresponding parameter value.

  • You can specify parameter name/value pairs in any order.

  • Parameter names are case insensitive.

  • You can specify unambiguous partial character vector matches.

Valid parameter names are:

Times

Vector of monotonically increasing observation times associated with the time series input array Array. If you do not specify a value for this argument, Times is a zero-based, unit-increment vector of the same length as that of the dimension of Array associated with time (see TimeDimension).

TimeDimension

Positive scalar integer that specifies which dimension of the input time series array Array is associated with time. The value of this argument cannot be greater than the number of dimensions of Array. If you do not specify a value for this argument, the default is 1, indicating that time is associated with the rows of Array.

StateDimension

Positive scalar integer that specifies which dimension of the input time series array Array is associated with the NVARS state variables. StateDimension cannot be greater than the number of dimensions of Array. If you do not specify a value for this argument, ts2func assigns StateDimension the first dimension of Array that is not already associated with time (the state vector Xt is associated with the first available dimension of Array not already assigned to TimeDimension).

Deterministic

A scalar, logical flag to indicate whether the output function is a deterministic function of time alone. If Deterministic is true, the output function F is a deterministic function of time, F(t), and the only input it accepts is a scalar, real-valued time t. If Deterministic is false, the output function F accepts two inputs, a scalar, real-valued time t followed by an NVARS-by-1 state vectorX(t). The default is false, and F is a callable function of time and state, F(t,X) .

Output Arguments

F

Callable function F(t) of a real-valued scalar observation time t. You can invoke F with a second input (such as an NVARS-by-1 state vector X), which is a placeholder that ts2func ignores. For example, while F(t) and F(t,X) produce identical results, the latter directly supports SDE simulation methods.

If the optional input argument Deterministic is true, F is a deterministic function of time, F(t), and the only input it accepts is a scalar, real-valued time t. Otherwise, if Deterministic is false (the default), F accepts a scalar, real-valued time t followed by an NVARS-by-1 state vector X(t).

Algorithms

  • When you specify Array as a trivial scalar or a vector (row or column), ts2func assumes that it represents a univariate time series.

  • F returns an array with one fewer dimension than the input time series array Array with which F is associated. Thus, when Array is a vector, a 2-dimensional matrix, or a three-dimensional array, F returns a scalar, vector, or 2-dimensional matrix, respectively.

  • When the scalar time t at which ts2func evaluates the function F does not coincide with an observation time in Times, F performs a zero-order-hold interpolation. The only exception is if t precedes the first element of Times, in which case F(t) = F(Times(1)).

  • To support Monte Carlo simulation methods, the output function F returns an NVARS-by-1 column vector or a 2-dimensional matrix with NVARS rows.

  • The output function F is always a deterministic function of time, F(t), and may always be called with a single input regardless of the Deterministic flag. The distinction is that when Deterministic is false, the function F may also be called with a second input, an NVARS-by-1 state vector X(t), which is a placeholder and ignored. While F(t) and F(t,X) produce identical results, the former specifically indicates that the function is a deterministic function of time, and may offer significant performance benefits in some situations.

References

Ait-Sahalia, Y. “Testing Continuous-Time Models of the Spot Interest Rate.” The Review of Financial Studies, Spring 1996, Vol. 9, No. 2, pp. 385–426.

Ait-Sahalia, Y. “Transition Densities for Interest Rate and Other Nonlinear Diffusions.” The Journal of Finance, Vol. 54, No. 4, August 1999.

Glasserman, P. Monte Carlo Methods in Financial Engineering. New York, Springer-Verlag, 2004.

Hull, J. C. Options, Futures, and Other Derivatives, 5th ed. Englewood Cliffs, NJ: Prentice Hall, 2002.

Johnson, N. L., S. Kotz, and N. Balakrishnan. Continuous Univariate Distributions. Vol. 2, 2nd ed. New York, John Wiley & Sons, 1995.

Shreve, S. E. Stochastic Calculus for Finance II: Continuous-Time Models. New York: Springer-Verlag, 2004.

Introduced in R2008a

Was this topic helpful?