Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Identify reciprocated ties in directed network with -netsis-


From   Nick Cox <njcoxstata@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: Identify reciprocated ties in directed network with -netsis-
Date   Sat, 15 Jun 2013 11:16:26 +0100

I have not used -netsis- (from SJ 12-1; please explain _where_
user-written programs you refer to come from) but this appears to
yield easily to a simple trick.

gen first = cond(source < target, source, target)
gen second = cond(source < target, target, source)
bysort month first second : gen recip = mod(_N, 2)  == 0

Inequalities apply to strings as well as numbers, e.g.

. di  ("James" < "Keira")
1

so sorting reduces pairs to comparable form ("James" "Keira"   and
"Keira" "James" both are sorted to "James" "Keira"   and 7  42 and 42
7 are both sorted to 7 42).

See

SJ-8-4  dm0043  . Tip 71: The problem of split identity, or how to group dyads
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
        Q4/08   SJ 8(4):588--591                                 (no commands)
        tip on how to handle dyadic identifiers

http://www.stata-journal.com/sjpdf.html?articlenum=dm0043

for more.

Nick
njcoxstata@gmail.com


On 15 June 2013 10:15, Claudio Tagliapietra
<claudio.tagliapietra@unibo.it> wrote:
> I am using -netsis- in Stata 12.1 SE in Windows 7, to analyze a directed network. The data is stored as an arc list, as follows
>
> Example 1. Input.
>
> month   source   target
> ------------------------------
> 1           Andrew  Peter
> 1           Peter     Andrew
> 1           James   Peter
> 2           Peter     James
> 2           Andrew  Peter
> 2           James    Peter
>
> "source" and "target" are stored as integer ids.
>
> I want to create a dummy "recipr" that indicates which ties (arcs) are reciprocated in each month. The output should be:
>
> Example 2. Output.
>
> month   source   target    recipr
> -----------------------------------------
> 1           Andrew  Peter      1
> 1           Peter     Andrew   1
> 1           James   Peter       0
> 2           Peter     James     1
> 2           Andrew  Peter       0
> 2           James    Peter      1
>
> Is this currently possible with -netsis-?
> Alternatives?
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index