data(biofam)
## Building one channel per type of event left home, married, and child
cases <- 200
bf <- as.matrix(biofam[1:cases, 10:25])
left <- bf==1 | bf==3 | bf==5 | bf==6
married <- bf == 2 | bf== 3 | bf==6
children <- bf==4 | bf==5 | bf==6
## Building sequence objects
left.seq <- seqdef(left)
marr.seq <- seqdef(married)
child.seq <- seqdef(children)
channels <- list(LeftHome=left.seq, Marr=marr.seq, Child=child.seq)
## CAT multidomain distances based on channel specific cost methods
MDdist <- seqMD(channels, method="OM",
sm =list("INDELSLOG", "INDELSLOG", "TRATE"), what="diss")
## Providing channel specific substitution costs
smatrix <- list()
smatrix[[1]] <- seqsubm(left.seq, method="TRATE")
smatrix[[2]] <- seqsubm(marr.seq, method="CONSTANT")
smatrix[[3]] <- seqsubm(child.seq, method="CONSTANT")
## Retrieving the MD sequences
MDseq <- seqMD(channels)
alphabet(MDseq)
## Retrieving the CAT multidomain substitution costs
## Using double weight for domain "child"
CATcost <- seqMD(channels,
sm=smatrix, cweight=c(1,1,2), what="cost")
## OMspell distances between MD sequences
MDdist2 <- seqdist(MDseq, method="OMspell",
sm = CATcost, indel=attr(CATcost,"indel"))
Run the code above in your browser using DataLab