Hi I am using the following code to generate the best model, and when it is running the following error appears
Error: $ operator is invalid for atomic vectors
I have read several solcuines, but I have not found one that works for me
the code is:
getSymbols("CPIAUCNS",src = "FRED")
IPC = CPIAUCNS["2001-01::2019-12"]
y = IPC$CPIAUCNS
FuerzaUniversal <- function(datos, valores)
{
require(doParallel)
co_cores <- (detectCores() - 1)
cl <- makeCluster(co_cores)
registerDoParallel(cl)
y = datos
primeravuelta = FALSE
primeravuelta = FALSE
for (order_x in 0:2){
for (order_y in 0:2){
for (order_z in 0:2){
for (periodo in 12:12){
for (seansonal_x in 0:2){
for (seansonal_y in 0:2){
for (seansonal_z in 0:2){
actual = tryCatch(arima(datos,order=c(order_x,order_y,order_z),seasonal=list(order=c(seansonal_x,seansonal_y,order_z),period=periodo)),error = function(err)FALSE)
if (!is.logical(actual))
print(c(order_x,order_y,order_z,seansonal_x,seansonal_y,seansonal_z,periodo,actual$aic))
if (primeravuelta == FALSE){
primeravuelta = TRUE
menor <- actual$aic
aOK <- order_x
bOK <- order_y
cOK = order_z
xOK <- seansonal_x
yOK <- seansonal_y
zOK <- seansonal_z
period = periodo
}
if (actual$aic < menor){
menor = actual$aic
aOK <- order_x
bOK <- order_y
cOK = order_z
xOK <- seansonal_x
yOK <- seansonal_y
zOK <- seansonal_z
period = periodo
}
}
}
}
}
}
}
}
stopCluster(cl)
coordenadas <- c(aOK,bOK,cOK,xOK,yOK,zOK,periodo,menor)
}
y = y
c= FuerzaUniversal(y)
can you help me how to solve this error
The function of the code is to find the best sarima model obtaining the AIC and obtaining the least of them to publish the best model of all possible combinations