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: AW: creating observations of non-occurrences


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: creating observations of non-occurrences
Date   Wed, 19 May 2010 17:32:51 +0200

<> 

This code can give you hints where to look:


*************
clear*
set obs 10
 
gen byte agentB=_n

tempfile first
save `first', replace

drop _all
set obs 10
gen byte agentA=_n
tempvar tosort
gen `tosort'=runiform()
sort `tosort'
drop `tosort'

merge 1:1 _n using `first', sorted nogen

expand _N, gen(original)
la def orig 0 "original" 1 "fake"
la val original orig

bys agentA agentB (original):  /* 
*/ replace agentB=cond(_n!=agentB[1],_n,  /* 
*/ agentB[1]+1) if _n!=1

l, sepby(agentA) h(20)

*************



HTH
Martin

-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Frederick Guy
Gesendet: Mittwoch, 19. Mai 2010 16:32
An: [email protected]
Betreff: st: creating observations of non-occurrences

I have N observations, each of which records a transaction between an
agent of type A and an agent of type B. 

I want to create a dataset of 11*N observations: the N that I already
have, plus 10*N for AB pairs that did not transact.

More specifically, for each transaction AiBj, i = 1....N, j= 1....T, I
want to draw a random sample of 10 AiBk non-occurrences, from the T-1
cases of k != j.

As usual I expect that this is laughingly simple, but these loops are
new to me.

Thanks.

Frederick



*
*   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/


*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index