ENMeval icon indicating copy to clipboard operation
ENMeval copied to clipboard

cbi.val.avg not computed for jackknife models

Open forianfinest opened this issue 1 year ago • 3 comments

Hello everybody, as written in the object, I tried to run models with jackknife partition and, while cbi.train values were outputted, cbi.val.avg were not. Is it a feature of ENMeval? Or am I getting something wrong? I tried to search online, with no avail. This is the script I used, with legacy commands:

maxit_arandisa <- ENMevaluate(occ = sp, envs = stack, bg = bg, algorithm = 'maxent.jar', fc=c('L','LQ','LP','QP','LQP','LQH','QH','H','QT','LQPT','LQHPT'), partitions = "jackknife", RMvalues =c(0.25,0.5,0.75,1,1.25,1.5,1.75,2,2.25,2.5,2.75,3,3.25,3.5,3.75,4,4.25,4.5,4.75,5), clamp = TRUE, rasterPreds = NULL, parallel = FALSE, numCores = 16, progbar = TRUE, updateProgress = TRUE)

Thank you in advance for the answer and sorry for the bother.

Best wishes, Mattia

forianfinest avatar Dec 06 '23 15:12 forianfinest

Mattia, thanks for using the pkg, and sorry for the late reply. I wonder how many occurrences you have. Jackknife partitioning should be used only for very small datasets (like under 20 or so). CBI sometimes fails to calculate if the training model has weird input data. I could never pin down why exactly, but it's finicky for some reason. From my experience, this usually occurs for larger partitions and not jackknife because large withheld datasets mean the training data is missing a lot of information and the model predictions might be strange, which may cause CBI to bug. Sorry I cannot provide a better answer. Perhaps you can try using the CBI functionality in the enmSdm pkg? You can insert it as a custom metric (see the vignette). This might work better than the ecospat implementation. Please let me know what you find.

BTW - you can specify that sequence of RMs with this: seq(0.25, 5, 0.25) BTW2 - don't name variables the same names as function names (like "stack"), because that can screw up your code when you want to use the function again

jamiemkass avatar Jan 25 '24 02:01 jamiemkass

Hi Jamie, thank you very much for your detailed answer and suggestions! I have precisely 15 occurence points, so I would suppose that jackknife should be used. However, I also made the model in a pretty large area [-23.98502, 64.00496, -36.02244, 44.01745 (xmin, xmax, ymin, ymax)] and my points are actually localized in a specific zone. I would suppose that it could cause issues. I run my analyses in a server, I will use enmSdm and let you know! Thank you again! Best wishes, Mattia

forianfinest avatar Jan 25 '24 07:01 forianfinest

Hi Jamie, I tried to insert the CBI from enmSdmx (not enmSdm, given that the latter package was seemingly retired in the favor of the former), but I still got NA. I am noy sure if I made a mistake in writing the formula:

cbi_other <- function(vars) { cbi_other <- enmSdmX::evalContBoyce(vars$occs.val.pred, vars$bg.val.pred) out <- data.frame(cbi_ensdmx = cbi_other, row.names = NULL) return(out) }

pls_arandisa <- ENMevaluate(occ = arasp, envs = enmstack, bg = bg, algorithm = 'maxent.jar', fc=c('L','LQ','LP','QP','LQP','LQH','QH','H','QT','LQPT','LQHPT'), partitions = "jackknife", user.eval = cbi_other, RMvalues =seq(0.25, 5, 0.25), clamp = TRUE, rasterPreds = NULL, parallel = FALSE, numCores = 16, progbar = TRUE, updateProgress = TRUE)

In case I did not, I would suppose that my presence points are way too concentrated in a single area of the raster stack and I am projecting a distribution in a way too large region.

In case the script I wrote is right, I think we can close the issue.

Best wishes, Mattia

forianfinest avatar Jan 31 '24 09:01 forianfinest

Closed this issue for now, but please reopen if another problem emerges.

jamiemkass avatar Jun 14 '24 09:06 jamiemkass