\[ Var(Y_t)=Var(5+e_t-1 - \frac{1}{2} e_t-1+ \frac{1}{4} e_t-2)\\ =Var(e_t)+ \frac{1}{4} Var(e_t)+ \frac {1}{16}Var(e_t)\\ = \frac {21}{16} \sigma^2 \]
\[ Cov(Y_t, Y_{t-1}) = Cov(5+e_t-\frac{1}{2}e_{t-1}+\frac{1}{4}e_{t-2},5+e_{t-1}-\frac{1}{2}e_{t-2}+\frac{1}{4}e_{t-3}) \\ =Cov(-\frac{1}{2}e_{t-1},e_{t-1}) +Cov(\frac{1}{4}e_{t-2},-\frac{1}{2}e_{t-2}) \\ = -\frac{1}{2} Var(e_{t-1}) -\frac{1}{8} Var(e_{t-2}) \\ = -\frac{5}{8}\sigma_e^2 \]
\[ Cov(Y_t, Y_{t-2}) = Cov(5+e_t-\frac{1}{2}e_{t-1}+\frac{1}{4}e_{t-2},5+e_{t-2}-\frac{1}{2}e_{t-3}+\frac{1}{4}e_{t-4})\\ = \frac{1}{4} Var(e_{t-2}) \\ = \frac{1}{4}\sigma_e^2 \]
\[ Cov(Y_t, Y_{t-2}) = \text{Cov}(5+e_t-\frac{1}{2}e_{t-1}+\frac{1}{4}e_{t-2}, 5+e_{t-2}-\frac{1}{2}e_{t-3}+\frac{1}{4}e_{t-4}) = 0 \]
\[ \rho_k = \begin{cases} 1 & k = 0\\ \frac{-\frac{5}{8}\sigma_e^2}{\frac{21}{16}\sigma_e^2}=-\frac{10}{21} & k = 1\\ \frac{\frac{1}{4}\sigma_e^2}{\frac{21}{16}\sigma_e^2}=\frac{4}{21} & k = 2\\ 0 & k = 3\\ \end{cases} \tag*{$\square$} \]
library(TSA)
##
## Attaching package: 'TSA'
## The following objects are masked from 'package:stats':
##
## acf, arima
## The following object is masked from 'package:utils':
##
## tar
MA2<-arima.sim(model=list(ma=c(-0.5, -0.4)), n=10)
plot(MA2, type='o', main='MA2 ; theta=-0.5, theta2=-0.4')
plot(y=MA2, x=zlag(MA2), ylab=expression(Y[t]), xlab=expression(Y[t-1]),main='MA(2); theta1=-0.5, theta2=-0.4')
par(mfrow=c(2,2))
ACF1 <- ARMAacf(c(-0.5, -0.4), lag.max = 10)
plot(y=ACF1[-2], x=1:10, type="h");abline(h=0)
library(TSA)
MA2<-arima.sim(model=list(ma=c(-1.2, 0.7)), n=10)
plot(MA2, type='o', main='MA2 ; theta=-1.2, theta2=0.7')
plot(y=MA2, x=zlag(MA2), ylab=expression(Y[t]), xlab=expression(Y[t-1]),main='MA(2); theta1=-1.2, theta2=0.7')
par(mfrow=c(2,2))
ACF2 <- ARMAacf(c(-1.2, 0.7),0.5, lag.max = 5)
plot(y=ACF2[-1], x=1:5, type="h");abline(h=0)
library(TSA)
MA2<-arima.sim(model=list(ma=c(1, 0.6)), n=10)
plot(MA2, type='o', main='MA2 ; theta=1, theta2=0.6')
plot(y=MA2, x=zlag(MA2), ylab=expression(Y[t]), xlab=expression(Y[t-1]),main='MA(2); theta1=1, theta2=0.6')
ACF3 <- ARMAacf(c(1, 0.6), lag.max = 5)
plot(y=ACF3[-1], x=5:1, type="h");abline(h=0)
Mostrar que cuando q se reemplaza por 1/ \(\theta\) , la funcion de autocorrelacion de un MA(1) no cambia
\[ \rho_1 = \frac{-\theta}{1+\theta^2} \\ \] \[ \frac{\partial}{\partial \theta}\rho_1 =\frac{-1(1+\theta^2)-2\theta(-\theta)}{(1+\theta^2)^2} = \frac{\theta^2 - 1}{(1+\theta^2)^2} = 0 \]
Cuando \(t = \begin{cases}-1\\1\end{cases}\) nos da
\[ \begin{aligned} \max \rho_1 & = \frac{-1(-1)}{1+(-1)^2} = 0.5\\ \min \rho_1 & = \frac{-1}{1+1^2} = -0.5 \end{aligned} \]
theta <- seq(-10, 10, by = 0.01)
p1 <- (-theta) / (1 + theta^2)
plot(theta, p1, type = "l")
points(theta[which.max(p1)], max(p1))
points(theta[which.min(p1)], min(p1))
Calcular y gra???car las funciones de autocorrelacion para los siguientes modelos AR(1). Gra???car con un numero su???cientes de rezagos para que la funcion de autocorrelacion decrezcaa casi cero
theta <- c(0.6, -0.6, 0.95, 0.3)
lag <- c(10, 10, 20, 10)
for (i in seq_along(theta)) {
print(ARMAacf(ar = theta[i], lag.max = lag[i]))
}
## 0 1 2 3 4 5
## 1.000000000 0.600000000 0.360000000 0.216000000 0.129600000 0.077760000
## 6 7 8 9 10
## 0.046656000 0.027993600 0.016796160 0.010077696 0.006046618
## 0 1 2 3 4
## 1.000000000 -0.600000000 0.360000000 -0.216000000 0.129600000
## 5 6 7 8 9
## -0.077760000 0.046656000 -0.027993600 0.016796160 -0.010077696
## 10
## 0.006046618
## 0 1 2 3 4 5 6
## 1.0000000 0.9500000 0.9025000 0.8573750 0.8145062 0.7737809 0.7350919
## 7 8 9 10 11 12 13
## 0.6983373 0.6634204 0.6302494 0.5987369 0.5688001 0.5403601 0.5133421
## 14 15 16 17 18 19 20
## 0.4876750 0.4632912 0.4401267 0.4181203 0.3972143 0.3773536 0.3584859
## 0 1 2 3 4 5
## 1.0000e+00 3.0000e-01 9.0000e-02 2.7000e-02 8.1000e-03 2.4300e-03
## 6 7 8 9 10
## 7.2900e-04 2.1870e-04 6.5610e-05 1.9683e-05 5.9049e-06
par(mfrow=c(2,2))
Ar1 <- ARMAacf(ma=0.6, lag.max = 10)
plot(y=Ar1[-3], x=1:10, type="h");abline(h=0)
Ar1 <- ARMAacf(ma=-0.6, lag.max = 10)
plot(y=Ar1[-3], x=1:10, type="h");abline(h=0)
Ar1 <- ARMAacf(ma=0.95, lag.max = 20)
plot(y=Ar1[-1], x=1:20, type="h");abline(h=0)
Ar1 <- ARMAacf(ma=0.3, lag.max = 10)
plot(y=Ar1[-3], x=1:10, type="h");abline(h=0)
Describa las caracteristicas generales de la funcion para los siguientes procesos:
Usar la formula recursiva $_k= 1 {k-1}+2 {k-2} $ (ecuacion Yule-Walker) para calcular y gra???car las funciones de autocorrelacion para los siguientes procesos AR(2) con los parametros especi???cados. En cada caso especi???que si las raices de la ecuacion caracteristica son reales o complejas.
\[ \begin{split} \rho_1 & = 0.6\rho_0 + 0.3\rho{-1} = 0.6 + 0.3\rho_1 = 0.8571 \\ \rho_2 & = 0.6\rho_1+0.3\rho_0 = 0.81426\\ \rho_3 & = 0.6\rho_2 + 0.3\rho_1 = 0.7457 \end{split} \]
$$ = = -1 2.0817 = {1.0817, -3.0817}.
$$
ar2solver <- function(phi1, phi2) {
roots <- polyroot(c(1, -phi1, -phi2))
cat("Roots:\t\t", roots, "\n")
if (any(Im(roots) > sqrt(.Machine$double.eps))) {
damp <- sqrt(-phi2)
freq <- acos(phi1 / (2 * damp))
cat("Dampening:\t", damp, "\n")
cat("Frequency:\t", freq, "\n")
}
ARMAacf(ar = c(phi1, phi2))
}
ar2solver(-0.4, 0.5)
## Roots: -1.069694+0i 1.869694-0i
## 0 1 2
## 1.00 -0.80 0.82
ar2solver(0.6, 0.3)
## Roots: 1.081666-0i -3.081666+0i
## 0 1 2
## 1.0000000 0.8571429 0.8142857
AR(2) \(\phi_1= 0.6 , \phi_2= 0.3\)
ar2solver(-0.4, 0.5)
## Roots: -1.069694+0i 1.869694-0i
## 0 1 2
## 1.00 -0.80 0.82
AR(2) \(\phi_1= -0.4 , \phi_2= 0.5\)
ar2solver(1.2, -0.7)
## Roots: 0.8571429+0.8329931i 0.8571429-0.8329931i
## Dampening: 0.83666
## Frequency: 0.7711105
## 0 1 2
## 1.0000000 0.7058824 0.1470588
AR(2) \(\phi_1= 1.2 , \phi_2= -0.7\)
ar2solver(-1, -0.6)
## Roots: -0.8333333+0.9860133i -0.8333333-0.9860133i
## Dampening: 0.7745967
## Frequency: 2.27247
## 0 1 2
## 1.000 -0.625 0.025
AR(2) \(\phi_1= -1 , \phi_2= -0.6\)
ar2solver(0.5, -0.9)
## Roots: 0.277778+1.016834i 0.277778-1.016834i
## Dampening: 0.9486833
## Frequency: 1.304124
## 0 1 2
## 1.0000000 0.2631579 -0.7684211
AR(2) \(\phi_1= 0.5 , \phi_2= -0.9\)
ar2solver(0.5, -0.6)
## Roots: 0.416667+1.221907i 0.416667-1.221907i
## Dampening: 0.7745967
## Frequency: 1.242164
## 0 1 2
## 1.00000 0.31250 -0.44375
AR(2) \(\phi_1= 0.5 , \phi_2= -0.6\)
Gra???car las funciones de autocorrelacion para cada uno de los siguientes procesos ARMA:
ARMA(1,1) con \(\phi=0.7\) y \(\theta=-0.4\)
AR(2) \(\phi_1= 0.7 , \theta= -0.4\)
ARMA(1,1) con \(\phi=0.7\) y \(\theta =0.4\)
AR(2) \(\phi_1= 0.7 , \theta= 0.4\)
Considere dos procesos MA(2), uno con \(\theta_1= \theta_2 = -\frac{1}{6}\) y otro con \(\theta_1=1\) y \(\theta_2=6\)
Mostrar que estos procesos tienen la misma funcion de autocorrelacion
Para \(\theta_1 = \theta_2 =-\frac{1}{6}\)
\[ \rho_k = \frac{-\frac{1}{6}+\frac{1}{6}\times\frac{1}{6}}{1 + \left(\frac{1}{6}\right)^2 + \left(\frac{1}{6}\right)^2} = \frac{\frac{1}{6}\left(\frac{1}{6}-1\right)}{1 + \frac{2}{36}} = - \frac{5}{38}. \]
Y para \(\theta_1=1\) y \(\theta_2=6\)
\[ \rho_k = \frac{1-6}{1+1^2+36} = - \frac{5}{38} \tag*{$\square$}. \]
¿Como se comparan las raices de los polinomios caracteristicos?
Para \(\theta_1= \theta_2 = -\frac{1}{6}\)
\[ \frac{\frac{1}{6} \pm \sqrt{\frac{1}{36}+ 4 \times \frac{1}{6}}}{-2\times \frac{1}{6}} = - \frac{1}{2} \pm \frac{\sqrt{\frac{25}{36}}}{-\frac{1}{3}} = - \frac{1}{2} \pm \frac{\frac{5}{6}}{\frac{1}{3}} = \{-3, -2\} \]
Y para \(\theta_1=1\) y \(\theta_2=6\)
\[ \frac{-1 \pm \sqrt{1 + 4 \times 6}}{-2\times6} = \frac{-1\pm 5}{-12} = \frac{1}{12} \pm \frac{5}{12} = \left\{-\frac{1}{3}, \frac{1}{2}\right\} \]
Considere un proceso AR(1)\(Y_t=Y_{t-1}+ e_t\) Mostrar que si \(\phi=1\) el proceso no puede ser estacionario.
Considere un proceso MA(6) \(\theta_1 =0.5,\theta_2= -0.25, \theta_3= 0.125, \theta_4=-0.0625, \theta_5= 0.03125, \theta_6 -0.0015625\)
ARMAacf(ar = -0.5, lag.max = 7)
## 0 1 2 3 4 5
## 1.0000000 -0.5000000 0.2500000 -0.1250000 0.0625000 -0.0312500
## 6 7
## 0.0156250 -0.0078125
ARMAacf(ma = -c(0.5, -0.25, 0.125, -0.0625, 0.03125, -0.0015625))
## 0 1 2 3 4
## 1.000000000 -0.499669415 0.249157053 -0.123223218 0.058900991
## 5 6 7
## -0.024029260 0.001172159 0.000000000
\[ \begin{cases} \psi_1 = \phi - \theta = 1\\ \psi_2 = (\phi - \theta)\phi = -0.5 \end{cases} \]
\[ \begin{cases} \theta = 0.5\\ \phi = -0.5 \end{cases} \]
ARMAacf(ma = -c(1, -0.5, 0.25, -0.125, 0.0625, -0.03125, 0.015625))
## 0 1 2 3 4
## 1.000000000 -0.714240871 0.357015800 -0.178298629 0.088730773
## 5 6 7 8
## -0.043528304 0.020089986 -0.006696662 0.000000000
ARMAacf(ar = -0.5, ma = -0.5, lag.max = 8)
## 0 1 2 3 4
## 1.000000000 -0.714285714 0.357142857 -0.178571429 0.089285714
## 5 6 7 8
## -0.044642857 0.022321429 -0.011160714 0.005580357