Exercise

# Dealing with trend and heteroscedasticity

Here, we will coerce nonstationary data to stationarity by calculating the return or growth rate as follows.

Often time series are generated as $$X_t = (1 + p_t) X_{t-1}$$ meaning that the value of the time series observed at time \(t\) equals the value observed at time \(t-1\) and a small percent change \(p_t\) at time \(t\).

A simple deterministic example is putting money into a bank with a fixed interest \(p\). In this case, \(X_t\) is the value of the account at time period \(t\) with an initial deposit of \(X_0\).

Typically, \(p_t\) is referred to as the *return* or *growth rate* of a time series, and this process is often stable.

For reasons that are outside the scope of this course, it can be shown that the growth rate \(p_t\) can be approximated by $$Y_t = \log X_t - \log X_{t-1} \approx p_t.$$

In R, \(p_t\) is often calculated as `diff(log(x))`

and plotting it can be done in one line `plot(diff(log(x)))`

.

Instructions

**100 XP**

- As before, the packages astsa and xts are preloaded.
- Generate a multifigure plot to (1) plot the quarterly US GNP (
`gnp`

) data and notice it is not stationary, and (2) plot the approximate growth rate of the US GNP using`diff()`

and`log()`

. - Use a multifigure plot to (1) plot the daily DJIA closings (
`djia$Close`

) and notice that it is not stationary. The data are an`xts`

object. Then (2) plot the approximate DJIA returns using`diff()`

and`log()`

. How does this compare to the growth rate of the GNP?