| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: A contingency table of counts by case
I have the following data:
case id x
1 1 1 1
2 1 2 1
3 1 3 1
4 2 1 1
5 2 2 0
6 2 3 1
7 3 2 1
8 3 3 0
9 3 4 0
"case" - cases, "id" - persons, and "x" - binary state.
I would like to count the number of "cases" in which any two "id"
a. both have "x=1",
b. the first has "x=0" - the second has "x=1",
c. the first has "x=1" - the second has "x=0",
d. both have "x=0",
and transform these counts to relative frequencies in the total number
of "cases" the pair has been observed together. The composition of
"case" by "id" varies, e.g. case=1,2 have id=1,2,3, but case=3 has id=2,3,4.
I guess this can be accomplished using nested loops, but do you know of
a better solution? I have about 20000 observations.
Thanks a lot for you help,
Serguei Kaniovski
--
___________________________________________________________________
Austrian Institute of Economic Research (WIFO)
Name: Serguei Kaniovski P.O.Box 91
Tel.: +43-1-7982601-231 Arsenal Objekt 20
Fax: +43-1-7989386 1103 Vienna, Austria
Mail: [email protected]
http://www.wifo.ac.at/Serguei.Kaniovski
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/