Hi Everybody
I have the following data including three variables with (i) "person" identifying a subject in the study, (ii) "mate" identifying a subject that has spent some time in the same room as the "person" and (iii) the time the pair of "person" and "mate" actually spent in the same room in hours. Please see the example below.
Now I would like to create a variable that puts these observations into corresponding clusters if they spent time together in the same room. For example, for person 1, they would get the same cluster ID as person 49, but not as 75, since they spent time in the same room, but had no overlap. Person 2 would get the same cluster ID as 77 and 85, but not 91, and so forth. Can you help me?
Thanks a lot!
I have the following data including three variables with (i) "person" identifying a subject in the study, (ii) "mate" identifying a subject that has spent some time in the same room as the "person" and (iii) the time the pair of "person" and "mate" actually spent in the same room in hours. Please see the example below.
Now I would like to create a variable that puts these observations into corresponding clusters if they spent time together in the same room. For example, for person 1, they would get the same cluster ID as person 49, but not as 75, since they spent time in the same room, but had no overlap. Person 2 would get the same cluster ID as 77 and 85, but not 91, and so forth. Can you help me?
Thanks a lot!
Code:
* Example generated by -dataex-. For more info, type help dataex clear input int(person mate) double overlap_duration 1 49 13.207777777777778 1 75 0 2 77 3.112777777709961 2 85 14.054722222154405 2 91 0 3 34 0 3 108 13.466666666734483 4 90 0 5 57 0 5 70 15.940277777845594 5 105 0 6 36 0 6 15 0 7 . . 8 93 0 8 19 10.896944444512261 9 . . 10 31 0 10 87 0 10 134 0 10 23 0 10 98 0 11 27 2.435 11 13 2.3219444443766277 12 17 0 13 27 0 13 11 2.3219444443766277 14 24 13.554444444512262 14 44 12.386666666666667 15 6 0 15 36 0 16 35 0 16 103 16.77027777777778 17 12 0 18 89 0 19 8 10.896944444512261 19 93 0 20 52 0 20 96 17.812777777845593 20 65 0 21 78 23.52833333326552 21 133 0 22 47 0 22 42 23.80388888888889 23 31 0 23 87 12.374166666666667 23 98 0 23 10 0 23 134 0 24 44 0 24 14 13.554444444512262 25 83 2.137777777777778 25 29 16.116666666666667 26 64 0 27 13 0 27 11 2.435 28 104 0 28 117 0 28 129 12.519722222222223 28 99 0 29 25 16.116666666666667 29 83 0 30 80 0 30 122 0 30 54 18.00861111117893 31 10 0 31 23 0 31 134 0 31 87 5.771111111043294 31 98 0 32 81 0 32 106 27.5575 33 . . 34 3 0 34 108 0 35 103 0 35 16 0 36 15 0 36 6 0 37 112 11.449444444444444 38 101 0 38 71 10.95111111111111 39 51 0 40 50 18.378333333265516 40 132 0 40 124 0 41 . . 42 47 0 42 22 23.80388888888889 43 73 0 44 14 12.386666666666667 44 24 0 45 60 0 45 56 0 46 116 0 46 82 0 47 22 0 47 42 0 48 . . 49 1 13.207777777777778 end
Comment