Last chance! 50% off unlimited learning
Sale ends in
Perform k-means clustering on functional data.
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,...)
fdata
class object.
See details section.
Metric function, by default metric.lp
.
Type of depth measure, by default FM depth.
Maximum number of iterations for the detection of centers.
=TRUE, draw the curves in the color of the centers.
List of arguments to pass to the dfunc
function .
List of arguments to pass to the kmeans.center.ini
function .
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 method
="Exact" calculated all combinations of ncl
centers. The ncl
curves with greater distance are the initial centers (this method may be too slow).
Maximum number of random samples for the initial selection of centers.
List of arguments to pass to the metric
function.
Further arguments passed to or from other methods.
Return:
Indexes of groups assigned.
Curves centers.
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.
Hartigan, J. A. and Wong, M. A. (1979). A K-means clustering algorithm. Applied Statistics 28, 100 \-108.
See Also generic kmeans function.
# NOT RUN {
# }
# NOT RUN {
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