Some notes before you start:
- Work precisely and read carefully.
- Answer all questions, and only the questions (so no unnecessary stories).
- If you have to test something, provide hypotheses, test results and conclusions.
- Time series commands are found in the menu Statistics under Time Series Differencing a variable is simple done by inserting D. before a variable, differencing twice is done using D2. (don’t forget the dot).
- In the ARIMA window you can specify a “full” order of lags to be included (e.g. AR(4) includes, 1st up to 4th lag), but you can also choose to include some specific lags (e.g. only 2nd and 4th lag). That you can do by choosing supply list of ARMA lags and indicating which lags you want to include.
Part 1
In this part of the practical use the data set univarts.dta, which contains 2 variables. The first variable, t, is a time trend, which serves as the “time variable” that Stata uses to denote the sequencing of the data over time. The other variable, y is the series to be analysed.
- Open the Stata datafile univarts.dta
- To declare that the data are time series data, go to Statistics/Time series/Setup & utilities/Declare data set to be time-series data. This takes you to the tsset menu.
- In the tsset menu, you should specify that the time variable is t and that the display format for the time variable is generic.
Now you are ready to analyse the data.
1. Obtain a graph of the series x, go to Statistics/Time series/Graphs/Line plots.
Question: Considering the graph, do you expect this series to be stationary? In your answer consider the mean and variance of the series and presence of trends.
2. Perform the Augmented Dickey Fuller test, available at Statistics/Time series/Tests. In the dfuller menu, begin with including a constant and trend term in the test equation, select display regression table and start with 12 lags for the autoregressive terms. If lagged autoregressive terms are not significant, eliminate them one by one, beginning with the longest lag. Eliminate the constant and deterministic trend if they are not significant.
Question: Report and interpret the results of the final version of the ADF test.
3. Also use the KPSS test (simply available as command: KPSS varname) to test the stationarity of the series.
Question: Report and interpret the results of the KPSS test.
4. If you conclude after questions 2 and 3 that the series is non-stationary, take first differences of y (specify as D.y in STATA) and then proceed with the ADF test on this differenced series. Continue differencing and testing, if necessary, until you obtain a stationary series.
Question: What is the order of integration of x?
5. Via Statistics/Time series/Graphs obtain the AC (Correlogram) function and PAC (Partial Correlogram) function of the stationary version of the series.
Question: Based on both these graphs, which ARIMA specification do expect to hold?
6. Based on the information from the AC and PAC graphs, estimate an appropriate ARIMA model for y, available at Statistics/Time series/ARIMA models. In the ARIMA menu, the dependent variable is y. Fill in the appropriate values for p, d and q.
Question: After obtaining an appropriate ARIMA model, summarise the results of your model. – Interpret the estimated parameters, including the intercept.
7. Obtain the residuals from this model (Statistics/Postestimation/Predictions, residuals, etc. ; from the menu, select Residuals or predicted innovations), and generate a new variable (call it “ehat”). Inspect the AC and PAC of ehat to see whether it is white noise.
Question: What do you conclude from both graphs?
8. Perform the Ljung-Box test (available at Statistics/Time series/Tests/Portmanteau white noise test.) for 5 and 10 lags (use ‘Options’). (Note: if you do not specify the number of lags, Stata selects 40)
Question: What do you conclude from this test?
9. Using the results of 7 and 8, decide whether your model is ‘finished’ or whether you can improve the specification. If you continue, go back to step 5, respecify the ARIMA model and continue with steps 6-8.
Question: Present your final ARIMA model (showing estimated parameters, their standard errors, test for overall significance of the model, etc and any information you have obtained about the remaining white-noise residual). Also write down the model in equation form.
Part 2
In this second exercise you will analyse a series for US wholesale prices, available in the file wpi1.dta. These are quarterly data, from 1960(Q1) to 1990(Q4), already declared as time series.
Previous analysis with these data has shown that taking natural logs of wpi reduces the heteroscedasticity of the series. You should work with the natural log version of the variable, which is also included in the data set.
Investigate the time series properties of ln_wpi and derive a proper ARIMA specification for this series. Use:
- Unit root tests, both the ADF and the KPSS test.
- AC and PAC graphs – Ljung-Box portmanteau white noise tests
- AIC and BIC if you have to decide between two different specifications with similar properties
Report your final results at each stage of the specification search, and present your final ARMA or ARIMA model for this series.
HƯỚNG DẪN DO-FILE
* Bạn hãy thay đổi đường dẫn (cd) thích hợp chứa tệp dữ liệu trong máy tính của mình!
cd “D:\Stata_data_analysis”
use univarts.dta, clear
*** Part 1
tsset t
twoway (tsline y)
dfuller y, trend regress lags(12)
dfuller y, regress lags(11)
dfuller y, regress lags(10)
kpss y
ac y
pac y
arima y, arima(0,0,2)
predict ehat, residuals
pac ehat
ac ehat
*** Câu 7
wntestq ehat, lags(5)
wntestq ehat, lags(10)
*** Câu 8
*** part 2
use wpi1.dta, clear
dfuller ln_wpi, trend regress lags(12)
dfuller ln_wpi, trend regress lags(11)
dfuller ln_wpi, trend regress lags(10)
dfuller ln_wpi, trend regress lags(9)
dfuller ln_wpi, trend regress lags(8)
dfuller ln_wpi, trend regress lags(7)
dfuller ln_wpi, trend regress lags(6)
dfuller ln_wpi, trend regress lags(5)
dfuller ln_wpi, trend regress lags(4)
kpss ln_wpi
*** tsline d.ln_wpi
dfuller D.ln_wpi, trend regress lag(4)
dfuller D.ln_wpi, regress lag(4)
dfuller D.ln_wpi, regress lag(3)
dfuller D.ln_wpi, regress lag(2)
dfuller D.ln_wpi, regress lag(1)
kpss D.ln_wpi
ac D.ln_wpi
pac D.ln_wpi
dfuller d2.ln_wpi, nocons regress lags(2)
kpss d2.ln_wpi
ac d2.ln_wpi
pac d2.ln_wpi
arima ln_wpi, arima(3,2,0) nocons
estat ic
predict vhat1, residuals
wntestq vhat1, lags(10)
ac vhat1
pac vhat1
arima ln_wpi, arima(0,2,1) nocons
estat ic
predict vhat2, residuals
ac vhat2
pac vhat2
wntestq vhat2, lags(10)
