Computer lab 2 - IDA - Linköping University

advertisement
Linköping university
Time series analysis, 732A21
Computer lab 2: Auto-Regressive-Moving-Average
(ARMA) Models
Learning objectives
The main objective of this computer lab is to make the student acquainted with the main
features of ARMA-models and how such models can be used for forecasting.
After completing the lab the student shall be able to:
(i)
Judge by visual inspection of time series plots and autocorrelations whether or
not a given data sets can be regarded as observations of a stationary sequence;
(ii)
Make a preliminary choice of ARMA model based on observed
autocorrelations and partial autocorrelations;
(iii)
Convert a non-stationary series into a stationary series by ordinary and
seasonal differencing;
(iv)
Explain how forecast of differenced series can be used to compute forecasts of
the original time series of data.
Assignment 1: Simulation of ARMA-models
Consider an AR(2)-process
Z t  1 Z t 1   2 Z t  2  et
normally distributed with mean zero and variance one. Such a process is stationary if the
parameters 1 and 2 satisfy the following conditions
2+1<1,
2-1<1,
-1<2<1.
Furthermore, it is easy to show that these conditions are satisfied if the point (1 , 2) is
inside the triangle defined by the straight lines 2+1=1, 2-1=1, and 2=-1.
Select a pair (1, 2) of parameter values that is inside the triangle defined above and not
close to any of its sides. Define two initial values Z1 and Z2 and use the random number
generator in Excel (Tools: Data Analysis) to generate another 100 observations of the
selected AR(2)-process. Make a time series plot of the generated data. (If you want to
reduce the impact of the initial values you can generate a somewhat longer time series of
data and discard the first part of it.)
Select a new pair of parameter values that is inside the triangle defined above but close to
its boundary. Generate and plot 100 observations of the selected AR(2)-process. In what
respect does the temporal variation of the second curve differ from that of the first curve?
Linköping university
Time series analysis, 732A21
Select a third pair of parameters that correspond to a point outside the cited triangle.
Generate and plot 100 observations of the selected AR(2)-process. In what respects does
the third curve differ from the other curves?
Make sure that you, by visual inspection, can identify time series plots corresponding to
(i) a clearly stationary process, (ii) a stationary but almost non-stationary process, and
(iii) a non-stationary process.
Copy and paste your three AR(2)-series to MINITAB and plot the sample autocorrelation
function for time lags 1-20. In what respect are the three autocorrelation functions
different? Note especially how the autocorrelation tails off with increasing time lags.
Theoretical task: Calculate the theoretical autocorrelation functions of the simulated
AR(2)-processes and compare with the sample autocorrelation functions.
Assignment 2: Identification of ARMA-models
Generate 100 observations according to the AR(1)-process
Yt  0.8Yt 1  et
where Var(et)=1. Form a new process
Z t  Yt   t
by adding independent normally distributed measurement errors t with mean 0 and
variance 1 to the original observations. Use MINITAB to compute the sample
autocorrelation and partial autocorrelation functions of Zt. Identify a suitable ARMAprocess for the data set under consideration and estimate the parameters of the model.
Plot the residuals to check whether the selected model is a suitable model.
Theoretical task: Calculate the theoretical autocorrelation function of Zt and compare
with the sample autocorrelation function.
Assignment 3: Making a non-stationary time series stationary by
differencing
Start an internet browser and open the web page
http://www.scb.se/eng/index.asp
Find statistics on the population in Sweden by doing the following:
Click on Statistical database
Select Population
Linköping university
Time series analysis, 732A21
Select Population by region, marital status, age and sex
Extract the total population of Sweden 1968Save the extracted data as a text or Excel file
Make a time series plot of the population in Sweden
Copy and past your data into MINITAB.
Carry out appropriate differencing operations and make time series plots of each of the
differenced series. What differencing operations are needed to make the series stationary?
Compute sample autocorrelation functions for the original series as well as each of the
differenced series. Do the estimated autocorrelations indicate that you have obtained a
stationary series after the last differencing? If not, carry out additional differencing.
Fit a suitable ARMA-model to the twice differenced population series and compute
forecasts for the next five years. (If you run into parameter estimation problems you can
try to fit a model without constant term.)
Use a calculator or a spreadsheet to convert the forecasts of the twice differenced series
into forecasts of the original population series for the next five years.
Find statistics on the number of registered vehicles in Sweden by doing the following:
Click on Sweden’s Statistical Databases
Click on Statistical database
Select Transport and communications
Select Fordon enligt bilregistret (number of cars according to the vehicle register)
Select Personbilar i trafik (passenger cars in traffic)
Select all data from 1975 and onwards
Save the extracted data as a text or Excel file
Make a time series plot of:
1) the number of cars in traffic
2) the change in the number of cars in traffic since the previous month
Copy and past your data into MINITAB.
Carry out additional differencing and make time series plots of the differenced series.
What differencing operations are needed to make the series stationary?
Compute sample autocorrelation functions for the original series as well as each of the
differenced series. Do the estimated autocorrelations indicate that you have obtained a
stationary series after the last differencing? If not, try another type of differencing.
Linköping university
Time series analysis, 732A21
Fit a suitable ARMA-model to a suitable differenced series of registered cars and
compute forecasts for the next twelve months.
Theoretical work: Use a calculator to convert forecasts of the differenced series into
forecasts of the original series.
To hand in
This course has individual written lab reporting. Write a concise report that shows that
you have done the assignments and reflected over the results obtained.
Deadline for reporting is normally one week after the lab has been made available on the
course website.
Download