# (2) type dfuller and then the name of the variable you want to test for a unit root. For example: dfuller top1 You could test the first difference of this variable for a unit root as follows: dfuller d.top1 Remember, the null hypothesis is that the IS a unit root. So, if you can reject the null, you can conclude there isn’t a unit root. For panel data: (1) tsset the data (e.g., tsset stnum year, yearly); (2) use either the Im, Pershan and Shin test (e.g., xtunitroot ips top1) or the Hadri’s Lagrange Multiplier test (e.g., xtunitroot hadri top1). The Hadri test requires a strongly balanced panel. So, the test can’t always be used. You can also include lags and a trend variable (e.g., xtunitroot ips top1, lag(aic 4) trend. You need the “xtfisher” command which can be downloaded (findit xtfisher). This is a test to see if a variable is stationary. The null hypothesis is that it has a “unit root.” Rejecting the null hypothesis of a unit root means the variable is stationary. With error correction models a useful test is to see if the residuals are stationary. If so, you don’t need to worry about some important problems. After estimating the model type: predict yhat (to obtain the residuals). Then type: xtfisher yhat if yhat==1 This will yield results for no lags. To specify lag length change the command to read: xtfisher yhat if yhat==1, lag(2) (for two time periods) If you reject this with confidence then the residuals are stationary. The results should say:

Ho: unit root

chi2(0) = 0.000 (i.e., less than .001 of a unit root)

# Prob > chi2 =

# To test for cointegration in panel data download the xtpedroni command

# Moving Average Variable: To transform state ideology from an annual variable

# (stideoan) to a moving average where years 1-4 were the same score (because our the data series we needed extend four years prior to the beginning of the time period for which data were collected) and years 5 and beyond were the average of the current year plus the immediately preceeding 3 years (each year equally weighted) type:

# xtset stnum year (note: stnum = state number and year=year)

# tssmooth ma stdeoan_ma=stideoan , window(3 1 0)

To generate a 12 year moving average of Democratic control (assuming you have already generated the Democratic control variable – e.g., 1= Democratic governor + Democratic majority of both houses of the state legislature in year “t” – how to do this is explained later in this file)

type:

tsset stnum year, yearly

gen demcont12 = (demcont[_n-12] + demcont[_n-11] + demcont[_n-10] + demcont[_n- 9] + demcont[_n-8] + demcont[_n-7] + demcont[_n-6] + demcont[_n-5] + demcont[_n -4] + demcont[_n-3] + demcont[_n-2] + demcont[_n-1])/12