TraMineR, is it possible to compare two sequence objects to calculate the discrepancy between them? By this I mean not comparing two sequences but two sets of sequences. Is this possible? If so, how do I go about doing it?
This is possible as long as your sequence objects share a same alphabet.
You do it by merging the two sequence objects into a pooled object, and then using
dissassoc with the indicator of the original set as group argument. To illustrate, I first create two separate objects of female and male from the mvad sequence object:
library(TraMineR) data(mvad) levels(mvad[,"male"]) <- c("female","male") mvad.seq <- seqdef(mvad, 17:86) male.seq <- mvad.seq[mvad$male=="male",] female.seq <- mvad.seq[mvad$male=="female",]
and merge the two objects into a single one
pooled.seq <- rbind(male.seq,female.seq)
We create an indicator of the originating set (that should comply with the order of the sequences in
oset.male <- rep(1,nrow(male.seq)) oset.female <- rep(2,nrow(female.seq)) oset <- c(oset.male, oset.female)
Now, we compute pairwise dissimilarities from the pooled object and get the discrepancy analysis by means of
lcs <- seqdist(pooled.seq, method="LCS") dissassoc(lcs, group=oset)