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]

Re: st: Contract/Collapse Combination


From   [email protected] (Brendan Halpin)
To   [email protected]
Subject   Re: st: Contract/Collapse Combination
Date   Mon, 21 May 2012 22:13:30 +0100

On Mon, May 21 2012, Lucas wrote:

> If I could then write something like:
>
> collapse x1 x2 x3 x4 ... xj, freq(EnterCol) freq(DidNotEnter)  zero

Here's a toy example based on some teaching-related work I was doing
today:

+----------------------------------------------------------------------
. input x1 x2 yesno count
. 1 1 0 353
. 1 1 1 207
. 1 2 0 17
. 1 2 1 8
. 2 1 0 120
. 2 1 1 205
. 2 2 0 202
. 2 2 1 391
. 3 1 0 138
. 3 1 1 279
. 3 2 0 131
. 3 2 1 244
. end
. 
. tab3way x1 yesno x2 [freq=count]
. 
. gen nno = count
. gen nyes = count[_n+1]
. keep if yesno==0
. drop count yesno
. 
. list, clean
. table x1 x2, c(max nno max nyes)
+----------------------------------------------------------------------

I think this is what you are asking for. It depends very strongly on the
assumption that the yesno variable (your "enter college" variable) is
sorted appropriately, i.e., in consecutive pairs of rows with all other
variables equal, the no line before the yes line. If zero counts are
omitted altogether, you'll have to adapt the code to take account of
that (or use -fillin-, but that might expand the data set too much). 

As an aside, you get the same results with the first format and this
model:

. logit yesno x1 x2 [freq=count]

as with the second format and this model:

. gen tot = nno + nyes
. blogit nyes tot x1 x2

which is a toy version of the problem you seem to be dealing with, if I
understand you correctly.


Regards,

Brendan
-- 
Brendan Halpin,   Department of Sociology,   University of Limerick,   Ireland
Tel: w +353-61-213147  f +353-61-202569  h +353-61-338562;  Room F1-009 x 3147
mailto:[email protected]    ULSociology on Facebook: http://on.fb.me/fjIK9t
http://teaching.sociology.ul.ie/bhalpin/wordpress         twitter:@ULSociology
*
*   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