Hello! I have data on individuals and their relationships with other individuals in a network. Each observation is a relationship between an individual and an other one. I would like to build a variable that equals 0 if there is no connection between A and B, 1 if there is exactly one connection between A and B (i.e., if A declared that they share a connection with B but not the other way around), and 2 if the relationship is reciprocal, i.e. both A and B declared that they share a relationship witht their pair. Please note that I have different networks so I would like to build this variable by group. Here is an example:
Let's say I want to create a status_connection variable. I would want it to be 2 for the D1-D2 and the D2-D1 pairs because there is a connection that is shared in the edgelist. However, D3 declared to have a connection with D1 while D1 doesn't have any connection with D3. I would want the variable to be 1 for both those inverted pairs. And if there is no connection between a pair of individuals in both ways, the variable would take a value of 0.
My intuition tells me the code should have something to do with summing the connection variable, yet I can't seem to figure it out. I would appreciate any help!
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str3(source target) byte connection "D1" "D2" 1 "D1" "D3" 0 "D1" "D4" 1 "D2" "D1" 1 "D2" "D3" 1 "D2" "D4" 0 "D3" "D1" 1 "D3" "D2" 1 "D3" "D4" 1 "D4" "D1" 0 end
My intuition tells me the code should have something to do with summing the connection variable, yet I can't seem to figure it out. I would appreciate any help!
Comment