I am trying to show how individuals move between a set of conditions or states over time. I think a sequence index plot should be able to visualize that.
HTML Code:
https://www.stata-journal.com/sjpdf.html?articlenum=gr0022
Code:
. separate begin, by(type) . separate end, by(type)
Code:
graph twoway > (rbar begin1 end1 id, horizontal) > (rbar begin2 end2 id, horizontal) > (rbar begin3 end3 id, horizontal) > (rbar begin4 end4 id, horizontal) > (rbar begin5 end5 id, horizontal) > , legend(order(1 "education" 2 "apprenticeship" > 3 "employment" 4 "unemployment" 5 "inactivity") > cols(1) pos(2) symxsize(5)) > xtitle("months") yla(, angle(h)) yscale(reverse)
My data set
HorseID | Time | PredictedLF |
1 | 15:06:57 | 1 |
1 | 15:06:58 | 1 |
1 | 15:06:59 | 5 |
1 | 15:07:00 | 5 |
1 | 15:07:01 | 2 |
1 | 15:07:02 | 4 |
1 | 15:07:03 | 4 |
2 | 09:38:10 | 4 |
2 | 09:38:11 | 2 |
2 | 09:38:12 | 3 |
2 | 09:38:13 | 3 |
2 | 09:38:14 | 4 |
2 | 09:38:15 | 4 |
2 | 09:38:16 | 4 |
2 | 09:38:17 | 2 |
2 | 09:38:18 | 4 |
2 | 09:38:19 | 6 |
2 | 09:38:20 | 6 |
2 | 09:38:21 | 6 |
Code:
separate Time, by ( PredictedLF)
I then used this to get start and end times for each classified behaviour.
For example:
Code:
gen LFendLyingLF=1 if Time1~=. &(Time1 [_n+1] ==.)
Code:
graph twoway (rbar LFStartLyingLF LFendLyingLF HorseID, horizontal)(rbar LFStartStep LFendStep HorseID, horizontal)(rbar LFStartPaw LFendPaw HorseID, horizontal)(rbar LFStartStand LFendStand HorseID, horizontal)(rbar LFStartWS LFendWS HorseID, horizontal)(rbar LFStartLyingR LFendLyingR HorseID, horizontal),legend (order(1 "Lying Left" 2 "Step" 3 "Pawing ground" 4 "Standing" 5 "Weight shift" 6 "Lying Right") cols(1) pos(2) symxsize(6))
Katrina
0 Response to Sequence Index Plot
Post a Comment