Holly,

I don't know of a clever way to do this, but I can think of a brute force
way, which might only be feasible if you have a small data set (as in your
example).  You could permute every possible set of connections, then choose
from that collection only the ones that meet your criteria.

Using your example, there are c=21 possible connections among the n=7
unique individuals, c = n*(n-1)/2.  Your example shows a total of 8
connections (16 rows / 2).  So you could generate all permutations of
choose(21, 8) = 203,490 ways to have 8 connections.  Then subset the ones
that have individual totals the same as your example (1 connection for
Alicia and Beth, 2 for Kerry and Kim, 3 for James and John, and 4 for
Rachel).

Jean


On Tue, Sep 3, 2013 at 1:01 PM, hollymaya <hollym...@gmail.com> wrote:

>
> I have a dataset of dyads (an edgelist) representing friendship
> nominations between egos and their nominated alters. The network is
> undirected so if ego is connected to alter, then there is a separate
> observation in the dataset for the reverse. I would like to randomly
> permute the friendships so that 1.) the total degree for each individual
> remains the same, i.e. each individual ends up with the same number of
> friendships they had in the original undirected dataset and 2.) there are
> no self loops, so individuals are not connected to themselves. Any
> suggestions on this would be greatly appreciated.
>
>
>
> Example
>
> Observed data:
>
> Ego          Alter
>
> Alicia       James
>
> Beth        Kim
>
> James      John
>
> James      Rachel
>
> James      Alicia
>
> John        Kerry
>
> John        Rachel
>
> John        James
>
> Kerry     Rachel
>
> Kerry      John
>
> Kim         Rachel
>
> Kim          Beth
>
> Rachel    Kim
>
> Rachel    James
>
> Rachel    Kerry
>
> Rachel    John
>
>
>
> Permuted data:
>
> Ego          Alter
>
> Alicia
>
> Rachel
>
> Beth
>
> James
>
> James
>
> Beth
>
> James
>
> John
>
> James
>
> Kim
>
> John
>
> Rachel
>
> John
>
> Kerry
>
> John
>
> James
>
> Kerry
>
> Rachel
>
> Kerry
>
> John
>
> Kim
>
>  Rachel
>
> Kim
>
> James
>
> Rachel
>
> Kim
>
> Rachel
>
> John
>
> Rachel
>
> Alicia
>
> Rachel
>
> Kerry
>
>
>
> Thank you in advance,
> Holly
>
>
>
>
>
>
>
>
> hollym...@gmail.com
>
>
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to