seqdcenter {TraMineR} | R Documentation |
Compute the distance to a group center according to a matrix of distance. The method use the decomposition of distance used by the ward criteria. In this case, distance to center equal the mean of the two by two distances.
seqdcenter(distmatrix, group=NULL)
distmatrix |
A matrix of distance such as the one computed by seqdist |
group |
If null, only one group is considered, otherwise group to compute center |
A vector with the distance to center of group for each sequence
## Define a sequence object data(biofam) bf.seq <- seqdef(biofam,10:25) couts <- seqsubm(bf.seq, method="TRATE") ## compute distance biofam.om <- seqdist(bf.seq,method="OM",indel=2,sm=couts) #compute distance to center according to gender distcenter <- seqdcenter(biofam.om, biofam$sex) ## ploting distribution of dist to center as a silhouette plot ## Ploting two plots par(mfrow=c(1,2)) barplot(sort(distcenter[biofam$sex=="man"]), main="Man",border=NA,space=0,col="cyan") barplot(sort(distcenter[biofam$sex=="woman"]), main="Woman",border=NA,space=0,col="cyan")