data(biofam)
## Building one channel per type of event left, children or married
bf <- as.matrix(biofam[, 10:25])
children <- bf==4 | bf==5 | bf==6
married <- bf == 2 | bf== 3 | bf==6
left <- bf==1 | bf==3 | bf==5 | bf==6
## Building sequence objects
child.seq <- seqdef(children)
marr.seq <- seqdef(married)
left.seq <- seqdef(left)
## Using transition rates to compute substitution costs on each channel
mcdist <- seqdistmc(channels=list(child.seq, marr.seq, left.seq),
method="OM", sm =list("INDELSLOG", "INDELSLOG", "TRATE"))
## Using a weight of 2 for children channel and specifying
## channel specific substitution costs
smatrix <- list()
smatrix[[1]] <- seqsubm(child.seq, method="CONSTANT")
smatrix[[2]] <- seqsubm(marr.seq, method="CONSTANT")
smatrix[[3]] <- seqsubm(left.seq, method="TRATE")
mcdist2 <- seqdistmc(channels=list(child.seq, marr.seq, left.seq),
method="OM", sm =smatrix, cweight=c(2,1,1))
## Retrieving the multichannel sequences
mcseq <- seqdistmc(channels=list(child.seq, marr.seq, left.seq),
method="OM", sm =smatrix, cweight=c(2,1,1), what="seqmc", ch.sep="+")
alphabet(mcseq)
## Retrieving the AT-multichannel substitution costs
mcsm <- seqdistmc(channels=list(child.seq, marr.seq, left.seq),
method="OM", sm=smatrix, cweight=c(2,1,1), what="cost", ch.sep="+")
Run the code above in your browser using DataLab