1
votes

I am working with TraMineR and I am new to R and TraMineR.

Actually I made a typology of a life course dataset with TraMineR and the cluster library in R. (used this guide: http://traminer.unige.ch/preview-typology.shtml)

Now I have different Cases sorted into different Types (all in all 4 Types).

I want to get into deeper analysis with a certain Type but I need to know which cases ( I have case numbers) belong to which type. # Is it possible to write the certain type a case is sorted to into the dataset itself as a new variable Is there another way?

1

1 Answers

0
votes

In the example of the referenced guide, the Type is obtained as follows using an optimal matching distances with substitution costs based on transition probabilities

library(TraMineR)
data(mvad)
mvad.seq <- seqdef(mvad, 17:86)
dist.om1 <- seqdist(mvad.seq, method = "OM", indel = 1, sm = "TRATE")

library(cluster)
clusterward1 <- agnes(dist.om1, diss = TRUE, method = "ward")
cl1.4 <- cutree(clusterward1, k = 4)

cl.4 is a vector with the cluster membership of the sequences in the order corresponding to the mvad dataset. (It could be convenient to transform it into a factor.) Therefore, you can simply add this variable as an additional column to the dataset. For instance, if we want to name this new column as Type

mvad$Type <- cl1.4
tail(mvad[,c("id","Type")])  ## id and Type of the last 6 sequences

##     id Type
## 707 707    3
## 708 708    3
## 709 709    4
## 710 710    2
## 711 711    1
## 712 712    4