Learn R Programming

TraMineR (version 1.0)

seqdcenter: Compute distance to center of a group

Description

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.

Usage

seqdcenter(distmatrix, group=NULL)

Arguments

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

Value

  • A vector with the distance to center of group for each sequence

Examples

Run this code
## 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")

Run the code above in your browser using DataLab