Thank you for your previous suggestions. For the time being, I have been running cross-validation over the nodes containing data only (i.e. the first 5 [out of 6 total] replicate surveys during each season). This at least gives results. Do you also have an update on what the Development Team suggests for running cross-validation on models with datasets containing NAs in the dependent variable(s)?
On a different note, for a dynamic N-occupancy model (i.e. including sub-models for occupancy and abundance and associated measurement errors for y_occ ~ dbern(psi) and y_abund ~ dbin(N, p) input dependent data), is runCrossValidate( ) able to generate performance scores from a loss function on
two processes, both occupancy and abundance? Specifically, this would yield an RMSE for the occupancy process as well as one for the abundance process.
To do so, I have been experimenting with the following code:#Cross-validate model results
commNocc_FoldFunction <- function(i){
foldNodes_i <- c(paste0('Yc_abund[', i,', , , ]'), paste0('Yc_occ[', i,', , , ]')) # will return 'y[1,,,]' for i = 1 (e.g., based on nsite)
##foldNodes_i <- c(paste0('Yc_occ[', i,', , , ]'), paste0('Yc_abund[', i,', , , ]')) # changing the order because the measurement error process for Yc_abund appears first in modelCode
return(foldNodes_i)
}
# The function below computes the root mean squared error
######### Here is where I exclude the 6th replicate surveys#########
win.data$Yc_abund <- win.data$Yc_abund[,,,1:5]
win.data$Yc_occ <- win.data$Yc_occ[,,,1:5]
const$nrep <- dim(win.data$Yc_abund)[[4]]
#####################################################
model <- nimbleModel(code = modelCode, name = "modelCode",
constants = const, data = win.data,
inits = init)
Cmodel <- compileNimble(model)
modelConf <- configureMCMC(model)
cvSamples <- runCrossValidate(MCMCconfiguration = modelConf,
k = 5, foldFunction = commNocc_FoldFunction,
lossFunction = RMSE_lossFunction,
MCMCcontrol = list(niter = ni, nburnin = nb))
I have also received some puzzling errors from runCrossValidate( ), errors suggesting missing quotations, parentheses, or curly braces, such as:
Error: unexpected '}' in:
" SSE <-
}"
orError: object 'SSE' not found
orError: unexpected '}' in: