[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Generating summary variables in TSCS data using values across long time periods

From   "Wallace, Geoffrey P" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: Generating summary variables in TSCS data using values across long time periods
Date   Mon, 18 Jan 2010 08:39:41 -0500

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]
*   For searches and help try:

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