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 on April 23, and its replacement, is already up and running.

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

st: AW: creating observations of non-occurrences

From   "Martin Weiss" <>
To   <>
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:

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)



-----Ursprüngliche Nachricht-----
[] Im Auftrag von Frederick Guy
Gesendet: Mittwoch, 19. Mai 2010 16:32
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.



*   For searches and help try:

*   For searches and help try:

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