# clusterSegments

### Description

The function does hierarchical clustering of the segmented (and joined) series by hclust and performs one of the "intervention" methods (see the respective parameter below) to identify subpopulations. The hierarchical clustering is performed by Euclidean distances using "average" linkage method.

### Usage

1 | ```
clusterSegments(object, intervention = "groups",pv=NULL,graphics=NULL)
``` |

### Arguments

`object` |
An object of class 'SegTrajectories' |

`intervention` |
intervention: Character. One of "groups","heights" or "pvclust". Option pvclust performs simple hierarchical clustering by hclust and then assesses the uncertainty in the clustering by the bootstrap probability values computed via multi-scale bootstrap resampling. Option "groups" asks the user to input the number of subpopulations we wants to identify (interactive). Option "heights" asks the user to interactively set a threshold T (a horizontal line on the tree plot) that defines the number of subpopulations. |

`pv` |
Supplied p-values for intervention=pvclust. See |

`graphics` |
Character vector. Optional parameter defining the colors for plotting (each color indicates a different subpopulation). Must be at least the length of total number of subpopulations defined. |

### Details

The algorithm offers several alternatives for subpopulation estimation that, ultimately, they lead to similar solutions. The user should first visualize the segmented data to get a rough idea of the possible subpopulations (plots generated by the algorithm). Option "pvclust" computes the hierarchical clustering tree with the p-values. The subpopulations are defined interactively by the user (point and click based on the R function `identify()`

; see help(identify)). Alternatively, option "groups" asks the user to input the number of subpopulations or define them interactively in option "height" (point and click at the desired height in the tree). The final plot shows the number of estimated subpopulations.

### Value

An object of class SegSeriesTrajectories.

### Author(s)

Diana H.P. Low, Efthimios Motakis

### References

Shimodaira, H. (2004) Approximately unbiased tests of regions using multistep-multiscale bootstrap resampling, Annals of Statistics, 32, 2616-2641.

### Examples

1 2 3 4 5 6 | ```
## Not run:
## interactive!
data(deltaGseg)
traj1.ss<-clusterSegments(traj1.denoise, intervention = "groups") #define clusters by number of groups formed.
## End(Not run)
``` |