R/RobustTrimmedClustering.R

Defines functions RobustTrimmedClustering

Documented in RobustTrimmedClustering

RobustTrimmedClustering=function(Data,ClusterNo,Alpha=0.05,PlotIt=FALSE,...){
  # Cls=RobustTrimmedClustering(Data,ClusterNo)
  #
  # INPUT
  # Data[1:n,1:d]     Data set with n observations and d features
  # ClusterNo         Number of clusters to search for
  # Alpha             No trimming is done equals to alpha =0, otherwise proportion of datapoints to be trimmed.
  # 
  # OPTIONAL
  # PlotIt            Boolean. Decision to plot or not.
  #
  # OUTPUT
  # Cls[1:n]          Clustering of data
  # Object            Object of tclust::tclust
  #
  # Author: MT 09/2019  
  
  if (!requireNamespace('tclust',quietly = TRUE)) {
    message(
      'Subordinate clustering package (tclust) is missing. No computations are performed.
            Please install the package which is defined in "Suggests".'
    )
    return(
      list(
        Cls = rep(1, nrow(Data)),
        Object = "Subordinate clustering package (tclust) is missing.
                Please install the package which is defined in 'Suggests'."
      )
    )
  }
  
  res=tclust::tclust(x=Data,k = ClusterNo,alpha = Alpha,...)
  Cls=res$cluster	
  
  if(PlotIt){
    ClusterPlotMDS(Data,Cls)
  }
  Cls=ClusterRename(Cls,Data)
  return(list(Cls=Cls,Object=res))
}

Try the FCPS package in your browser

Any scripts or data that you put into this service are public.

FCPS documentation built on Oct. 19, 2023, 5:06 p.m.