Finding Nearest Neighbors and Keeping their Topological Information
Source:R/pastNNsInfo.R
pastNNsInfo.Rd
This function identifies the nearest neighbors of a given point in a time series, excluding common coordinate vectors and a specified horizon from the candidate nearest neighbors. It returns detailed information about these neighbors, including their times, distances, signatures, patterns, and coordinates.
Arguments
- CCSPAN
Integer, the span of common coordinates to exclude from the nearest neighbor search.
- NNSPAN
Integer, the number of nearest neighbors to consider for the analysis.
- Mx
Matrix, the main matrix representing the state space of the system.
- Dx
Numeric matrix, containing distances between points in the state space.
- SMx
Matrix, containing signatures of the state space.
- PSMx
Matrix, containing patterns derived from the signatures.
- i
Integer, the current index in time series data for which nearest neighbors are being considered.
- h
Integer, the horizon beyond which data is not considered in the nearest neighbor search.
Value
A list containing:
i
: The current index in time series data.times
: The times of the nearest neighbors.dists
: The distances to the nearest neighbors.signatures
: The signatures of the nearest neighbors.patterns
: The patterns of the nearest neighbors.coordinates
: The coordinates of the nearest neighbors.
Examples
# Generate random data for demonstration
set.seed(123)
E <- 3
tau <- 1
Mx <- matrix(rnorm(300), nrow = 100)
Dx <- distanceMatrix(Mx, "minkowski")
SMx <- signatureSpace(Mx, E)
PSMx <- patternSpace(SMx, E)
CCSPAN <- (E - 1) * tau
NNSPAN <- E + 1
i <- 15
h <- 2
neighborsInfo <- pastNNsInfo(CCSPAN, NNSPAN, Mx, Dx, SMx, PSMx, i, h)
print(neighborsInfo)
#> $i
#> [1] 15
#>
#> $times
#> [1] 10 7 5 4
#>
#> $dists
#> 10 7 5 4
#> 1.025941 1.666314 1.722671 1.871442
#>
#> $signatures
#> [,1] [,2]
#> [1,] 1.364659 -0.973024734
#> [2,] -1.245821 -0.003698368
#> [3,] -1.080906 0.537278619
#> [4,] -0.418051 0.890736659
#>
#> $patterns
#> [1] 42 30 78 78
#>
#> $coordinates
#> [,1] [,2] [,3]
#> [1,] -0.44566197 0.9189966 -0.05402813
#> [2,] 0.46091621 -0.7849045 -0.78860284
#> [3,] 0.12928774 -0.9516186 -0.41433995
#> [4,] 0.07050839 -0.3475426 0.54319406
#>