dist_comp {etree} | R Documentation |
Distances
Description
Compute pairwise distances starting from single objects containing the original univariate observations.
Usage
dist_comp(x, lp = 2)
Arguments
x |
Object containing the original univariate observations. Currently available types and the form they need to have to be correctly recognized are the following:
See Details to find out which distance is used in each case. |
lp |
Integer specifying which norm should be used to compute the distances for functional data. |
Details
The distances used in each case are the following:
Logical: Euclidean distance, implemented via
dist()
;Numeric: Euclidean distance, implemented via
dist()
;Nominal: Gower's distance, implemented via
daisy()
;Functions:
L^{p}
-norm, implemented viametric.lp()
with default options;Graphs: Edge Difference distance (Hammond et al., 2013), implemented via
nd.edd()
;Persistence diagrams: Wasserstein distance, implemented via
wasserstein()
with default options;
Value
Object of class "dist"
containing the pairwise distances.
References
D. K. Hammond, Y. Gur, and C. R. Johnson (2013). Graph diffusion distance: A difference measure for weighted graphs based on the graph laplacian exponential kernel. In 2013 IEEE Global Conference on Signal and Information Processing, pages 419-422.
Examples
# Number of observations
nobs <- 10
## Logical
obj <- as.logical(rbinom(nobs, 1, 0.5))
d <- dist_comp(obj)
## Integer
obj <- rpois(nobs, 5)
d <- dist_comp(obj)
## Numeric
obj <- rnorm(nobs)
d <- dist_comp(obj)
## Factors
obj <- factor(letters[1:nobs])
d <- dist_comp(obj)
## Functional data
obj <- fda.usc::rproc2fdata(nobs, seq(0, 1, len = 100), sigma = 1)
d <- dist_comp(obj)
## Graphs
obj <- lapply(1:nobs, function(j) igraph::sample_gnp(100, 0.2))
d <- dist_comp(obj)
## Persistence diagrams
x <- lapply(rep(100, nobs), function(np) TDA::circleUnif(np))
obj <- lapply(x, TDA::ripsDiag, maxdimension = 1, maxscale = 3)
d <- dist_comp(obj)