grouping - Find social network components in Stata -


[i copied part of below example separate post , changed suit specific needs]

pos_1    pos_2   2        4   2        5   1        2   3        9   4        2   9        3 

the above read person_2 connected person_4,...,person_4 connected person_2, , person_9 connected person_3.

i want create third categorical [edited] variable, component, lets me know if observed link part of connected component (subnetwork) within network. in case, there 2 connected components in network:

pos_1    pos_2    component   2        4        1   2        5        1   1        2        1   3        9        2   4        2        1   9        3        2 

all nodes in component 1 connected each other, not nodes in component 2 , vice versa. there way generate component variable in stata? know there alternative programs in, code more seamless if can integrate stata.

if reshape data long form, can use group_id (from ssc) want:

clear input pos_1    pos_2   2        4   2        5   1        2   3        9   4        2   9        3 end  gen id = _n reshape long pos_, i(id) j(n)  clonevar comp = id list, sepby(comp)  group_id comp, match(pos)  reshape wide pos_, i(id) j(n)  egen component = group(comp) list 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -