Page 1 of 1

Bug/Issue with par.secr.fit

PostPosted: Thu Apr 21, 2016 7:16 pm
by jnwaite
Hello,

I use the par.secr.fit function quite a bit and have run into a bit of a nuisance issue. Model specification errors are not caught or reported until the very end, and when they occur, the results of the models that do complete are not saved. For example, I might specify 3 models but accidentally misspell a covariate in one of them (the covariate on sigma in the third model, in this example):

Code: Select all
fitnm.bkTT.1 <- list(capthist="captHist", model=list(D~1, g0~bk+trapType, sigma~1), mask=mask2, hcov="sex", trace=TRUE, method="Nelder-Mead", control=list(maxit=1500))

fitnm.bkTTsex.1 <- list(capthist="captHist", model=list(D~1, g0~bk+trapType+h2, sigma~1), mask=mask2, hcov="sex", trace=TRUE, method="Nelder-Mead", control=list(maxit=1500))

fitnm.bkTT.TT <- list(capthist="captHist", model=list(D~1, g0~bk+trapType, sigma~traptype), mask=mask2, hcov="sex", trace=TRUE, method="Nelder-Mead", control=list(maxit=1500))

fits3 <- par.secr.fit(c("fitnm.bkTT.1", "fitnm.bkTTsex.1", "fitnm.bkTT.TT"), ncores=3)


Instead of immediately reporting the error and halting the process, the remaining two models continue to be processed, but upon completion, the following error is reported:

Code: Select all
[Error in checkForRemoteErrors(val) :
  one node produced an error: covariate(s) traptype not found


The "fits3" object that should have contained the results of the three models is not produced and the process must be started from the very beginning after the error is corrected. An ideal behavior would be either to first detect the error and halt the entire process from the very beginning, or to save the results of the models that do run to completion and simply report the error for the ones that do not.

Aside from being more diligent in checking my code before I run it, is there anything that can be done to retrieve the results from the models that do not produce errors?

Thanks!

Re: Bug/Issue with par.secr.fit

PostPosted: Thu Apr 21, 2016 7:28 pm
by murray.efford
I wouldn't have called that a bug, but I agree that it's not nice. I can imagine a pre-check option in par.secr.fit that merely evaluates the likelihood once for each model, and possibly error handling could be changed throughout secr.fit. Each of these might take more of my time than it would save of yours, and introduce more complexity, so I'm not really motivated. You could emulate the pre-check by including details= list (LLonly = TRUE) in each argument list. (I often use a list of 'base args' common to all models).
Murray