# Modifying the time granularity of a state sequence

I created a sequence object from my SPELL-formatted data set. The sequence length of the sequence object is 1440 (i.e., 1-min intervals for a day).

Is there any easy way for TraMineR to convert the sequence length from 1440 to 288 (i.e., 5-min intervals), using the status in the first minute of every time interval to represent an individual's status during that 5-min period?

• The title of the question may be confusing. What about changing it to something like: Modifying the time granularity of a state sequence. Commented Nov 15, 2012 at 10:54

You can simply select the corresponding columns. In your case, this should be columns 1, 6, 11, ... You can get the column indices using the "seq" function:

column.5min <- seq(from = 1, to = 1440, by=5)


Now you can select the column, for instance using:

myseq5min <- myseq[, column.5min]


Here is an example using the "mvad" data set and selecting the first state of each year.

 ## Loading the library
library(TraMineR)
## Defining sequence properties
mvad.alphabet <- c("employment", "FE", "HE", "joblessness", "school", "training")
mvad.lab <- c("employment", "further education", "higher education", "joblessness", "school", "training")
mvad.shortlab <- c("EM", "FE", "HE", "JL", "SC", "TR")
## The state sequence object.
## Now select the column every year (every twelve monthes)

An alternative solution is to use the seqgranularity function provided by the TraMineRextras package. This function changes the time granularity using different methods, currently either "first" state or "last" state, but other methods such as choosing the most frequent state in the aggregated spell should be implemented in the future.
mvadg.seq.year <- seqgranularity(mvad.seq, tspan=12, method = "first")

TraMineRextras should be made available on the CRAN in the near future. In the meantime, if you have the latest version of R, you can just install it from R-Forge with
install.packages("TraMineRextras", repos="http://R-Forge.R-project.org")