I am doing sequence analysis using Traminer and I have employment sequences from age 51 to age 75. However, because some participants enter the survey after age 51, some of the sequences start later (left missing values). I also have some right missing, and some internal missing gaps. I would like to treat internal missing gaps as an additional state, and left and right gaps as voids. However, if I set the option "DEL" for left missing values, the sequences get shifted to the left and the voids appear to the right. Do you have any advice on how to treat left missing gaps so that they are set as void without shifting the sequences? I am afraid shifting sequences would distort timing too much when using the indel costs.

Here is my code:

States_Wide.seq <- seqdef(
                   States_Wide, # Select data   
                   var = 2:26,                    # Columns containing the sequences
                   alphabet = state_alphabet,
                   start=51, left="DEL", right="DEL", gaps="6", missing=NA, void="%",
                   xtstep = 4)
  • 2
    $\begingroup$ These values are termed "censored." ("Missing" is a term reserved for when no information about an observation is available.) It's unclear what you mean by "treating...as voids" or "indel costs." $\endgroup$
    – whuber
    Commented Apr 9 at 20:18
  • $\begingroup$ I am using the term "missing" as this is how these gaps are defined in the Traminer user guide. $\endgroup$
    – Lucia
    Commented Apr 9 at 22:41
  • $\begingroup$ By "treating as void" I mean deleting the missing (or censored, if that is clearer) states $\endgroup$
    – Lucia
    Commented Apr 9 at 22:44
  • $\begingroup$ Indel costs are insertion/deletion costs, used to compare sequences in sequence analysis. People who have done sequence analysis or used Traminer before will be familiar with this term. $\endgroup$
    – Lucia
    Commented Apr 9 at 22:45
  • $\begingroup$ Thank you. But people who will be experienced with censored data and possibly better positioned to help you might not be familiar with that term, which is why it's best to explain any argot you need to use. $\endgroup$
    – whuber
    Commented Apr 10 at 15:11

1 Answer 1


You are right, TraMineR:::seqdef fills the positions of voids by shifting the subsequent elements to the left. To keep the positions of all the elements, you must assign a state (missing or any thing else) to each uninformed position. For instance, you can assign a state "L" to all left missing by passing argument left="L", and a state "G" to all gaps with gaps="G".

I illustrate with the example data ex1.

s <- seqdef(ex1[1:6,1:12], left="L", gaps="G")

##    Sequence               
## s1 L-L-L-A-A-A-A-A-A-A-A-A
## s2 D-D-D-B-B-B-B-B-B-B    
## s3 L-D-D-D-D-D-D-D-D-D-D  
## s4 A-A-G-G-B-B-B-B-D-D    
## s5 A-G-A-A-A-A-G-A-A-A    
## s6 L-L-L-C-C-C-C-C-C-C

Doing so, plots will distinguish between left and gap missings. Likewise, indicators such as entropy or complexity index will treat elements L and G as additional elements of the alphabet. To compute edit distances, you can set specific indel and substitution costs for each of these two states.

The defaults are left=NA and gaps=NA, which assign "*" to left missings and gaps.

  • $\begingroup$ Thank you for your answer! Ok, sounds like the best available option (other than imputing) is to treat left missing values as a separate state (different from gaps). I wonder if it would be possible, in the future, to add an extension to Traminer so that they can be treated as void in the same way it is doing it now for right censored sequences (without sequence shifting). I think that would make more sense qualitatively, since filling voids with insertion costs less than replacing a state with another state. I'd be happy to talk more and help figure it out! Thanks again for your prompt reply. $\endgroup$
    – Lucia
    Commented Apr 10 at 19:14
  • $\begingroup$ I cannot figure out what you want to do. Either you assign something to NAs to preserve the position of subsequent elements or you treat NAs as voids (nothing assigned) and subsequent elements will be shifted to the left. Do you want to shifting to the right? For what kind of analysis does that matter for you? $\endgroup$
    – Gilbert
    Commented Apr 11 at 7:33
  • $\begingroup$ I'd like them to be voids, but not shifted so that the timing of states within sequences does not get distorted as much. The voids could be filled with insertions as it is currently happening when voids are at the end, I would think. I think it is relevant for surveys with different cohorts that enter at different time points, where the missingness is not really informative but just depends on people entering earlier vs. later. $\endgroup$
    – Lucia
    Commented May 9 at 23:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.