treating overlapping states TraMineR

117 Views Asked by At

I'm using TraMineR and I'm trying to import a dataset and convert it from a SPELL format to STS format.

That's an example of my dataset (for the sake of simplicity I used numeric values instead of dates).

Alphabet=[a,b]

days=[1,2,3,4,5....]

id | start | end | values |
1  |   1   |  5  |   a    |
1  |   6   |  12 |   a    |
1  |  10   |  15 |   b    |
2  |   2   |  8  |   b    |
2  |   7   |  10 |   a    |

Defining the sequences in STS format, I'll have the following

id day1 day2 .........day9 day10 day11 day12 day13 day14.......
 1  a    a   ......... a     a     a     a     b     b  .......
 2  ........and so on

The problem is that if I have concomintant states, the last starts when the first ends as happened in my example between the second to third state for id 1.

How can I split states?

I.e. when the state a finishes then b starts from the beginning, just if overlapping is less then n days.

Or maybe can I define another states when a and b overlap for more than n days.

I.e.

id day1 day2 .........day9 day10 day11 day12 day13 day14.......
 1  a    a   ......... a     ab     ab    ab     b     b  ....... 
0

There are 0 best solutions below