Statalist The Stata Listserver


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

Re: st: linear interpolation


From   Rafal Raciborski <[email protected]>
To   [email protected]
Subject   Re: st: linear interpolation
Date   Wed, 19 Jul 2006 14:15:38 -0400

scott,

i usually add the missing years manually (just for one country or for a "missing" country) and then use �tsfill, full-:

. list

+----------------------+
| year D country |
|----------------------|
1. | 1980 100 1 |
2. | 1990 200 1 |
3. | 2000 300 1 |
4. | 1990 3 2 |
5. | 2000 4 2 |
+----------------------+

. local N = `_N' + 30

. set obs `N'
obs was 5, now 30

. replace year = 1975 + _n if year == .
(25 real changes made)

. tsset country year
panel variable: country, 1 to 2
time variable: year, 1980 to 2000, but with gaps

. tsfill, full

. drop if country==.
(26 observations deleted)

. list

+----------------------+
| year D country |
|----------------------|
1. | 1980 100 1 |
2. | 1981 . 1 |
3. | 1982 . 1 |
4. | 1983 . 1 |
5. | 1984 . 1 |
|----------------------|
6. | 1985 . 1 |
7. | 1986 . 1 |
8. | 1987 . 1 |
9. | 1988 . 1 |
10. | 1989 . 1 |
|----------------------|
11. | 1990 200 1 |
12. | 1991 . 1 |
13. | 1992 . 1 |
14. | 1993 . 1 |
15. | 1994 . 1 |
|----------------------|
16. | 1995 . 1 |
17. | 1996 . 1 |
18. | 1997 . 1 |
19. | 1998 . 1 |
20. | 1999 . 1 |
|----------------------|
21. | 2000 300 1 |
22. | 2001 . 1 |
23. | 2002 . 1 |
24. | 2003 . 1 |
25. | 2004 . 1 |
|----------------------|
26. | 2005 . 1 |
27. | 1980 . 2 |
28. | 1981 . 2 |
29. | 1982 . 2 |
30. | 1983 . 2 |
|----------------------|
31. | 1984 . 2 |
32. | 1985 . 2 |
33. | 1986 . 2 |
34. | 1987 . 2 |
35. | 1988 . 2 |
|----------------------|
36. | 1989 . 2 |
37. | 1990 3 2 |
38. | 1991 . 2 |
39. | 1992 . 2 |
40. | 1993 . 2 |
|----------------------|
41. | 1994 . 2 |
42. | 1995 . 2 |
43. | 1996 . 2 |
44. | 1997 . 2 |
45. | 1998 . 2 |
|----------------------|
46. | 1999 . 2 |
47. | 2000 4 2 |
48. | 2001 . 2 |
49. | 2002 . 2 |
50. | 2003 . 2 |
|----------------------|
51. | 2004 . 2 |
52. | 2005 . 2 |
+----------------------+


then you can use -ipolate- with the epolate option, see �help ipolate-

rafal



Quoting Scott Cunningham <[email protected]>:


I have data from the 1980, 1990 and 2000 Census, and need to linearly interpolate the in-between years (1981-1989, 1991-2001, 2002-2005). For now, I am assuming a constant rate of growth each year. Let D80 equal the 1980 value, D90 equal the 1990 value and r be the rate of growth per year. Solving this means solving the following equation for r:

D1*(1+r)^10=D2

I had two questions. How do I create a panel for 1981-1989, 1991-1999, 2001-2005 to insert these missing values? Assume the data is in this format:

YEAR D STATE
1980 100 1
1980 3 2
1990 200 1
1990 4 2

I want to create YEAR values for 1981-1989, etc., and then after doing that, create corresponding estimates for each state. This means calculating two different values for r, and then using that value to estimate each of the missing years. I think I will need to use the -expand- command, but I wasn't sure if there was a simple way to do this, such as with an ado file already created for exactly this sort of thing.

thanks,


scott
*
* 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/



================
Rafal Raciborski
Graduate student
Department of Political Science
Emory University
301 Tarbutton Hall
1555 Dickey Drive Atlanta, GA 30322
404-315-7498 (home)
[email protected]
http://www.roofoos.net/



*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index