Learn R Programming

fda.usc (version 1.2.3)

kmeans.fd: K-Means Clustering for functional data

Description

Perform k-means clustering on functional data.

Usage

kmeans.fd(fdataobj,ncl=2,metric=metric.lp,dfunc=func.trim.FM,
max.iter=100,par.metric=NULL,par.dfunc=list(trim=0.05),
par.ini=list(method="sample"),draw=TRUE,...)
kmeans.center.ini(fdataobj,ncl=2,metric=metric.lp,
draw=TRUE,method="sample",iter=100,par.metric=NULL,...)

Arguments

fdataobj
fdata class object.
ncl
See details section.
metric
Metric function, by default metric.lp.
dfunc
Type of depth measure, by default FM depth.
max.iter
Maximum number of iterations for the detection of centers.
draw
=TRUE, draw the curves in the color of the centers.
par.dfunc
List of arguments to pass to the dfunc function .
par.ini
List of arguments to pass to the kmeans.center.ini function .
method
Method for selecting initial centers. If method="Sample" (by default) takes n times a random selection by the ncl centers. The ncl curves with greater distance are the initial centers. If
iter
Maximum number of random samples for the initial selection of centers.
par.metric
List of arguments to pass to the metric function.
...
Further arguments passed to or from other methods.

Value

  • Return:
  • clusterIndexes of groups assigned.
  • centersCurves centers.

Details

The method searches the locations around which are grouped data (for a predetermined number of groups). If ncl=NULL, randomizes the initial centers, ncl=2 using kmeans.center.ini function. If ncl is an integer, indicating the number of groups to classify, are selected ncl initial centers using kmeans.center.ini function. If ncl is a vector of integers, indicating the position of the initial centers with length(ncl) equal to number of groups. If ncl is a fdata class objecct, ncl are the initial centers curves with nrow(ncl) number of groups.

References

Hartigan, J. A. and Wong, M. A. (1979). A K{-}means clustering algorithm. Applied Statistics 28, 100 -108.

See Also

See Also generic kmeans function.

Examples

Run this code
data(phoneme)
mlearn<-phoneme$learn[c(1:50,101:150,201:250),]

#Unsupervised classification
out.fd1=kmeans.fd(mlearn,ncl=3,draw=TRUE)
out.fd2=kmeans.fd(mlearn,ncl=3,draw=TRUE,par.ini=list(method="exact"))
# Different Depth function
ind=c(17,77,126)
out.fd3=kmeans.fd(mlearn,ncl=mlearn[ind,],draw=FALSE,
dfunc=func.trim.FM,par.dfunc=list(trim=0.1))
out.fd4=kmeans.fd(mlearn,ncl=mlearn[ind,],draw=FALSE,
dfunc=func.med.FM)
out.fd5=kmeans.fd(mlearn,ncl=3,dfunc=func.trim.RPD,
max.iter=10,par.dfunc=list(dfunc="depth.FM",deriv=c(0,1,1)))
group=c(rep(1,50),rep(2,50),rep(3,50))
table(out.fd5$cluster,group)

Run the code above in your browser using DataLab