>
>Date: Fri, 13 Feb 2009 16:25:36 -0500
>From: "Victor, Jennifer Nicoll" <[email protected]>
>Subject: st: convert adjacency to edgelist
>
>Hello Stata users,
>
>I have a 438x438 adjacency matrix (symmetrical, non-directed) where
>the cells are the number of connections between each i,j pair (the
>pairs are members of congress and the connections are the number of
>caucuses each pair is in). I have it in Excel format, csv format, and
>Stata format. I also have it in Stata as a dyadic dataset with
>attribute variables (N=95,703). I want to convert either the dyadic
>data or the adjacency matrix to an edgelist that I could import into R
>(igraph) or NodeXL or TouchGraph so that I can make a network graph or
>two, but I need an edgelist to import into those programs.
Can you clarify what you want here with a small example? To go from
an adjacency matrix to what
I would call an edge list is just a -reshape- from wide to long,
which I'm presuming is not what you want.
(i.e, given a Stata data set of the form: (non-proportional font on)
+------------------------------+
| egoid x1 x2 x3 x4 x5 |
|------------------------------|
1. | 1 . 2 2 0 1 |
2. | 2 . . 0 3 3 |
3. | 3 . . . 2 2 |
4. | 4 . . . . 2 |
5. | 5 . . . . . |
+------------------------------+
(where x_i is the number of connnections from egoid to i)
Then
reshape long x, i(ego) j(alter)
drop if missing(x)
would yield what I would call an edge list in Stata.
+-----------------+
| ego alter x |
|-----------------|
1. | 1 2 2 |
2. | 1 3 2 |
3. | 1 4 0 |
4. | 1 5 1 |
5. | 2 3 0 |
|-----------------|
6. | 2 4 3 |
7. | 2 5 3 |
8. | 3 4 2 |
9. | 3 5 2 |
10. | 4 5 2 |
+-----------------+
Regards,
=-=-=-=-=-=-=-=-=-=-=-=-=
Mike Lacy
Fort Collins CO USA
(970) 491-6721 office
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/