This function calculates various square distances measures between distributions, including the, Bhattacharyya distance, Mahalanobis distance, and Euclidean distance.

distance(object,method="Mahalanobis",sqrt=FALSE,level=0.95,debias=TRUE,...)

Arguments

object

A list of ctmm fit objects or single-location telemetry objects to compare.

method

Square distance measure to return: "Bhattacharyya", "Mahalanobis", or "Euclidean".

sqrt

Return the linear distance.

level

The confidence level desired for the output.

debias

Approximate debiasing of the square distance.

...

Not currently used.

Value

A list with tables DOF, containing the effective samples sizes of the estimates, and CI, containing the confidence intervals of the distance estimates. A value of 0 implies that the two distributions have the same mean location, while larger values imply that the two distributions are farther apart. The (square) Euclidean distance has units of square meters, if sqrt=FALSE. The square Mahalanobis and Bhattacharyya distances are unitless. For the Euclidean distance, only the centroids are compared.

Author

C. H. Fleming

Note

The Bhattacharyya distance (BD) is naturally of a squared form and is not further squared.

See also

Examples

# \donttest{
# Load package and data
library(ctmm)
data(buffalo)

# fit models for first two buffalo
GUESS <- lapply(buffalo[1:2], function(b) ctmm.guess(b,interactive=FALSE) )
# using ctmm.fit here for speed, but you should almost always use ctmm.select
FITS <- lapply(1:2, function(i) ctmm.fit(buffalo[[i]],GUESS[[i]]) )
names(FITS) <- names(buffalo[1:2])

# Mahalanobis distance between these two buffalo
distance(FITS)
#> $DOF
#>              Cilla         Gabs
#> Cilla          Inf 0.0003126323
#> Gabs  0.0003126323          Inf
#> 
#> $CI
#> , , low
#> 
#>       Cilla Gabs
#> Cilla     0    0
#> Gabs      0    0
#> 
#> , , est
#> 
#>             Cilla        Gabs
#> Cilla 0.000000000 0.004166238
#> Gabs  0.004166238 0.000000000
#> 
#> , , high
#> 
#>           Cilla      Gabs
#> Cilla 0.0000000 0.6572822
#> Gabs  0.6572822 0.0000000
#> 
#> 
#> attr(,"class")
#> [1] "distance"
# }