for(i in 2:num_asset){
assetclass <- ts(mydt[,i])
tryCatch(
{
fit <- Arima(assetclass,order = c(2,0,2))
},
error = function(e){
fit <- auto.arima(assetclass)
k=i
}
)
fst <-as.data.frame(forecast(fit, h=52))
}
I want to run code above. But It doesn't work showing message below.
Error in forecast(fit, h = 52) : object 'fit' not found
My intention is ...
If there is an error in first function( fit <- Arima(assetclass,order = c(2,0,2))
) then, I'd like to run second function(fit <- auto.arima(assetclass)
)
How should I do?