data(biofam) #load illustrative data
## Defining the new state labels
statelab <- c("Parent", "Left", "Married", "Left/Married", "Child",
"Left/Child", "Left/Married/Child", "Divorced")
## Creating the state sequence object,
biofam.seq <- seqdef(biofam[1:100, 10:25], alphabet=0:7, states=statelab)
## Clara clustering
bfclara <- seqclararange(biofam.seq, R = 3, sample.size = 10, kvals = 2:3,
seqdist.args = list(method = "HAM"), parallel=FALSE,
stability=TRUE)
#Show the cluster quality measures.
bfclara
#Plot and normalize the values for easier identification of minimum and maximum values.
plot(bfclara, norm="range")
## Stability values.
plot(bfclara, stat="stabmean")
plot(bfclara, stat="stability")
seqdplot(biofam.seq, group=bfclara$clustering$cluster3)
## Cluster quality indices estimation using boostrap
bCQI <- bootclustrange(bfclara, biofam.seq, seqdist.args = list(method = "HAM"),
R = 3, sample.size = 10, parallel=FALSE)
bCQI
plot(bCQI, norm="zscore")
if (FALSE) {
## Fuzzy clustering
bfclaraf <- seqclararange(biofam.seq, R = 3, sample.size = 20, kvals = 2:3,
method="fuzzy", seqdist.args = list(method = "HAM"),
parallel=FALSE)
bfclaraf
plot(bfclaraf, norm="zscore")
fuzzyseqplot(biofam.seq, group=bfclaraf$clustering$cluster3, type="I",
sortv="membership", membership.threashold=0.2)
## Noise clustering
bfclaran <- seqclararange(biofam.seq, R = 3, sample.size = 20, kvals = 2:3,
method="noise", seqdist.args = list(method = "HAM"), dnoise=6,
parallel=FALSE)
fuzzyseqplot(biofam.seq, group=bfclaran$clustering$cluster3, type="I",
sortv="membership", membership.threashold=0.2)
}
Run the code above in your browser using DataLab