Finding Nearest Neighbors and Keeping their Topological Information (Lite Version)
Source:R/pastNNsInfo_Lite.R
pastNNsInfo_Lite.Rd
This function is a simplified version of pastNNsInfo
, identifying the nearest neighbors of a given point in a time series. It returns detailed information about these neighbors, including their times, distances, signatures, patterns, and coordinates, without excluding common coordinate vectors and horizon.
Arguments
- CCSPAN
Integer, the span of common coordinates to exclude from the nearest neighbor search (not used in Lite version).
- 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 (not used in Lite version).
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(200), nrow = 20)
CCSPAN <- (E - 1) * tau
NNSPAN <- E + 1
i <- 15
h <- 2
Dx <- distanceVector(point = Mx[i, ], candidateNNs = Mx[1:(i - CCSPAN - h), ], n = 2)
SMx <- signatureSpace(Mx, E)
PSMx <- patternSpace(SMx, E)
neighborsInfoLite <- pastNNsInfo_Lite(CCSPAN, NNSPAN, Mx, Dx, SMx, PSMx, i, h)
print(neighborsInfoLite)
#> $i
#> [1] 15
#>
#> $times
#> [1] 2 8 10 1
#>
#> $dists
#> 2 8 10 1
#> 3.194540 3.795441 3.886333 4.116415
#>
#> $signatures
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> [1,] 0.01220257 0.01005764 -0.2944062 0.8876039 -0.1283967 -1.2043583
#> [2,] 1.41843435 -0.62002847 0.5196596 0.3821773 -2.1031234 1.7459028
#> [3,] 1.69947689 -1.33718399 2.1334538 -0.9012771 -0.2298110 -0.9903047
#> [4,] -0.50734806 0.37311673 1.0743465 -0.3738753 -0.7161707 0.8280532
#> [,7] [,8] [,9]
#> [1,] 0.6852771 -0.7869795 2.3123622
#> [2,] 0.6099559 -1.1716974 0.5685179
#> [3,] -1.2157224 1.6559950 -0.8682565
#> [4,] 0.5841377 0.3509271 -2.1160376
#>
#> $patterns
#> [1] 124515570 124596402 51212562 52018998
#>
#> $coordinates
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> [1,] -0.2301775 -0.2179749 -0.20791728 -0.50232345 0.385280401 0.2568837
#> [2,] -1.2650612 0.1533731 -0.46665535 0.05300423 0.435181491 -1.6679419
#> [3,] -0.4456620 1.2538149 -0.08336907 2.05008469 1.148807618 0.9189966
#> [4,] -0.5604756 -1.0678237 -0.69470698 0.37963948 0.005764186 -0.7104066
#> [,7] [,8] [,9] [,10]
#> [1,] -0.94747461 -0.2621975 -1.0491770 1.26318518
#> [2,] 0.07796085 0.6879168 -0.4837806 0.08473729
#> [3,] -0.07130809 -1.2870305 0.3689645 -0.49929202
#> [4,] 0.11764660 0.7017843 1.0527115 -1.06332613
#>