naginterfaces.library.tsa.inhom_​iema_​all

naginterfaces.library.tsa.inhom_iema_all(z, t, tau, m1, inter, ftype, p, sorder=1, sinit=None, x=None, pn=0, comm=None)[source]

inhom_iema_all calculates the iterated exponential moving average for an inhomogeneous time series, returning the intermediate results.

For full information please refer to the NAG Library document for g13mf

https://www.nag.com/numeric/nl/nagdoc_27.1/flhtml/g13/g13mff.html

Parameters
zfloat, array-like, shape

, the current block of observations, for , where is the number of observations processed so far, i.e., the value supplied in on entry.

tfloat, array-like, shape

, the times for the current block of observations, for , where is the number of observations processed so far, i.e., the value supplied in on entry.

If , = 61 will be returned, but inhom_iema_all will continue as if was strictly increasing by using the absolute value.

taufloat

, the parameter controlling the rate of decay. must be sufficiently large that , can be calculated without overflowing, for all .

m1int

The minimum number of times the EMA operator is to be iterated.

interint, array-like, shape

The type of interpolation used with indicating the interpolation method to use when calculating and the interpolation method to use when calculating , .

Three types of interpolation are possible:

Previous point, with .

Linear, with .

Next point, .

Zumbach and Müller (2001) recommend that linear interpolation is used in second and subsequent iterations, i.e., , irrespective of the interpolation method used at the first iteration, i.e., the value of .

ftypeint

The function type used to define the relationship between and when calculating . Three functions are provided:

The identity function, with .

The absolute value, with .

The absolute difference, with , where the vector is supplied in .

pfloat

, the power used in the transformation function.

sorderint, optional

Determines the storage order of output returned in .

sinitNone or float, array-like, shape , optional

If , the values used to start the iterative process, with

,

,

, .

If then is not referenced.

xNone or float, array-like, shape , optional

Note: the required length for this argument is determined as follows: if : ; otherwise: .

If , , the vector used to shift the current block of observations, for , where is the number of observations processed so far, i.e., the value supplied in on entry.

If then is not referenced.

pnint, optional

, the number of observations processed so far. On the first call to inhom_iema_all, or when starting to summarise a new dataset, must be set to . On subsequent calls it must be the same value as returned by the last call to inhom_iema_all.

commNone or dict, communication object, optional, modified in place

Communication structure.

On initial entry: need not be set.

Returns
iemafloat, ndarray, shape

The iterated exponential moving average.

If , .

If , .

For , and is the number of observations processed so far, i.e., the value supplied in on entry.

pfloat

If , then , the actual power used in the transformation function is returned, otherwise is unchanged.

pnint

, the updated number of observations processed so far.

Raises
NagValueError
(errno )

On entry, .

Constraint: or .

(errno )

On entry, .

Constraint: .

(errno )

On entry, , and .

Constraint: .

(errno )

On entry, , and .

Constraint: .

(errno )

On entry, , and .

Constraint: if linear interpolation is being used.

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

On entry at previous call, .

Constraint: if then must be unchanged since previous call.

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

On entry at previous call, .

Constraint: if then must be unchanged since previous call.

(errno )

On entry, and .

Constraint: .

(errno )

On entry, .

On entry at previous call, .

Constraint: if then must be unchanged since previous call.

(errno )

On entry, , and .

Constraint: if , , for .

(errno )

On entry, .

Constraint: , or .

(errno )

On entry, .

Constraint: , or .

(errno )

On entry, and .

On entry at previous call, , .

Constraint: if , must be unchanged since the last call.

(errno )

On entry, .

Constraint: , or .

(errno )

On entry, , On entry at previous call, .

Constraint: if , must be unchanged since the previous call.

(errno )

On entry, .

Constraint: absolute value of must be representable as an integer.

(errno )

On entry, .

Constraint: if , . If , the nearest integer to must not be .

(errno )

On entry, , and .

Constraint: if or and for any then .

(errno )

On entry, , , and .

Constraint: if and for any then .

(errno )

On entry, .

On exit from previous call, .

Constraint: if then must be unchanged since previous call.

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

On exit from previous call, .

Constraint: if then must be unchanged since previous call.

(errno )

[‘rcomm’] has been corrupted between calls.

(errno )

On entry, , and .

Constraint: if , or .

(errno )

On entry, , and .

Constraint: if then .

Warns
NagAlgorithmicWarning
(errno )

On entry, , and .

Constraint: should be strictly increasing.

(errno )

Truncation occurred to avoid overflow, check for extreme values in , , or for .

Notes

inhom_iema_all calculates the iterated exponential moving average for an inhomogeneous time series. The time series is represented by two vectors of length : a vector of times, ; and a vector of values, . Each element of the time series is, therefore, composed of the pair of scalar values , for . Time can be measured in any arbitrary units, as long as all elements of use the same units.

The exponential moving average (EMA), with parameter , is an average operator, with the exponentially decaying kernel given by

The exponential form of this kernel gives rise to the following iterative formula (Zumbach and Müller (2001)) for the EMA operator:

where

The value of depends on the method of interpolation chosen and the relationship between and the input series depends on the transformation function chosen. inhom_iema_all gives the option of three interpolation methods:

Previous point:

;

Linear:

;

Next point:

.

and three transformation functions:

Identity:

;

Absolute value:

;

Absolute difference:

;

where the notation is used to denote the integer nearest to . In the case of the absolute difference is a user-supplied vector of length and, therefore, each element of the time series is composed of the triplet of scalar values, .

The -iterated exponential moving average, , is defined using the recursive formula:

with

For large datasets or where all the data is not available at the same time, and, where required, can be split into arbitrary sized blocks and inhom_iema_all called multiple times.

References

Dacorogna, M M, Gencay, R, Müller, U, Olsen, R B and Pictet, O V, 2001, An Introduction to High-frequency Finance, Academic Press

Zumbach, G O and Müller, U A, 2001, Operators on inhomogeneous time series, International Journal of Theoretical and Applied Finance (4(1)), 147–178