Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: re: assistance with time series data


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: re: assistance with time series data
Date   Thu, 7 Aug 2008 08:50:45 -0400

< >
Justin said

I am working with person-year data and trying to estimate the time it takes someone to move after they have finished their education. The data tell me for each year of a person's life, whether they moved that year and whether (and what level) of school they were in. I have a variable that tells me the age someone made a move (could have multiple moves per lifetime) and the age that someone finished school (could only finish school once in lifetime). To get what I want, the interval between finishing school and move, I subtract the persons age when they moved from the time they finished school. The works out fine unless someone made a move before finishing school, which is where I'm stuck. For instance, someone moved at age 15 and at age 22 and they finished school at age 21. I'm only interested in the move made after finishing school but with the coding, it's only accepting the first move. So the time between finish school and moving is -6 rather than +1. I've tried several things but nothing is working.


. use schoolmove, clear

. list, sepby(person)

+---------------------------------+
| person age inschool moved |
|---------------------------------|
1. | 1 15 1 0 |
2. | 1 16 1 0 |
3. | 1 17 1 0 |
4. | 1 18 0 0 |
5. | 1 19 0 0 |
6. | 1 20 0 1 |
7. | 1 21 0 0 |
|---------------------------------|
8. | 2 18 1 0 |
9. | 2 19 1 1 |
10. | 2 20 1 0 |
11. | 2 21 1 0 |
12. | 2 22 0 0 |
13. | 2 23 0 1 |
14. | 2 24 0 0 |
+---------------------------------+

. g movedafter = !inschool & moved

. egen leftschool = max(age*inschool), by(person)

. g sinceschool = age*movedafter - leftschool if movedafter
(12 missing values generated)

. list, sepby(person)

+------------------------------------------------------------------+
| person age inschool moved moveda~r leftsc~l sinces~l |
|------------------------------------------------------------------|
1. | 1 15 1 0 0 17 . |
2. | 1 16 1 0 0 17 . |
3. | 1 17 1 0 0 17 . |
4. | 1 18 0 0 0 17 . |
5. | 1 19 0 0 0 17 . |
6. | 1 20 0 1 1 17 3 |
7. | 1 21 0 0 0 17 . |
|------------------------------------------------------------------|
8. | 2 18 1 0 0 21 . |
9. | 2 19 1 1 0 21 . |
10. | 2 20 1 0 0 21 . |
11. | 2 21 1 0 0 21 . |
12. | 2 22 0 0 0 21 . |
13. | 2 23 0 1 1 21 2 |
14. | 2 24 0 0 0 21 . |
+------------------------------------------------------------------+


Notice that Ms. 2 moved during school, but that move is not considered.


Kit Baum, Boston College Economics and DIW Berlin
http://ideas.repec.org/e/pba1.html
An Introduction to Modern Econometrics Using Stata:
http://www.stata-press.com/books/imeus.html


*
* 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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index