code:
for(j in 1:100){......
for(k in 1:20) {
fit.mod = fit(mod)
if(AIC(fit.mod) < best) { best_model = fit.mod
best = AIC(fit.mod)
}
fit.mod <- best_model
........}
when the error
Error in fb(init = init, A = trDens, B = dens, ntimes = ntimes(object), :
NA/NaN/Inf in foreign function call (arg 10)
occurs, the loop automatically stops. I tried
if(is.na(fit.mod)){next}
and
if(!identical(fit.mod@message,c("Log likelihood converged to within tol. (relative change)"))){next}
But the loop still stops. Is there a method where I can ignore this error and continue the loop? Thanks in advance!