Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: Re: Snowball sampling


From   "Joseph Coveney" <[email protected]>
To   <[email protected]>
Subject   st: Re: Snowball sampling
Date   Sat, 23 Mar 2013 13:06:02 +0900

Ray Hawkins wrote:

I am working with social network data, but it is too big, so I would like to
do snowball sampling. My data look like the following. Can you help me
figure out how to keep 'giveid' and corresponding 'recid' for a seed id? For
example, giveid=17 is a seed id. So, I would like to keep giveid=17 and all
giveid (=recid for giveid=17) = 6, 2, 5, 23, 1, 11, 4, 16, 33, 27, 16 (if
exist, of course). Then, for another seed id=32, for example, I would like
to repeat the same process to get certain data size. Thank you in advance.

--------------------------------------------------------------------------------

Not very efficient, but it should work and it has an easy-to-debug one-to-one
correspondence with the specifications:

* "keep giveid=17"
generate byte keep = giveid == 17

* "and all giveid (=recid for giveid=17)"
quietly levelsof recid if giveid == 17, local(keepers)
quietly foreach keeper of local keepers {
    replace keep = 1 if giveid == `keeper'
}

* "repeat the same process" "for another seed id=32"
quietly replace keep = 1 if giveid == 32
quietly levelsof recid if giveid == 32, local(keepers)
quietly foreach keeper of local keepers {
    replace keep = 1 if giveid == `keeper'
}

quietly keep if keep

Joseph Coveney

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index