| kma {briKmeans} | R Documentation | 
Clustering and alignment of functional data
Description
kma jointly performs clustering and alignment of a functional dataset (multidimensional or unidimensional functions).
Usage
kma(x, y0 = NULL, y1 = NULL, n.clust = 1, warping.method = "affine",
similarity.method = "d1.pearson", center.method = "k-means", seeds = NULL,
optim.method = "L-BFGS-B", span = 0.15, t.max = 0.1, m.max = 0.1, n.out = NULL,
tol = 0.01, fence = TRUE, iter.max = 100, show.iter = 0, nstart=2, return.all=FALSE,
check.total.similarity=FALSE)
Arguments
x | 
 matrix n.func X grid.size or vector grid.size: 
the abscissa values where each function is evaluated. n.func: number of functions in the dataset. grid.size: maximal number of abscissa values where each function is evaluated. The abscissa points may be unevenly spaced and they may differ from function to function.   | 
y0 | 
 matrix n.func X grid.size or array n.func X grid.size X d: evaluations of the set of original functions on the abscissa grid   | 
y1 | 
 matrix n.func X grid.size or array n.func X grid.size X d: evaluations of the set of original functions first derivatives on the abscissa grid   | 
n.clust | 
 scalar: required number of clusters. Default value is   | 
warping.method | 
 character: type of alignment required. If   | 
similarity.method | 
 character: required similarity measure. Possible choices are:   | 
center.method | 
 character: type of clustering method to be used. Possible choices are:   | 
seeds | 
 vector max(n.clust) or matrix nstart X n.clust: indexes of the functions to be used as initial centers. If it is a matrix, each row contains the indexes of the initial centers of one of the   | 
.
optim.method | 
 character: optimization method chosen to find the best warping functions at each iteration. Possible choices are:   | 
span | 
 scalar: the span to be used for the loess procedure in the center estimation step when   | 
t.max | 
 scalar:   | 
m.max | 
 scalar:   | 
n.out | 
 scalar: the desired length of the abscissa for computation of the similarity indexes and the centers. Default value is   | 
tol | 
 scalar: the algorithm stops when the increment of similarity of each function with respect to the corrispondent center is lower than   | 
fence | 
 boolean: if   | 
iter.max | 
 scalar: maximum number of iterations in the k-mean alignment cycle. Default value is   | 
show.iter | 
 boolean: if   | 
nstart | 
 scalar: number of initializations with different seeds. Default value is   | 
return.all | 
 boolean: if   | 
check.total.similarity | 
 boolean: if   | 
Value
The function output is a list containing the following elements:
iterations | 
 scalar: total number of iterations performed by kma function.  | 
x | 
 as input.  | 
y0 | 
 as input.  | 
y1 | 
 as input.  | 
n.clust | 
 as input.  | 
warping.method | 
 as input.  | 
similarity.method | 
 as input.  | 
center.method | 
 as input.  | 
x.center.orig | 
 vector n.out: abscissa of the original center.  | 
y0.center.orig | 
 matrix 1 X n.out: the unique row contains the evaluations of the original function center. If   | 
y1.center.orig | 
 matrix 1 X n.out: the unique row contains the evaluations of the original function first derivatives center. If   | 
similarity.orig | 
 vector: original similarities between the original functions and the original center.  | 
x.final | 
 matrix n.func X grid.size: aligned abscissas.  | 
n.clust.final | 
 scalar: final number of clusters. Note that, when   | 
x.centers.final | 
 vector n.out: abscissas of the final function centers and/or of the final function first derivatives centers.  | 
y0.centers.final | 
 matrix n.clust.final X n.out: rows contain the evaluations of the final functions centers.   | 
y1.centers.final | 
 matrix n.clust.final X n.out: rows contains the evaluations of the final derivatives centers.   | 
labels | 
 vector: cluster assignments.  | 
similarity.final | 
 vector: similarities between each function and the center of the cluster the function is assigned to.  | 
dilation.list | 
 list: dilations obtained at each iteration of kma function.  | 
shift.list | 
 list: shifts obtained at each iteration of kma function.  | 
dilation | 
 vector: dilation applied to the original abscissas   | 
shift | 
 vector: shift applied to the original abscissas   | 
Author(s)
Alice Parodi, Mirco Patriarca, Laura Sangalli, Piercesare Secchi, Simone Vantini, Valeria Vitelli.
References
Sangalli, L.M., Secchi, P., Vantini, S., Vitelli, V., 2010. "K-mean alignment for curve clustering". Computational Statistics and Data Analysis, 54, 1219-1233.
Sangalli, L.M., Secchi, P., Vantini, S., 2014. "Analysis of AneuRisk65 data: K-mean Alignment". Electronic Journal of Statistics, Special Section on "Statistics of Time Warpings and Phase Variations", Vol. 8, No. 2, 1891-1904.
See Also
Examples
    ## simulated data
    set.seed(1)
    x.coord = seq(0,1,0.01)
    x <- matrix(ncol = length(x.coord), nrow = 100)
    labels <- matrix(ncol = 100, nrow = 1)
  
    centers <-  matrix(ncol = length(x.coord), nrow = 4)
    centers[1, ] <- abs(x.coord)-0.5
    centers[2, ] <- (abs(x.coord-0.5))^2 - 0.8
    centers[3, ] <- -(abs(x.coord-0.5))^2 + 0.7
    centers[4, ] <- 0.75*sin(8*pi*abs(x.coord))
  
    for(i in 1:4){
        for(j in 1:25){
            labels[25*(i-1) + j] <- i  
            if(i == 1){x[25*(i-1) + j, ] <- abs(x.coord)-0.5 + 
                rnorm(length(x.coord),0,0.1)}
            if(i == 2){x[25*(i-1) + j, ] <- (abs(x.coord-0.5))^2 - 0.8 + 
                rnorm(length(x.coord),0,0.1)}
            if(i == 3){x[25*(i-1) + j, ] <- -(abs(x.coord-0.5))^2 + 0.7 + 
                rnorm(length(x.coord),0,0.1)}
            if(i == 4){x[25*(i-1) + j, ] <- 0.75*sin(8*pi*abs(x.coord)) + 
                rnorm(length(x.coord),0,0.1)}
            }
        }
    C <- kma(x.coord, x, n.clust = 4, 
            warping.method = "NOalignment", similarity.method = "d0.pearson")
    table(C$labels, labels)