[Traminer-users] Different Substitution Costs

Gilbert Ritschard Gilbert.Ritschard at unige.ch
Fri Jul 1 12:54:35 CEST 2011

On 01-Jul-11 9:49, Marcel Eschenfelder wrote:
> Dear all,
> I am wondering, how I can change substitution costs (for optimal 
> matching analysis) between different states in the sequences. I got a 
> data set consisting of four different states, where the transition 
> between some is nearer than between others.
> Is there a possibility to change the substitution costs between two 
> states (and how can I do this)? For example: transition from "A" to 
> "B" = 1; transition from "A" to "C" = 2.

You can define your own substitution cost matrix and pass it to seqdist 
with the 'sm=' argument.

For example,  assuming your state sequence object is my.seq and the 
alphabet is of size 3, you would create a custom substitution cost 
matrix (should be symmetrical) as follows:

myscm <- matrix(c(0,1,2,  1,0,2, 2,2,0), nrow=3, ncol=3)
dist.om <- seqdist(my.seq, method="OM", sm=myscm)

Alternatively, you can create a substitution cost matrix using the 
"CONSTANT" or "TRATE" method and then customize any element you want 
before passing it to seqdist; e.g.:

scm <- seqsubm(my.seq, method="CONSTANT", cval=2)
scm[1,2] <- scm[2,1] <- 1
dist.om <- seqdist(my.seq, method="OM", sm=scm)

Good luck.

> Thanks in advance and kind regards
> Marcel
> _______________________________________________
> Traminer-users mailing list
> Traminer-users at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/traminer-users 

More information about the Traminer-users mailing list