Problem 1

Comparing the two phases of arrival along the surface, \(P(t = 1, \dots, 1024)\) and \(S(t = 1025, \dots , 2048)\), for the two series, we can see that both the Earthquake and Explosion waveform amplitude increases when phase S begins, but while the Eartquake waveform amplitude holds its new level throughout phase \(S\), the Explosion waveform amplitude diminishes and almost returns to its \(P\) phase level.

plot(EQ5, col = "#336B87", ylab = "Values")

lines(EXP6, col = "#763626")

legend('topleft', legend = c("Earthquake", "Explosion"), 
       col = c("#336B87", "#763626"), lty = 1, cex = 0.8)

Problem 2

Part (a)

s = c(rep(0, 100), 10 * exp(-(1:100)/20) * cos(2 * pi * 1:100/4))

x = s + rnorm(200)

plot.ts(x, main = 'Model A', col = "#336B87")

Part (b)

s = c(rep(0, 100), 10 * exp(-(1:100)/200) * cos(2 * pi * 1:100/4))

x = s + rnorm(200)

plot.ts(x, main = 'Model B', col = "#336B87")

Part (c)

The time serie generated by Model A has a behavior similiar to that of the Explosion serie, and the time serie generated by Model B has a behavior similar to that of the Earthquake serie presented in problem 1. Below we have the signal modulator of Model A and B. The signal modulator A generates a serie that decreases more rapidly with time when compared to the series generated by signal modulator B, which explains the behavior of the series generated by Model A and Model B discussed above.

signal_a = exp(-c(1:100)/20)

signal_b = exp(-c(1:100)/200)

plot.ts(signal_a, col = "#336B87", ylab = "Values", ylim = c(0,1))

lines(signal_b, col = "#763626")

legend('bottomleft', legend = c("Signal A", "Signal B"), 
       col = c("#336B87", "#763626"), lty = 1, cex = 0.8)

Problem 3

Part (a)

# ts
w = rnorm(100, 0, 1) 

x = filter(w, filter = c(0 , -.9), method = "recursive")

# moving average
ma = filter(x, filter = rep(1/4, 4), sides = 1)

# plot
plot(x, col = "#336B87", ylab = "Values")

lines(ma, col = "#763626")

legend('topleft', legend = c("ts x", "moving average"), 
       col = c("#336B87", "#763626"), lty = 1, cex = 0.8)

Part (b)

# ts
x = cos(2 * pi * 1:100/4)

# moving average
ma = filter(x, filter = rep(1/4, 4), sides = 1)

# plot
plot.ts(x, col = "#336B87", ylab = "Values")

lines(ma, col = "#763626")

legend('topleft', legend = c("ts x", "moving average"), 
       col = c("#336B87", "#763626"), lty = 1, cex = 0.8)

Part (c)

# ts 
w = rnorm(100, 0, 1) 

x = cos(2 * pi * 1:100/4) + w 

# moving average
ma = filter(x, filter = rep(1/4, 4), sides = 1)

# plot
plot.ts(x, col = "#336B87", ylab = "Values")

lines(ma, col = "#763626")

legend('topleft', legend = c("ts x", "moving average"), 
       col = c("#336B87", "#763626"), lty = 1, cex = 0.8)

Part (d)

In all three models, the moving average smooths the series, helping to visually extract patterns more easily. The more regular the series, the more smooth is the moving average. Model C is the least regular and Model B is the extreme case, in which the series varies between -1 and 1, and its moving average is actually a constant equal to zero.

Problem 8

Part (a)

Consider the first three values of the random walk with drift model presented,

\[\begin{align} x_0 &= 0 \\[0.5cm] x_1 &= \delta + x_0 + w_1 \\[0.5cm] x_2 &= \delta + x_1 + w_2 \end{align}\]

Plugging the first and second equations on the third equation, we have:

\[\begin{align} x_2 &= 2\delta + \sum_{k = 1}^{2} w_k \end{align}\]

Using induction, we can see that:

\[\begin{align} x_t &= \delta t + \sum_{k = 1}^{t} w_k \end{align}\]

Part (b)

For the mean function we have:

\[\begin{align} E(x_t) &= E\bigg(\delta t + \sum_{k = 1}^{t} w_k\bigg) \\[0.5cm] &= E(\delta t) + E\bigg(\sum_{k = 1}^{t} w_k\bigg) \\[0.5cm] &= \delta t \end{align}\]

For the autocovariance function we have:

\[\begin{align} \gamma (s, t) = cov (x_s, x_t) &= E \bigg\{\Big(x_s - E(x_s)\Big) \Big(x_t - E(x_t)\Big) \bigg\} \\[0.5cm] &= E \bigg\{\Big(x_s - \delta s\Big) \Big(x_t - \delta t \Big) \bigg\} \\[0.5cm] &= E \bigg\{\Big(\delta s + \sum_{j = 1}^{s} w_j - \delta s\Big) \Big(\delta t + \sum_{k = 1}^{t} w_k - \delta t \Big) \bigg\} \\[0.5cm] &= E \bigg\{\sum_{j = 1}^{s} w_j \sum_{k = 1}^{t} w_k \bigg\} \\[0.5cm] & = mín\{s,t\} \; \sigma_w^2 \end{align}\]

Part (c)

The first and second moments of the series are a function of time. So, the serie is not stationary.

Part (d)

Using the expression for the autocovariance function from question (b), we have:

\[\begin{align} \rho(t-1, t) &= \frac{\gamma(t-1, t)}{\sqrt{\gamma(t-1, t-1) \; \gamma(t,t)}} \\[0.5cm] &= \frac{(t-1) \sigma_w^2}{\sqrt{(t-1) \sigma_w^2 \; t \sigma_w^2}} \\[0.5cm] &= \frac{(t-1)}{\sqrt{(t-1) \; t}} \\[0.5cm] &= \sqrt{\frac{(t-1)}{t}} \\[0.5cm] &= \sqrt{1 - \frac{1}{t}} \end{align}\]

So, as \(t \rightarrow \infty\), \(\rho(t-1, t) \rightarrow 1\). This results implies that, as \(t\) increases, the correlation between the value in \(t\) and \(t-1\) increases, thus, the correlation between \(x_{100}\) and \(x_{99}\) is greater than the correlation between \(x_2\) and \(x_1\). So, \(\{x_t\}\) shows a more persistent behavior as time passes.

Part (d)

Subtracting \(x_{t-1}\) on both sides of the equation we get the new serie:

\[\begin{align} x_t - x_{t-1} = \delta + w_t \end{align}\]

Let \(y_t = x_t - x_{t-1}\), so, \(y_t = \delta + w_t\). For the mean and autocovariance function of the new serie we have:

\[E (y_t) = E(\delta + w_t) = \delta\] \[\gamma (y_s, y_t) = cov(\delta + w_s, \delta + w_t) = cov(w_s, w_t) = 0\] As the mean and autocovariance are not a function of time, we can conclude that \(\{y_t\}\) is stationary.

Problem 19

Part (a)

\[\begin{align} E(x_t) &= E(\mu + w_t + \theta w_{t-1}) \\[0.5cm] &= E(\mu) + E(w_t) + \theta E(w_{t-1}) \\[0.5cm] &= \mu \end{align}\]

Part (b)

The autocovariance function can be written as:

\[\begin{align} \gamma(s, t) &= cov(x_s, x_t) \\[0.5cm] &= E\bigg\{\Big(x_s - E(x_s)\Big) \Big(x_t - E(x_t)\Big) \bigg\} \\[0.5cm] &= E\bigg\{\Big(\mu + w_s + \theta w_{s-1} - \mu\Big) \Big(\mu + w_t + \theta w_{t-1} - \mu \Big) \bigg\} \\[0.5cm] &= E\bigg\{\Big(w_s + \theta w_{s-1} \Big) \Big(w_t + \theta w_{t-1} \Big) \bigg\} \\[0.5cm] &= E \Big(w_s w_t + \theta w_s w_{t-1} + \theta w_{s-1} w_t + \theta^2 w_{s-1} w_{t-1} \Big) \end{align}\]

For \(s = t\) we have:

\[\begin{align} \gamma(t, t) &= E \Big(w_t^2 + \theta w_t w_{t-1} + \theta w_{t-1} w_t + \theta^2 w_{t-1}^2 \Big) \\[0.5cm] &= \sigma_w^2 + \theta^2 \sigma_w^2 \\[0.5cm] &= \sigma_w^2 (1 + \theta^2) \end{align}\]

Where the expected value from the crossed terms are zero because the \(\{w\}\) process generates independent variables.

For \(\mid s - t\mid = 1\) we have:

\[\begin{align} \gamma(t-1, t) &= E \Big(w_{t-1} w_t + \theta w_{t-1}^2 + \theta w_{t-2} w_t + \theta^2 w_{t-2} w_{t-1} \Big) \\[0.5cm] &= \theta \sigma_w^2 \end{align}\]

For \(\mid s - t\mid > 1\) we won’t have quadratic terms, so \(\gamma(s, t) = 0\) for \(\mid s - t\mid > 1\).

Part (c)

Using the results from question (b), we can see that for all values of \(\theta \in \mathbb{R}\) the mean function will be a constant (\(\mu\)), the variance will be a finite positive value that is not a function of time, and the autocovariance function \(\gamma(s, t)\) para \(s \neq t\) will not be function of time either. So, the processes will be stationary because its first and second moments are well-defined and not a function of time.

Part (d)

The expression for \(var(\bar{x})\) is:

\[\begin{align} var(\bar{x}) = \frac{1}{n} \sum^{n}_{h = -n} \bigg( 1 - \frac{\mid h \mid}{n} \bigg) \gamma_x(h) \end{align}\]

Because the autocovariance function for the processes \(\{x_t\}\) is zero for \(\mid h \mid > 1\), we can rewrite the variance expression above just considering \(h = \{-1, 0, 1\}\). We get:

\[\begin{align} var(\bar{x}) &= \frac{1}{n} \sum^{1}_{h = -1} \bigg( 1 - \frac{\mid h \mid}{n} \bigg) \gamma_x(h) \\[0.5cm] &= \frac{1}{n} \bigg[ \gamma_x(0) + 2 \bigg( 1 - \frac{1}{n} \bigg) \gamma_x(1) \bigg] \end{align}\]

Plugging the \(\gamma_x(0)\) and \(\gamma_x(1)\) into the equation we get:

\[\begin{align} var(\bar{x}) &= \frac{1}{n} \bigg[ \sigma_w^2 (1 + \theta^2) + 2 \bigg( 1 - \frac{1}{n} \bigg) \sigma_w^2 \theta \bigg] \\[0.5cm] &= \frac{\sigma_w^2}{n} \bigg[ 1 + \theta^2 + 2 \bigg( \frac{n-1}{n} \bigg) \theta \bigg] \end{align}\]

So, for \(\theta = 1\) we have:

\[\begin{align} var(\bar{x}) &= \frac{2 \sigma_w^2}{n} \bigg[ 1 + \bigg( \frac{n-1}{n} \bigg) \bigg] \end{align}\]

For \(\theta = 0\) we have:

\[\begin{align} var(\bar{x}) &= \frac{\sigma_w^2}{n} \end{align}\]

And, for \(\theta = -1\) we have:

\[\begin{align} var(\bar{x}) &= \frac{2 \sigma_w^2}{n} \bigg[ 1 - \bigg( \frac{n-1}{n} \bigg) \bigg] \end{align}\]

Part (e)

For values of \(n\) usually occurring in time series \((n − 1)/n\) will be close to 1. So, for \(\theta = 1\) the variance of for the mean estimation can be written as:

\[\begin{align} var(\bar{x}) \approx \frac{4 \sigma_w^2}{n} \end{align}\]

For \(\theta = 0\) we still have:

\[\begin{align} var(\bar{x}) \approx \frac{\sigma_w^2}{n} \end{align}\]

And, for \(\theta = -1\) we have:

\[\begin{align} var(\bar{x}) \approx 0 \end{align}\]

We can conclude that the accuracy of the mean estimate when \(\theta = -1\) is greater than when \(\theta = 0\), and the accuracy of the mean estimate when \(\theta = 0\) is greater than when \(\theta = 1\).

Problem 20

Part (a)

w = rnorm(500, 0, 1) 

acf(w, plot = FALSE, lag.max = 20)
## 
## Autocorrelations of series 'w', by lag
## 
##      0      1      2      3      4      5      6      7      8      9     10 
##  1.000 -0.012 -0.007 -0.033  0.072 -0.011  0.030 -0.033 -0.019  0.029  0.016 
##     11     12     13     14     15     16     17     18     19     20 
##  0.017 -0.041  0.036 -0.068  0.024  0.008  0.003  0.018  0.031  0.027
acf(w, lag.max = 20)

Given that variables generated from a white noise process are independent, the autocorrelation for \(x_t\) e \(x_s\) is zero when \(s \neq t\). For the simulated series using \(n = 500\), all autocorrelations are statistically equal to zero, and most of them has an absolute value close to zero.

Part (b)

w = rnorm(50, 0, 1) 

acf(w, plot = FALSE, lag.max = 20)
## 
## Autocorrelations of series 'w', by lag
## 
##      0      1      2      3      4      5      6      7      8      9     10 
##  1.000 -0.107 -0.045  0.041 -0.191 -0.054 -0.080  0.045 -0.169 -0.283  0.110 
##     11     12     13     14     15     16     17     18     19     20 
##  0.061  0.016  0.263  0.099 -0.035  0.067 -0.087 -0.071 -0.084 -0.095
acf(w, lag.max = 20)

For the simulated series using \(n = 50\), most of the estimated autocorrelations are statistically equal to zero still, but their absolute values are not as close to zero as before.

Problem 21

Part (a)

w = rnorm(500, 0, 1) 

v = filter(w, sides = 2, filter = rep(1/3, 3))
           
acf(v, na.action = na.pass, plot = FALSE, lag.max = 20)
## 
## Autocorrelations of series 'v', by lag
## 
##      0      1      2      3      4      5      6      7      8      9     10 
##  1.000  0.694  0.356  0.042  0.027  0.029  0.016  0.008  0.002 -0.025 -0.048 
##     11     12     13     14     15     16     17     18     19     20 
## -0.051 -0.021  0.009  0.011 -0.001 -0.031 -0.067 -0.104 -0.108 -0.083
acf(v, na.action = na.pass, lag.max = 20)

For this moving average series \(\rho(h) \neq 0\) for \(\mid h \mid \le 2\) and \(\rho(h) = 0\) for \(\mid h \mid > 2\) (this is actually a property of moving averages that holds for every order \(q\), not only \(q = 2\)). For the simulated series using \(n = 500\), we have \(\hat{\rho}(h) \neq 0\) for \(h \le 2\) satisfied, but some \(\hat{\rho}(h) = 0\) do not hold for all \(h > 2\).

Part (b)

w = rnorm(50, 0, 1) 

v = filter(w, sides = 2, filter = rep(1/3, 3))
           
acf(v, na.action = na.pass, plot = FALSE, lag.max = 20)
## 
## Autocorrelations of series 'v', by lag
## 
##      0      1      2      3      4      5      6      7      8      9     10 
##  1.000  0.606  0.264  0.032  0.146  0.114 -0.020 -0.007  0.074  0.140 -0.051 
##     11     12     13     14     15     16     17     18     19     20 
## -0.271 -0.308 -0.169 -0.008 -0.082 -0.195 -0.242 -0.236 -0.268 -0.352
acf(v, na.action = na.pass, lag.max = 20)

For the simulated series using \(n = 50\), we can see that \(\hat{\rho}(h) \neq 0\) for \(h \le 2\) is not satisfied. And, for \(h > 2\), more autocorrelations do not satisfy \(\hat{\rho}(h) = 0\) compared to the estimation with \(n = 500\).