uu <- "https://raw.githubusercontent.com/vmoprojs/DataLectures/master/CAEMP.DAT"
datos = read.csv(url(uu),sep=",",header=T)
d2s = ts(datos,st=1962,frequency = 4)
plot(d2s)
interpretar.- La serie no es estacionaria por que tiene tendencia
acf(d2s)
library(tseries)
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
adf.test(d2s)
##
## Augmented Dickey-Fuller Test
##
## data: d2s
## Dickey-Fuller = -2.6391, Lag order = 5, p-value = 0.3106
## alternative hypothesis: stationary
basado en la prueba dickey fuller la serie no es estacionaria, ademas la funcion de autocorrelacion muestra un desenso suave en los 12 primeros rezagos.
d2sd=diff(d2s)
acf(d2sd)
adf.test(d2sd)
## Warning in adf.test(d2sd): p-value smaller than printed p-value
##
## Augmented Dickey-Fuller Test
##
## data: d2sd
## Dickey-Fuller = -4.0972, Lag order = 5, p-value = 0.01
## alternative hypothesis: stationary
interpretacion MA2 el p valor de la prueba de dickey fuller indica que la serie es estacionaria por que este es menor que alfa 0.05
acf(d2sd)
pacf(d2sd)
m1=arima(d2s,order = c(0,1,2))
m1$aic
## [1] 488.5535
m2=arima(d2s,order = c(1,1,0))
m2$aic
## [1] 485.4119
m3=arima(d2s,order = c(1,1,2))
m3$aic
## [1] 489.1799
De los tres modelos presentes se escoge el que represente el valor mas bajo del indicador de AIC en este caso el modelo 2 (aic=485.41)
d2sp=predict(m2,3)
d2sp
## $pred
## Qtr1 Qtr2 Qtr3
## 1996 92.17202 92.24426 92.27748
##
## $se
## Qtr1 Qtr2 Qtr3
## 1996 1.437907 2.544385 3.499883
str(d2s)
## Time-Series [1:136, 1] from 1962 to 1996: 83.1 82.8 84.6 85.4 86.2 ...
## - attr(*, "dimnames")=List of 2
## ..$ : NULL
## ..$ : chr "caemp"
inicio=1962.
final=1996.5
fecha=seq(inicio,final,by=0.25)
desempleo=rbind(d2s,d2sp)
## Warning in rbind(d2s, d2sp): number of columns of result is not a multiple of
## vector length (arg 2)
data=rbind(rep("real",136),rep("pronostico",3))
## Warning in rbind(rep("real", 136), rep("pronostico", 3)): number of columns of
## result is not a multiple of vector length (arg 2)
#datosd=data.frame(fecha,desempleo,data)