Paginas web de donde se obtuvieron los códigos:
http://rstudio-pubs-static.s3.amazonaws.com/315820_40a5f5c5ff22451e856d608c59dd5f28.html
https://medium.com/analytics-vidhya/sarima-forecasting-seasonal-data-with-python-and-r-2e7472dfad83
Tasa_Desempleo <- readRDS("Tasa Desempleo Regional.rds")
Tasa_Desempleo[cae_general_red!= "Inactivos",Porcentaje := sum(Total), by = .(ano_trimestre,mes_central,region)]
TABLA <- Tasa_Desempleo[cae_general_red == "Cesantes" & region == params$reg, .(Porcentaje = Total/Porcentaje), by = .(ano_trimestre,mes_central)]
TABLA <- ts(TABLA$Porcentaje, start = c(2010,2), end = c(2020,1), frequency = 12)
hchart(TABLA, name = "TASA DE DESEMPLEO") %>%
hc_title(text = "holi", align = "left") %>%
hc_subtitle(text = "holi2", align = "left") %>%
hc_legend(verticalAlign = "top", align = "left", x = 40, y = 0)
## Warning: `as_data_frame()` is deprecated as of tibble 2.0.0.
## Please use `as_tibble()` instead.
## The signature and semantics have changed, see `?as_tibble`.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_warnings()` to see where this warning was generated.
hchart(acf(TABLA,lag.max = 120, plot = F))
## Warning: `data_frame()` is deprecated as of tibble 1.1.0.
## Please use `tibble()` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_warnings()` to see where this warning was generated.
hchart(pacf(TABLA,lag.max = 120, plot = F))
adf.test(TABLA)
##
## Augmented Dickey-Fuller Test
##
## data: TABLA
## Dickey-Fuller = -3.3427, Lag order = 4, p-value = 0.06746
## alternative hypothesis: stationary
z <- stl(TABLA,"per")
hchart(z)
fit1 <- auto.arima(TABLA)
checkresiduals(fit1)
##
## Ljung-Box test
##
## data: Residuals from ARIMA(0,1,0)(2,0,0)[12]
## Q* = 28.736, df = 22, p-value = 0.1525
##
## Model df: 2. Total lags used: 24
fit2 <- auto.arima(TABLA, stepwise = FALSE) # stepwise = FALSE to make auto.arima() work harder to find a good model from a larger collection of models
checkresiduals(fit2)
##
## Ljung-Box test
##
## data: Residuals from ARIMA(0,1,3)(2,0,0)[12]
## Q* = 13.36, df = 19, p-value = 0.8196
##
## Model df: 5. Total lags used: 24
fit3 <- auto.arima(TABLA, trace=F, test="kpss", ic="bic") # stepwise = FALSE to make auto.arima() work harder to find a good model from a larger collection of models
checkresiduals(fit3)
##
## Ljung-Box test
##
## data: Residuals from ARIMA(0,1,0)(1,0,0)[12]
## Q* = 32.556, df = 23, p-value = 0.08913
##
## Model df: 1. Total lags used: 24
x <- forecast(forecast(fit1,h=24))
hchart(x)
y <- forecast(forecast(fit2,h=24))
hchart(y)
w <- forecast(forecast(fit3,h=24))
hchart(w)