Calculates the distance matrix of observations with circular variables using an adapted version of Gower's distance. This distance should be compatible with the Gower's distance for other variable types.

circ_dist(frame)

Arguments

frame

A data frame with all columns are circular measured in degrees.

Value

Object of class "dist".

Details

The distance between two observations i and j of a circular variable q is suggested to be

$$(y_{iq}, y_{jq}) = \frac{180 - |180 - |y_{iq} - y_{jq}||}{180}.$$

References

  • Tran, T. V. (2019). Chapter 3. Monothetic Cluster Analysis with Extensions to Circular and Functional Data. Montana State University - Bozeman.

See also

Examples

# Make a sample data set of 20 observations with 2 circular variables data <- data.frame(var1 = sample.int(359, 20), var2 = sample.int(359, 20)) circ_dist(data)
#> 1 2 3 4 5 6 7 #> 2 0.53888889 #> 3 0.31666667 0.48888889 #> 4 0.55000000 0.91111111 0.60000000 #> 5 0.09166667 0.44722222 0.23611111 0.64166667 #> 6 0.40555556 0.71111111 0.22222222 0.37777778 0.32500000 #> 7 0.65000000 0.79444444 0.65555556 0.21111111 0.74166667 0.47777778 #> 8 0.86944444 0.54722222 0.55277778 0.36388889 0.78888889 0.46388889 0.26388889 #> 9 0.88055556 0.34166667 0.59722222 0.56944444 0.78888889 0.50833333 0.46944444 #> 10 0.59166667 0.61944444 0.48055556 0.38611111 0.68333333 0.58055556 0.17500000 #> 11 0.49166667 0.31388889 0.29722222 0.69166667 0.41111111 0.51944444 0.48055556 #> 12 0.40000000 0.80555556 0.45000000 0.18888889 0.49166667 0.22777778 0.40000000 #> 13 0.54166667 0.36388889 0.35833333 0.64166667 0.46111111 0.58055556 0.43055556 #> 14 0.46388889 0.28611111 0.42500000 0.70833333 0.37222222 0.48611111 0.88611111 #> 15 0.73888889 0.29444444 0.56666667 0.70000000 0.64722222 0.47777778 0.61111111 #> 16 0.31666667 0.49444444 0.63333333 0.50000000 0.39722222 0.53333333 0.71111111 #> 17 0.24166667 0.31388889 0.45277778 0.68055556 0.21666667 0.54166667 0.89166667 #> 18 0.42500000 0.51944444 0.52500000 0.48611111 0.51666667 0.70833333 0.27500000 #> 19 0.31944444 0.21944444 0.26944444 0.86944444 0.22777778 0.49166667 0.88611111 #> 20 0.28888889 0.25000000 0.23888889 0.83888889 0.19722222 0.46111111 0.81666667 #> 8 9 10 11 12 13 14 #> 2 #> 3 #> 4 #> 5 #> 6 #> 7 #> 8 #> 9 0.20555556 #> 10 0.32222222 0.52777778 #> 11 0.37777778 0.46666667 0.30555556 #> 12 0.49722222 0.54166667 0.57500000 0.74722222 #> 13 0.32777778 0.52777778 0.25555556 0.06111111 0.80833333 #> 14 0.62222222 0.41666667 0.90555556 0.60000000 0.51944444 0.65000000 #> 15 0.34722222 0.14166667 0.66944444 0.60833333 0.51111111 0.65833333 0.27500000 #> 16 0.79166667 0.58611111 0.88611111 0.80833333 0.31111111 0.85833333 0.20833333 #> 17 0.84444444 0.63888889 0.83333333 0.62777778 0.49166667 0.67777778 0.22222222 #> 18 0.48888889 0.69444444 0.16666667 0.22777778 0.67500000 0.16666667 0.80555556 #> 19 0.76666667 0.56111111 0.71111111 0.40555556 0.71388889 0.45555556 0.19444444 #> 20 0.71388889 0.59166667 0.64166667 0.33611111 0.68888889 0.38611111 0.26388889 #> 15 16 17 18 19 #> 2 #> 3 #> 4 #> 5 #> 6 #> 7 #> 8 #> 9 #> 10 #> 11 #> 12 #> 13 #> 14 #> 15 #> 16 0.44444444 #> 17 0.49722222 0.18055556 #> 18 0.81388889 0.71944444 0.66666667 #> 19 0.41944444 0.40277778 0.22222222 0.61111111 #> 20 0.45000000 0.47222222 0.29166667 0.54166667 0.06944444