Hi all,
I'm fitting an integrated distance model with distance point counts and normal point counts without distance information using the IDS() function. Now I would like to assess the GOF of the model. However, when I tried to adapt the function and use parboot(), I get the below error. Anyone could help to adapt properly the function to be used with parboot()?
Error: assignment of an object of class “list” is not valid for @‘y’ in an object of class “unmarkedFrameDS”; is(value, "matrix") is not TRUE
My code is:
modIDS <- IDS(
lambdaformula = fPC1,
# detformulaPC = ~1,
dataDS = umfDS,
dataPC = umfPC,
availformula = ~1,
durationDS = umfDS@siteCovs$dur_min,
durationPC = umfPC@obsCovs$dur_min,
maxDistPC = 0.5,
keyfun = "exp",
unitsOut = "kmsq"
)
fitstatsIDS <- function(modIDS) {
observedDS <- getY(fm@data)
expectedDS <- fitted(modIDS)$ds
residsDS <- residuals(modIDS)$ds
sseDS <- sum(residsDS^2, na.rm = TRUE)
chisqDS <- sum((observedDS - expectedDS)^2 / expectedDS, na.rm = TRUE)
freeTukeDS <- sum((sqrt(observedDS) - sqrt(expectedDS))^2, na.rm = TRUE)
observedPC <- getY(fm@dataPC)
expectedPC <- fitted(modIDS)$pc
residsPC <- residuals(modIDS)$pc
ssePC <- sum(residsPC^2, na.rm = TRUE)
chisqPC <- sum((observedPC - expectedPC)^2 / expectedPC, na.rm = TRUE)
freeTukePC <- sum((sqrt(observedPC) - sqrt(expectedPC))^2, na.rm = TRUE)
out <- c(
SSE_DS = sseDS,
Chisq_DS = chisqDS,
freemanTukey_DS = freeTukeDS,
SSE_PC = ssePC,
Chisq_PC = chisqPC,
freemanTukey_PC = freeTukePC
)
return(out)
}
(pbDS <- parboot(modIDS, fitstatsIDS, nsim = 10))
Best regards,
Juan