Class Exercises 1. Decomposition (a) Use "decompose" on the Air Passenger series to obtain a trend, seasonal effect and random component. Do you think a multiplicative or additive model is more appropriate. Choose the most approprate model, redoing the decomposition if necessary. (b) List the components in R. Plot the trend component. Plot the seasonal component. Use "cycle" to produce a boxplot of the seasonal component. Since the seasonal effect is the same for any month, this boxplot should just give you the actual seasonal effects. (c) Produce a plot of the trend component with the seasonal component superimposed (see Figure 13 in the notes). 2. Stationarity and Ergodic Series (a) Look up the word "stationary" in a time series book or on the internet. Check the definition against that in the notes and lectures. (b) Repeat (a) for the word "ergodic". Check that you understand these two words in the context of time series and stochastic processes. 3. Correlation (revision exercise). (a) Read in the Chocolate, Beer, and Electricity data. Calculate the correlation between the three variables, using: (i) the "cor" function and (ii) "cov" and "sd" functions (see notes). (b) Look up the word "autocorrelation". We will cover this in more detail in the next lecture, but in the meantime plot the autocorrelation for the electricity series using the R function "acf". What features in the acf plot correspond to the seasonal variation in the series? 4. Autocorrelation (a) Plot the correlogram for the Air Passenger series. What feature in the correlogram correspond to the (i) trend; (ii) seasonal variation? (b) Fit a decomposition model to the Air Passenger series, and store the random component (residuals) in a vector "ap.res". (c) Remove the missing values from "ap.res" and replace "ap.res" with a new "ap.res" that has no missing values. The easiest way to do this is to use: "ap.res = ap.res[!is.na(ap.res)]", where "is.na" is an R function that returns "TRUE" if a value is missing (NA - not available), and "!" means "NOT". (d) Plot the correlogram of "ap.res". (Note that, by default, the "acf" function does not accept missing values.) What do you notice? 5. Exponential Smoothing (i) Read in the motor complaints series, and fit an exponential smoothing model for alpha = 0.99 and alpha = 0.01. Plot the results. What do you notice? (ii) Read in the quarterly exchange rate series from: http://www.massey.ac.nz/~pscowper/ts/pounds_nz.dat, and create a ts object in R. Fit an exponential smoothing model to this series. Plot the result. What is the estimate of alpha? 6. Holt Winters Fit a Holt Winters model to the beer production data and forecast the next years production. The data are located at: http://www.massey.ac.nz/~pscowper/ts/cbe.dat. Do you think a multiplicative or additive seasonal model would be most suitable?