Given a time series (timeSeries), an embedding dimension (m) and a time lag (timeLag), the \(n^{th}\) Takens' vector is defined as $$T[n]={timeSeries[n], timeSeries[n+ timeLag],...timeSeries[n+m*timeLag]}.$$ This function estimates an appropiate time lag by using the autocorrelation or the average mutual information (AMI) function.
CalculateTimeLag(
HRVData,
technique = c("acf", "ami"),
method = c("first.e.decay", "first.zero", "first.minimum", "first.value"),
value = 1/exp(1),
lagMax = NULL,
doPlot = TRUE,
...
)
The estimated time lag.
Data structure that stores the beats register and information related to it.
The technique that we shall use to estimate the time lag. Allowed values are "acf" and "ami".
The method that we shall use to select the time lag (see the Details section). Available methods are "first.zero", "first.e.decay", "first.minimum" and "first.value".
Numeric value indicating the value that the autocorrelation/AMI function must cross in order to select the time lag. It is used only with the "first.value" method.
Maximum lag at which to calculate the acf/AMI.
Logical value. If TRUE (default value), a plot of the autocorrelation/AMI function is shown.
Additional parameters for the acf or the
mutualInformation functions (see mutualInformation
).
A basic criteria for estimating a proper time lag is based on the following reasoning: if the time lag used to build the Takens' vectors is too small, the coordinates will be too highly temporally correlated and the embedding will tend to cluster around the diagonal in the phase space. If the time lag is chosen too large, the resulting coordinates may be almost uncorrelated and the resulting embedding will be very complicated. Thus, the autocorrelation function can be used for estimating an appropiate time lag of a time series. However, it must be noted that the autocorrelation is a linear statistic, and thus it does not take into account nonlinear dynamical correlations. To take into account nonlinear correlations the average mutual information (AMI) can be used. Independently of the technique used to compute the correlation, the time lag can be selected in a variety of ways:
Select the time lag where the autocorrelation/AMI function decays to 0 (first.zero method). This method is not appropriate for the AMI function, since it only takes positive values.
Select the time lag where the autocorrelation/AMI function decays to 1/e of its value at zero (first.e.decay method).
Select the time lag where the autocorrelation/AMI function reaches its first minimum (first.minimum method).
Select the time lag where the autocorrelation/AMI function decays to the value specified by the user (first.value method and value parameter).
H. Kantz and T. Schreiber: Nonlinear Time series Analysis (Cambridge university press)
timeLag
,mutualInformation
.
if (FALSE) {
data(HRVProcessedData)
HRVData = HRVProcessedData
HRVData = SetVerbose(HRVData,T)
timeLag = CalculateTimeLag(HRVData,technique = "ami")
embeddingDim = CalculateEmbeddingDim(HRVData,
timeLag = timeLag,
maxEmbeddingDim = 15)
}
Run the code above in your browser using DataLab