[Traminer-users] ID variable in TSE Data

Lucas Rich rlucas11 at yahoo.com
Thu Dec 12 22:37:14 CET 2013

I am trying to get an id variable into TSE data so I can match event data with other data that is indexed with this ID variable. I kept running into problems doing this, and after trying a number of things, I found that whether this works depends on the name that I use for this ID variable, which seems strange. So the following code works and correctly pulls the ID variable into the TSE data.

id <- c(10,20,30,40)
t1 <- c(1,1,1,1)
t2 <- c(1,2,NA,1)
t3 <- c(1,NA,2,1)
t4 <- c(2,2,2,2)
t5 <- c(1,1,2,2)
data <- data.frame(id,t1,t2,t3,t4,t5)

data.seq <- seqdef(data, 2:6, labels = c("NotDisabled","Disabled"),id=data$id)
transition2 <- seqetm(data.seq, method="transition")
data.tse <- seqformat(data, 2:6, from="STS", to = "TSE", tevent=transition2, id=data$id)

However, if I change the name of the ID variable, then I get the following error:

Error in `[.data.frame`(x, r, vars, drop = drop) : 
  undefined columns selected

For instance, if I just change the name and run the code again with the new variable name, then I get the error (only for the seqformat command, the seqdef command works fine):

names(data)[1] <- "pid"
data.seq <- seqdef(data, 2:6, labels = c("NotDisabled","Disabled"),id=data$pid)
data.tse <- seqformat(data, 2:6, from="STS", to = "TSE", tevent=transition2, id=data$pid)

Am I missing some reason why the former name works but not the latter?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/traminer-users/attachments/20131212/a64dc637/attachment.html>

More information about the Traminer-users mailing list