VectorExtensions.Lag Method

Definition

Namespace: Extreme.DataAnalysis
Assembly: Extreme.Numerics (in Extreme.Numerics.dll) Version: 8.1.23

Overload List

Lag<T>(Vector<T>) Returns a vector whose observations are moved ahead by one observation.
Lag<T>(Vector<T>, Int32) Returns a vector whose observations are moved ahead by the specified number of observations.
Lag<T>(Vector<T>, Int32, T) Returns a vector whose observations are moved ahead by the specified number of observations.

VectorExtensions.Lag<T>(Vector<T>)

Returns a vector whose observations are moved ahead by one observation.
C#
public static Vector<T> Lag<T>(
	this Vector<T> vector
)

Parameters

vector  Vector<T>
The vector to transform.

Type Parameters

T

Return Value

Vector<T>
A vector.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Vector<T>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

Each new observation is the observation before the current observation. The first observation is set to NaN.

The new vector gets the name lag1(<name>), where <name> is the name of the original vector.

VectorExtensions.Lag<T>(Vector<T>, Int32)

Returns a vector whose observations are moved ahead by the specified number of observations.
C#
public static Vector<T> Lag<T>(
	this Vector<T> vector,
	int lag
)

Parameters

vector  Vector<T>
The vector to transform.
lag  Int32
The number of observations to shift the series by.

Type Parameters

T

Return Value

Vector<T>
A vector.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Vector<T>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

A positive value of lag indicates that the observations are shifted forward. If lag equals 1, then each new observation is the observation before the current observation. The first lag observations are set to NaN. If lag equals -1, then each new observation is the observation after the current observation. The last abs(lag) observations are set to NaN.

The name of the new vector depends on whether lag is positive or negative. If lag is positive, the new vector gets the name lag<n>(<name>), where <n> is the lag and <name> is the name of the original vector. If lag is positive, the new vector gets the name lead<abs(n)>(<name>).

VectorExtensions.Lag<T>(Vector<T>, Int32, T)

Returns a vector whose observations are moved ahead by the specified number of observations.
C#
public static Vector<T> Lag<T>(
	this Vector<T> vector,
	int lag,
	T paddedValue
)

Parameters

vector  Vector<T>
The vector to transform.
lag  Int32
The number of observations to shift the series by.
paddedValue  T
The valuie to be used for values in the new series that don't exist in the original series.

Type Parameters

T

Return Value

Vector<T>
A vector.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Vector<T>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

A positive value of lag indicates that the observations are shifted forward. If lag equals 1, then each new observation is the observation before the current observation. The first lag observations are set to paddedValue. If lag equals -1, then each new observation is the observation after the current observation. The last abs(lag) observations are set to paddedValue.

The name of the new vector depends on whether lag is positive or negative. If lag is positive, the new vector gets the name lag<n>(<name>), where <n> is the lag and <name> is the name of the original vector. If lag is positive, the new vector gets the name lead<abs(n)>(<name>).

See Also