# Optimal matching distances as percentages?

I'm using R and the library TraMineR to do sequence analysis on social science data. I have computed an optimal matching (OM) distance matrix.

      [,1]     [,2]      [,3]      [,4]
[1,]   0.00000 94.80628 110.00000 107.46826
[2,]  94.80628  0.00000  53.71086  78.02520
[3,] 110.00000 53.71086   0.00000  47.88362
[4,] 107.46826 78.02520  47.88362   0.00000


Here is a dput() of the OM matrix:

structure(c(0, 94.8062777425491, 110, 107.468255963965, 94.8062777425491,
0, 53.7108606841158, 78.0251951544836, 110, 53.7108606841158,
0, 47.8836216007405, 107.468255963965, 78.0251951544836, 47.8836216007405,
0), .Dim = c(4L, 4L))


and I computed it using this code:

# Read and transpose data

# Define the sequence object

# Define the substitution matrix

# Calculate the OM matrix


Now I want to express the similarity between two sequences in %. How can I accomplish this?

• It's possible I just don't understand how you generated the above distance matrix, but what do you mean by "the similarity between two sequences in %"? Your distance matrix is a 4x4, doesn't that mean you have four sequences? Aug 28, 2012 at 2:12
• Yes, so I want to be able to measure the similarity in % between any two sequences. There are 12 combinations in total. Aug 28, 2012 at 2:14
• Could you provide an bit of the data? I think it may make it clearer what you are working with. Aug 28, 2012 at 2:22

The seqdist function has a norm argument for specifying one of several normalization options. If your are interested in dissimilarities as percentage of the maximum possible dissimilarity given the alphabet and the sequence lengths, you just pass the argument norm="maxdist" to the function.
twitter.om <- seqdist(twitter.seq, method="OM", indel=1, sm=twitter_costs, with.missing=FALSE, norm="maxdist")
See seqdist help page (by typing ?seqdist) for other possible normalizations.