dist2centers: Calculates curve distances to the centers.

Description Usage Arguments Details Value Author(s) References Examples

Description

Distance to all cluster centers is calculated for each curve. Dataset can be in general format "Format1" or matrix format "Format2" (see formatFuncy).

Usage

1
dist2centers(data, centers)

Arguments

data

Dataset in "Format1" or "Format2".

centers

Matrix with cluster center curves in columns.

Details

Calculates the sum of the squared distances between the curves and the cluster centers on the available time points and divides it by the total number of time points for the corresponding curve. If the dataset is in irregular format "Format1", center curves must correspond to evaluations on the unique union of all time points.

Value

Matrix of dimension nr_curves x nr_clusters.

Author(s)

Christina Yassouridis

References

Christina Yassouridis and Dominik Ernst and Friedrich Leisch. Generalization, Combination and Extension of Functional Clustering Algorithms: The R Package funcy. Journal of Statistical Software. 85 (9). 1–25. 2018

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
##Generate dataset
set.seed(2804)
ds <- sampleFuncy(obsNr=100, k=4, timeNrMin=5, timeNrMax=10, reg=FALSE)
data <- Data(ds)
##Get unique union of all time points
time <- sort(unique(data[,3]))
##Generate center curves
c1 <- sin(time)+rnorm(30)
c2 <- cos(time)+rnorm(30)
c3 <- time^2+rnorm(3)
centers <- cbind(c1,c2,c3)
##Calculate distance to the centers
dist2centers(data, centers)

funcy documentation built on May 2, 2019, 9:22 a.m.

Related to dist2centers in funcy...