1) The command:
sort pid month
bys pid: gen lagstatus=status[_n-1]
ta status lagstatus, row
2)the discrepancy:
Using xttrans
xttrans status, i(pid) t(month)
RECODE of |
newel2 |
(RECODE of |
newel | RECODE of newel2 (RECODE of newel (RECODE
(RECODE of | of element))
element)) | E S N U | Total
-----------+--------------------------------------------+----------
E | 99.21 0.05 0.62 0.12 | 100.00
S | 0.22 99.39 0.28 0.11 | 100.00
N | 2.04 0.06 97.84 0.06 | 100.00
U | 7.28 0.00 2.32 90.40 | 100.00
-----------+--------------------------------------------+----------
Total | 75.93 5.93 17.13 1.00 | 100.00
Using
ta status lagstatus, row:
RECODE of |
newel2 |
(RECODE of |
newel |
(RECODE of | lagstatus
element)) | E S N U | Total
-----------+--------------------------------------------+----------
E | 23,063 4 106 22 | 23,195
| 99.43 0.02 0.46 0.09 | 100.00
-----------+--------------------------------------------+----------
S | 12 1,797 3 0 | 1,812
| 0.66 99.17 0.17 0.00 | 100.00
-----------+--------------------------------------------+----------
N | 144 5 5,078 7 | 5,234
| 2.75 0.10 97.02 0.13 | 100.00
-----------+--------------------------------------------+----------
U | 27 2 3 273 | 305
| 8.85 0.66 0.98 89.51 | 100.00
-----------+--------------------------------------------+----------
Total | 23,246 1,808 5,190 302 | 30,546
| 76.10 5.92 16.99 0.99 | 100.00
----------------------------------------------------------
Subject: st: RE: xttrans
Show us
1. The _exact_ code used to generate lagstatus.
2. An example of discrepancies.
Nick
[email protected]
Anna Manzoni
I am using the xttrans command. I have a longitudinal data file with
status in each month for each respondent (12 months for each
respondent). I do not understand why using
xttrans status, i(pid) t(month)
doesn't give me exactly the same result as
ta status lagstatus, row
where status is the var indicating the status in each month (t) and
lagstatus is status at t-1.
What is xttrans actually doing?
*
* 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/