\[ Yt=5+e_t-\frac{1}{2}e_{t-1}+\frac{1}{4}e_{t-2}\\ E(Y_t)=0\\ Var(Y_t)=Var(5+e_t-\frac{1}{2}e_{t-1}+\frac{1}{4}e_{t-2})=[1+(\frac{1}{2})^2+(\frac{1}{4})^2]\sigma_e^2=\frac{21}{16}\sigma_e^2\\ Cov(Y_t, Y_{t-1})=Cov(e_t-\frac{1}{2}e_{t-1}+\frac{1}{4}e_{t-2}, e_{t-1}-\frac{1}{2}e_{t-2}+\frac{1}{4}e_{t-3})=Cov(-\frac{1}{2}e_{t-1}+\frac{1}{4}e_{t-2}, e_{t-1}-\frac{1}{2}e_{t-2})\\ =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}(\frac{1}{4})-\frac{1}{2}]\sigma_e^2=-\frac{5}{8}\sigma_e^2\\ Cov(Y_t, Y_{t-2})=Cov(e_t-\frac{1}{2}e_{t-1}+\frac{1}{4}e_{t-2}, e_{t-2}-\frac{1}{2}e_{t-3}+\frac{1}{4}e_{t-4})=Cov(\frac{1}{4}e_{t-2}, e_{t-2})=\frac{1}{4}\sigma_e^2\\ Corr(Y_t, Y_{t-k})=\rho_k=\frac{Cov(Y_t, Y_{t-k})}{\sqrt{Var (Y_t)}\sqrt{Var(Y_{t-k})}}\\ \rho_k= 1 K=0\\ \rho_k= -\frac{10}{21} K=1\\ \rho_k= \frac{4}{21} K=2\\ \rho_k= 0 K>0\\ \] ## 2. Graficar la función de autocorrelación para los siguientes modelos MA(2) con los parámetros especificados:
library(TSA)
##
## Attaching package: 'TSA'
## The following objects are masked from 'package:stats':
##
## acf, arima
## The following object is masked from 'package:utils':
##
## tar
library(forecast)
ma2 <- arima.sim(model = list(ma= c(-0.5, -0.4)), n=120)
autoplot(ma2, type="o", main="MA(2); theta1= -0.5, theta2= -0.4")
ARMAacf(ma=list(-0.5, -0.4))
## 0 1 2 3
## 1.0000000 -0.2127660 -0.2836879 0.0000000
ma2 <- arima.sim(model = list(ma= c(-1.2, 0.7)), n=120)
autoplot(ma2, type="o", main="MA(2); theta1= -1.2, theta2= 0.7")
ARMAacf(ma=list(-1.2, 0.7))
## 0 1 2 3
## 1.0000000 -0.6962457 0.2389078 0.0000000
ma2 <- arima.sim(model = list(ma= c(1, 0.6)), n=120)
autoplot(ma2, type="o", main="MA(2); theta1= 1, theta2= 0.6")
ARMAacf(ma=list(1, 0.6))
## 0 1 2 3
## 1.0000000 0.6779661 0.2542373 0.0000000
\[ \frac{-\frac{1}{\theta}}{1+(\frac{1}{\theta})^{2}}=\frac{-\theta}{1+{\theta}^2} \]
par(mfrow=c(2,2))
ACF1 <- ARMAacf(ar=0.6,lag.max=12)
ACF2 <- ARMAacf(ar=-0.6,lag.max=12)
ACF3 <- ARMAacf(ar=0.95,lag.max=20)
ACF4 <- ARMAacf(ar=0.3,lag.max=12)
plot(y=ACF1[-1],x=1:12,main='phi=0.6',xlab='Lag',ylab='ACF',type='h'); abline(h=0)
plot(y=ACF2[-1],x=1:12,main='phi=-0.6',xlab='Lag',ylab='ACF',type='h'); abline(h=0)
plot(y=ACF3[-1],x=1:20,main='phi=0.95',xlab='Lag',ylab='ACF',type='h'); abline(h=0)
plot(y=ACF4[-1],x=1:12,main='phi=0.3',xlab='Lag',ylab='ACF',type='h'); abline(h=0)
MA(1): Correlación distinta de cero en el rezago 1. Pueder ser positivo o negativo, debe estar entre -0.5 y 0.5.
MA(2): Correlación distinta de cero, en los rezagos 1 y 2.
AR(1): Autocorrelaciones en descomposición exponencial a partir del rezago 0. Si phi<0, entonces las autocorrelaciones son positivas.
AR(2): Las autocorrelaciones pueden tener varios patrones, pero si las raíces de la ecuación característica son números complejos.
ARMA (1,1): Autocorrelaciones en despcomposición exponencial a partir del rezago 1, pero no desde el rezago 0.
rho=NULL; phi1=0.6; phi2=0.3; max.lag=20
rho1=phi1/(1-phi2); rho2=(phi2*(1-phi2)+phi1^2)/(1-phi2)
rho[1]=rho1; rho[2]=rho2
for (k in 3:max.lag) rho[k]=phi1*rho[k-1]+phi2*rho[k-2]
rho
## [1] 0.8571429 0.8142857 0.7457143 0.6917143 0.6387429 0.5907600 0.5460789
## [8] 0.5048753 0.4667488 0.4315119 0.3989318 0.3688126 0.3409671 0.3152241
## [15] 0.2914246 0.2694220 0.2490806 0.2302749 0.2128891 0.1968159
plot(y=rho,x=1:max.lag,type='h',ylab='ACF',xlab='Lag',ylim=c(-1,+1)); abline(h=0)
polyroot(c(1,-phi1,-phi2))
## [1] 1.081666-0i -3.081666+0i
Las raíces son reales , una raíz está muy cerca del límite de estacionariedad (1). Esto explica la lentitud.
rho=NULL; phi1=-0.4; phi2=0.5; max.lag=20
rho1=phi1/(1-phi2); rho2=(phi2*(1-phi2)+phi1^2)/(1-phi2)
rho[1]=rho1; rho[2]=rho2
for (k in 3:max.lag) rho[k]=phi1*rho[k-1]+phi2*rho[k-2]
rho
## [1] -0.8000000 0.8200000 -0.7280000 0.7012000 -0.6444800 0.6083920
## [7] -0.5655968 0.5304347 -0.4949723 0.4632063 -0.4327687 0.4047106
## [13] -0.3782686 0.3536627 -0.3305994 0.3090711 -0.2889281 0.2701068
## [19] -0.2525068 0.2360561
plot(y=rho,x=1:max.lag,type='h',ylab='ACF',xlab='Lag',ylim=c(-1,+1)); abline(h=0)
polyroot(c(1,-phi1,-phi2))
## [1] -1.069694+0i 1.869694-0i
rho=NULL; phi1=1.2; phi2=-0.7; max.lag=20
rho1=phi1/(1-phi2); rho2=(phi2*(1-phi2)+phi1^2)/(1-phi2)
rho[1]=rho1; rho[2]=rho2
for (k in 3:max.lag) rho[k]=phi1*rho[k-1]+phi2*rho[k-2]
rho
## [1] 0.70588235 0.14705882 -0.31764706 -0.48411765 -0.35858824
## [6] -0.09142353 0.14130353 0.23356071 0.18136038 0.05413996
## [11] -0.06198431 -0.11227915 -0.09134596 -0.03101975 0.02671848
## [16] 0.05377599 0.04582826 0.01735071 -0.01125892 -0.02565621
plot(y=rho,x=1:max.lag,type='h',ylab='ACF',xlab='Lag',ylim=c(-1,+1)); abline(h=0)
polyroot(c(1,-phi1,-phi2))
## [1] 0.8571429+0.8329931i 0.8571429-0.8329931i
Las raíces son complejas, por lo tanto
Damp = sqrt(-phi2)
Freq = acos(phi1/(2*Damp))
Phase = atan((1-phi2)/(1+phi2))
Damp; Freq; Phase
## [1] 0.83666
## [1] 0.7711105
## [1] 1.396124
rho=NULL; phi1=-1; phi2=-0.6; max.lag=20
rho1=phi1/(1-phi2); rho2=(phi2*(1-phi2)+phi1^2)/(1-phi2)
rho[1]=rho1; rho[2]=rho2
for (k in 3:max.lag) rho[k]=phi1*rho[k-1]+phi2*rho[k-2]
rho
## [1] -0.6250000000 0.0250000000 0.3500000000 -0.3650000000 0.1550000000
## [6] 0.0640000000 -0.1570000000 0.1186000000 -0.0244000000 -0.0467600000
## [11] 0.0614000000 -0.0333440000 -0.0034960000 0.0235024000 -0.0214048000
## [16] 0.0073033600 0.0055395200 -0.0099215360 0.0065978240 -0.0006449024
plot(y=rho,x=1:max.lag,type='h',ylab='ACF',xlab='Lag',ylim=c(-1,+1)); abline(h=0)
polyroot(c(1,-phi1,-phi2))
## [1] -0.8333333+0.9860133i -0.8333333-0.9860133i
Las raíces son complejas, por lo tanto
Damp = sqrt(-phi2)
Freq = acos(phi1/(2*Damp))
Phase = atan((1-phi2)/(1+phi2))
Damp; Freq; Phase
## [1] 0.7745967
## [1] 2.27247
## [1] 1.325818
rho=NULL; phi1=0.5; phi2=-0.9; max.lag=20
rho1=phi1/(1-phi2); rho2=(phi2*(1-phi2)+phi1^2)/(1-phi2)
rho[1]=rho1; rho[2]=rho2
for (k in 3:max.lag) rho[k]=phi1*rho[k-1]+phi2*rho[k-2]
rho
## [1] 0.26315789 -0.76842105 -0.62105263 0.38105263 0.74947368
## [6] 0.03178947 -0.65863158 -0.35792632 0.41380526 0.52903632
## [11] -0.10790658 -0.53008597 -0.16792707 0.39311384 0.34769128
## [16] -0.17995682 -0.40290056 -0.03948914 0.34286593 0.20697320
plot(y=rho,x=1:max.lag,type='h',ylab='ACF',xlab='Lag',ylim=c(-1,+1)); abline(h=0)
polyroot(c(1,-phi1,-phi2))
## [1] 0.277778+1.016834i 0.277778-1.016834i
Las raíces son complejas, por lo tanto
Damp = sqrt(-phi2)
Freq = acos(phi1/(2*Damp))
Phase = atan((1-phi2)/(1+phi2))
Damp; Freq; Phase
## [1] 0.9486833
## [1] 1.304124
## [1] 1.518213
rho=NULL; phi1=-0.5; phi2=-0.6; max.lag=20
rho1=phi1/(1-phi2); rho2=(phi2*(1-phi2)+phi1^2)/(1-phi2)
rho[1]=rho1; rho[2]=rho2
for (k in 3:max.lag) rho[k]=phi1*rho[k-1]+phi2*rho[k-2]
rho
## [1] -0.3125000000 -0.4437500000 0.4093750000 0.0615625000 -0.2764062500
## [6] 0.1012656250 0.1152109375 -0.1183648437 -0.0099441406 0.0759909766
## [11] -0.0320290039 -0.0295800840 0.0340074443 0.0007443282 -0.0207766307
## [16] 0.0099417184 0.0074951192 -0.0097125907 0.0003592238 0.0056479425
plot(y=rho,x=1:max.lag,type='h',ylab='ACF',xlab='Lag',ylim=c(-1,+1)); abline(h=0)
polyroot(c(1,-phi1,-phi2))
## [1] -0.416667+1.221907i -0.416667-1.221907i
Las raíces son complejas, por lo tanto
Damp = sqrt(-phi2)
Freq = acos(phi1/(2*Damp))
Phase = atan((1-phi2)/(1+phi2))
Damp; Freq; Phase
## [1] 0.7745967
## [1] 1.899428
## [1] 1.325818
ACF=ARMAacf(ar=0.7,ma=-0.4,lag.max=20)
plot(y=ACF[-1],x=1:20,xlab='Lag',ylab='ACF',type='h'); abline(h=0)
ACF=ARMAacf(ar=0.7,ma=0.4,lag.max=20)
plot(y=ACF[-1],x=1:20,xlab='Lag',ylab='ACF',type='h'); abline(h=0)
ARMAacf(ma=c(-1/6,-1/6))
## 0 1 2 3
## 1.0000000 -0.1315789 -0.1578947 0.0000000
ARMAacf(ma=c(1,-6))
## 0 1 2 3
## 1.0000000 -0.1315789 -0.1578947 0.0000000
Tenemos en cuenta
\[ 1-\frac{1}{6}x-\frac{1}{6}x^2=-\frac{1}{6}(x+3)(x-2)\\ \\ 1+x-6x^2=-6(x+\frac{1}{3})(x-\frac{1}{2}) \] Las raíces de los polinomios son recíprocos el uno del otro. Sólo el modelo MA(2) con theta1=theta2=-1/6 es invertible.
Supongamos que (Yt) es estacionario. Entonces
\[ Var(Y_t)=\phi^2Var(Y_{t-1})+\sigma_e^2/1+\phi^2 \] si |phi|=1 esto es imposible y tenemos una prueba por contradicción.
Los coeficientes disminuyen exponencialmente en magnitud a una tasa de 0.5 mientras alternan en el signo. En tetha6 los coeficientes casi han desaparecido. Un proceso AR(1) con phi=-0.5 sería el modelo más simple.