<>
BTW, -bysort ccode (year): - does not achieve the effect you want, as you
correctly suspect (hence the need for -rolling-): It merely restricts the
analysis to each level of "ccode" and -sort-s according to "year" in the
process - though for the standard deviation, -sort-ing hardly matters :-)
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Wallace,
Geoffrey P
Gesendet: Montag, 18. Januar 2010 14:40
An: [email protected]
Betreff: st: Generating summary variables in TSCS data using values across
long time periods
Dear all,
I have two questions, which I believe are related, and deal with generating
summary variables based on longer time periods using time-series
cross-sectional data.
1. I?m using the Polity IV data set which gives national democracy scores in
a country-year format.
As a measure of volatility I want to generate a variable that captures the
standard deviation in a country?s polity score (polity2) in a moving window
over 25-year periods. E.g. For Iraq in 1990 this would be the standard
deviation in polity2 for 1965-1989, etc. I also want a similar measure
looking at volatility in 25-year windows using future polity scores.
I have tried variants of the ?egen- command like the following
.bysort ccode (year): egen sd(polity2)
I believe this simply gives the standard deviation in polity2 across the
entire time period for each country, but I cannot figure out how to specify
by moving 25-year periods.
I was successful in using the ?tssmooth ma- command to create a moving
average variable over similar 25-year periods, but have not found a way to
generate something similar for standard deviations, or alternative measures.
2. I also want to generate a dummy variable by country-year that equal ?1?
if a country achieved above a particular polity2 score ?x? over the previous
25-year period. Is there a way to do so with using some form of the
expression
-if polity2[_n-1]>x ? polity2[_n-25]>x-
Is there a way to avoid specifying [_n-t] 25 separate times?
Any help on either issue would be greatly appreciated.
Best, Geoff
--
Geoffrey Wallace
Assistant Professor
Department of Political Science
1657 Patterson Office Tower
University of Kentucky
Lexington, KY 40506-0027
tel. 859-257-2709
fax. 859-257-7034
email. [email protected]
web. http://www.uky.edu/~gpwa223
*
* 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/
*
* 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/