Problems to assess the Goodness of fit in R&N models

281 views
Skip to first unread message

paol...@usp.br

unread,
Apr 28, 2015, 4:02:29 PM4/28/15
to unmarked Group
Hello,

I've modeled the relative abundance of ocelots with the Royle & Nichols models at unmarked and now I'm trying to compute the c-hat for the most parameterized model. I've used this code:

# Goodness of fit

fitstats <- function(fm){
  observed <- getY(umfRN_b200_leg2)
  expected <- fitted(fm)
  resids <- residuals(fm)
  sse <- sum(resids^2)
  chisq <- sum(((observed-expected)^2)/expected)
  freeTuke <- sum((sqrt(observed)-sqrt(expected))^2)
  out <- c(SSE = sse, Chisq=chisq, freemanTukey = freeTuke)
  return(out)
  
}  

pb <- parboot(rDES_lamGl, fitstats, nsim=50)

But when I called the object 'pb' I've got this error message:

Call: parboot(object = rDES_lamGl, statistic = fitstats, nsim = 50)

Parametric Bootstrap Statistics:
             t0 mean(t0 - t_B) StdDev(t0 - t_B) Pr(t_B > t0)
SSE          NA             NA               NA           NA
Chisq        NA             NA               NA           NA
freemanTukey NA             NA               NA           NA

t_B quantiles:
Error in quantile.default(newX[, i], ...) : 
  missing values and NaN's not allowed if 'na.rm' is FALSE


As I have NAs at my occurence matrix I tried the function parboot with na.rm = TRUE, but R says that it is an unused argument.

Does anyone have any idea about what is happening or what shoud I do to compute the goodness of fit?

I've also tried to remove the NAs from the unmarked frame with the function na.omit, but it didn't work.

Thank you very much for your help.

best regards,

--
Att.

Roberta Montanheiro Paolino
Bióloga
Mestranda em Biologia Comparada - FFCLRP / USP-RP
Laboratório de Ecologia e Conservação de Mamíferos

(16) 99182 3123

Kery Marc

unread,
Apr 28, 2015, 4:10:32 PM4/28/15
to unma...@googlegroups.com
Hi Roberta,

I think you have to put the "na.rm = TRUE" inside of the GoF function definition, in the calls to sum. Like this:

sse <- sum(resids^2, na.rm = TRUE)

One further thing (important): you should NOT test GoF directly on the 0/1 data that you feed into this model. GoF tests for binary response do NOT indicate GoF, instead, the GoF must be computed on some aggregation of the data, for instance, the detection histories (as does the MacKenzie-Bailey (MB) test implemented in the "sister package" AICcmodavg), or row or column sums of the detection history. I am not sure whether the MB test can be applied to the RN model ?

Kind regards  --- Marc



From: unma...@googlegroups.com [unma...@googlegroups.com] on behalf of paol...@usp.br [paol...@usp.br]
Sent: 28 April 2015 22:00
To: unmarked Group
Subject: [unmarked] Problems to assess the Goodness of fit in R&N models

--
You received this message because you are subscribed to the Google Groups "unmarked" group.
To unsubscribe from this group and stop receiving emails from it, send an email to unmarked+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages