Professional Documents
Culture Documents
library(WriteXLS)
library(uroot)
library(tidyr)
library(tidyverse)
library(lubridate)
library(forecast)
library(dplyr)
library(data.table)
Base <- unite(Servicios,Clave,c(2:6), sep = ";",remove = TRUE) %>%
data.frame() %>%
spread(Clave,Servicios)
myts
?auto.arima
pl <- autoplot(myts)
pl
M <- 24
PREFCST.list2<- list()
PREFCST.list <- list()
FCSTF <- list()
FCST.list <- list()
for (j in 1:ncol(myts)) {
ifelse(is.na(myts[,j][[nrow(myts)]]),
FCSTF[[j]] <- rep(c(0),M),
ifelse(myts[,j][[nrow(myts)]] <= 5 || myts[,j][[nrow(myts)]] > sum( myts[,j]
[[nrow(myts)-3]] + myts[,j][[nrow(myts)-2]] + myts[,j][[nrow(myts)-1]], na.rm =
TRUE) ,
FCSTF[[j]] <- rep(c(myts[,j][[nrow(myts)]]),M),
{
automatic.services <-auto.arima(myts[,j],test = "adf", ic ="aicc")
PREFCST.list[[j]]<- forecast(automatic.services,M, level = c(99.5))
PREFCST<- c(PREFCST.list[[j]]$mean)
ifelse ( (PREFCST[M]) < 0,
{
automatic.services <-auto.arima(myts[,j],stationary = TRUE)
PREFCST.list2[[j]] <- forecast(automatic.services,M, level = c(99.5))
PREFCST2<- c(PREFCST.list2[[j]]$mean)
ifelse ( (PREFCST2[M]) < 0,
{
automatic.services <-auto.arima(myts[,j], approximation = TRUE)
FCST.list[[j]] <- forecast(automatic.services,M, level = c(99.5))
FCSTF[[j]]<- c(FCST.list[[j]]$mean)},
{
automatic.services <-auto.arima(myts[,j],stationary = TRUE)
FCST.list[[j]] <- forecast(automatic.services,M, level = c(99.5))
FCSTF[[j]] <- c(FCST.list[[j]]$mean)})},
{
automatic.services <-auto.arima(myts[,j],test = "adf", ic ="aicc")
FCST.list[[j]] <- forecast(automatic.services,M, level = c(99.5))
FCSTF[[j]] <- c(FCST.list[[j]]$mean)})}))
print(j)
}
Forecast Diario
library(readxl)
Servicios <- read_excel("C:\\Users\\jogarzon\\OneDrive - IKE ASISTENCIA COLOMBIA
S.A\\Forecast\\Mexico\\Diario\\Rewards Real.xlsx",
col_types = c("date", "text", "text", "numeric"))
library(astsa)
library(stats)
library(WriteXLS)
library(uroot)
library(tidyr)
library(tidyverse)
library(lubridate)
library(forecast)
library(dplyr)
library(data.table)
?auto.arima
pl <- autoplot(myts)
pl
#revisar esta funcion approximation = TRUE
##auto.arima(y = myts, ic = c("aic"), test = "adf", seasonal.test = "ch", start.p =
2, start.q = 2, start.P = 1, start.Q = 1, max.order = 5)
#parallel = TRUE,stepwise = FALSE,num.cores =4
Arima <- auto.arima(myts, trace = TRUE)
summary(Arima)
FCST <- forecast(Arima,334,level = c(99.5))
Y<-bind_cols(FCST$mean,X$pred,REAL,seq(as.Date("2021/02/01"), by = "day",
length.out = 334)) %>%
data.frame() %>% `names<-`(names) %>%
gather(key= "Modelo",value = "Llamadas",1:3)
names<- c("ARIMA","SARIMA","REAL","Fecha")
autoplot(FCST)
Transponer
Sub Transponer()
n = Cells(1, 1).CurrentRegion.Rows.Count
m = Cells(1, 1).CurrentRegion.Columns.Count
Application.ScreenUpdating = False
For j = 2 To t
Cells(2, bd + j).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Cut
Cells(2, bd + 1).Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Activate
ActiveSheet.Paste
Next
'rotulos
For k = 1 To t
For jj = 1 To n - 1
Cells(1 + ((n - 1) * (k - 1)) + jj, bd + 2) = Cells(1, bd + k)
Next
Next
Cells(1, bd + 1).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.ClearContents
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
With Selection.Font
.ColorIndex = xlAutomatic
.TintAndShade = 0
End With
Range("A1").Select
Selection.Copy
Cells(1, bd + 1).Select
ActiveSheet.Paste
Cells(1, bd + 2).Select
ActiveSheet.Paste
Application.CutCopyMode = False
Cells(1, bd + 1) = "Servicios"
Cells(1, bd + 2) = "Mes"
End Sub