This function computes the distance matrix from a given embedded matrix, M
, using a specified metric. The distance matrix is essential for exploring the underlying structure in complex systems by quantifying the distances between different points (or states) in the embedded space. This matrix can be crucial for further analysis like clustering, nearest neighbor searches, or causality inference in complex systems.
Arguments
- M
Numeric matrix, the embedded state space matrix where each row represents a point in the reconstructed state space of a time series or any multidimensional data.
- metric
Character, the distance metric to be used for computing distances. Common metrics include "euclidean", "maximum", "manhattan", "canberra", "binary" or "minkowski".
Value
An object of class dist
, representing the distance matrix of the embedded matrix M
. This distance matrix can optionally be converted to a full matrix format if needed for subsequent analyses.
Examples
# Assume M is an already constructed state space matrix of a time series
M <- matrix(rnorm(100), nrow = 10)
distanceMat <- distanceMatrix(M, "euclidean")
print(distanceMat) # Optionally convert to a full matrix for display
#> 1 2 3 4 5 6 7
#> 1 0.000000 3.654564 4.729537 3.347999 5.264946 5.233028 6.751787
#> 2 3.654564 0.000000 4.125794 3.093635 2.967079 4.475383 6.055989
#> 3 4.729537 4.125794 0.000000 5.478951 5.434183 6.623987 5.471213
#> 4 3.347999 3.093635 5.478951 0.000000 3.551598 4.283127 6.095860
#> 5 5.264946 2.967079 5.434183 3.551598 0.000000 4.512884 5.922342
#> 6 5.233028 4.475383 6.623987 4.283127 4.512884 0.000000 7.206408
#> 7 6.751787 6.055989 5.471213 6.095860 5.922342 7.206408 0.000000
#> 8 3.768413 3.745335 4.882656 4.032156 4.003764 4.278306 6.337805
#> 9 3.651633 2.157596 3.104306 3.695785 3.782606 4.350905 4.737304
#> 10 5.010448 3.832958 5.560822 3.453163 4.880085 5.941095 5.903261
#> 8 9 10
#> 1 3.768413 3.651633 5.010448
#> 2 3.745335 2.157596 3.832958
#> 3 4.882656 3.104306 5.560822
#> 4 4.032156 3.695785 3.453163
#> 5 4.003764 3.782606 4.880085
#> 6 4.278306 4.350905 5.941095
#> 7 6.337805 4.737304 5.903261
#> 8 0.000000 3.343799 4.694651
#> 9 3.343799 0.000000 4.132463
#> 10 4.694651 4.132463 0.000000