# Commands and Syntax for Data Analysis Using STATA

Only available on StudyMode
• Topic: Statistics, Time series analysis, Time series
• Pages : 7 (1247 words )
• Published : April 5, 2011

Text Preview
Time series analysis
(Session – I)

Commands and syntax for data analysis using STATA

1. Open and Run the STATA application
• Click on the Data on the task bar and open Data editor • Copy the data from Excel sheet and paste it on the data editor • Preserve the data
• Close Data Editor

2. Type “describe” in the command space- Software will show the description of the data set.

3. Graphs
i) To Draw a scatter plot of variables yvar (y-axis) against xvar (x-axis) type the following in the command box: scatter yvar xvar

ii) Draw a line graph, i.e. scatter with connected points: line yvar xvar

iii) Draw a correlogram (graphical representation of autocorrelation coefficients): ac yvar

4. Autocorrelation function:
tsset time variable (set the time variable) corrgram yvar

Time series analysis
(Session –II)

Commands and syntax for data analysis using STATA
5. Open and Run the STATA application – copy the data to the Data editor

6. Declare the dataset to be time series data, type the following tsset time variable (set the time variable)

7. Moving average of xvar :
tssmooth ma [new var] = xvar, window [no. of lags]

8. Single Exponential Smoothing of xvar :
tssmooth exponential [new var] = xvar

9. Double –exponential smoothing of xvar :
tssmooth dexponential [new var] = xvar

10. Holt-Winters seasonal smoothing of xvar :
tssmooth shwinters [new var] = xvar, period (X)

(to display the changes in the result window type the command – “list”) Time series analysis
(Session – III)

Commands and syntax for Differencing data for stationarity using STATA

11. Open and Run the STATA application – copy the data to the Data editor

12. Declare the dataset to be time series data, type the following tsset time variable (set the time variable)

13. Autocorrelation function & Correlogram of yvar:
corrgram yvar
ac yvar, name (AC)
4. 1st order difference of yvar, create a new variable dy1 as: gen dy1 = D.yvar

5. 2nd order difference of yvar, create another new variable dy2 as: gen dy2 = D.D.yvar

6. Autocorrelation function & Correlogram of dy1:
corrgram dy1
ac dy1, name (DY1)

7. Autocorrelation function & Correlogram of dy2:
corrgram dy2
ac dy2, name (DY2)

(to display the differenced value in the result window type the command – “list”, use “line” for viewing trend) Time series analysis
(Session – IV)

Commands and syntax for Test for stationarity using STATA
14. Open and Run the STATA application – copy the data to the Data editor

15. Declare the dataset to be time series data, type the following tsset time variable (set the time variable)

16. Augmented Dicky-Fuller test for unit root :
dfuller yvar, [options] lags (>0)

17. Test for cointegration (Engle-Granger test)
regress y x
predict residual, res

5. Test residual for stationarity (Augmented Dicky-Fuller test) dfuller residual, [options] lags (>0)

6. Test for autocorrelation of residuals (Durbin-Watson Test) dwstat

Options:noconstant - suppress constant term in regression trend - include trend term in regression
regress -display regression table

Time series analysis
(Session – V)

Commands and syntax for ARIMA model using STATA
18. Open and Run the...