--
You received this message because you are subscribed to a topic in the Google Groups "unmarked" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/unmarked/aNp6s09kMUI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to unmarked+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/unmarked/c4ad1236-747f-4a04-9900-f1f8ba3b5d40n%40googlegroups.com.
Hi Katherine,
I would suggest having a look at R package DHARMa (https://cran.r-project.org/web/packages/DHARMa/vignettes/DHARMa.html) – I found it quite useful, although I am not sure whether it will work with unmarked objects.
Cheers
Pablo
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/unmarked/CAFAe7-LsfPi_Gw0Yk-zCeUMAiw%2B9eOxSX-noxYOo8wcv3tRoEg%40mail.gmail.com.
I had a bit of a play with the Dunn-Smyth residuals in Warton et al. 2017 based on expecting the detection residuals to be: yi - predict("det"), and for the occupancy residuals to be Y(site) - predict("state") - does that sound right?
Hi Katherine,I had a bit of a play with the Dunn-Smyth residuals in Warton et al. 2017 based on expecting the detection residuals to be: yi - predict("det"), and for the occupancy residuals to be Y(site) - predict("state") - does that sound right?I think this is not quite correct. There's a bunch going on to construct the residuals in the function they provide (below) involved with jittering, applying a normal cdf, and . It looks like google groups thinks something like object *at* data is an email address, so not quite sure this will look as intended.Cheers,John
residuals.occModum<-function(object,is.detect.constant=FALSE){det.data<-object@data@y; # Binary matrix of detections, sites in rows, visits in columns.nSites<-dim(det.data)[1]; # Number of sites.psi<-predict(object, 'state')[, 1]; # Occupancy probabilities, assuming a vector.## Get number of visits (ni) and probability of non-detection (prob0).ni<-apply(is.na(det.data)==FALSE,1,sum); # Number of site visits, a vector across sites.xi<-apply(det.data,1,sum,na.rm=TRUE); # Number of detections.xiOcc<-pmin(xi,1); # Make it binary to study occupancy "only".
pi<-matrix(predict(object, 'det')[, 1],nrow=nSites,byrow=T); # Detection probabilities.#Without the byrow argument, the matrix of pi gives me the residuals in the incorrect order. I have only one NA so I know its position and can deduce that the original code gives the structure S1R1,S1R2,S1R3 as the first three values of the first column.
pdetMinus[iSite]<-hetcdf(xiSite-1,niSite,piSite); #why is it minus 1? The cdf function has a clause for no detections so why do we exclude them here?
pdet[iSite]<-pdetMinus[iSite]+hetpdf(xiSite,niSite,piSite);}
pdet<-pdet/(1-prob0); # 'CDF' for number of detections xi in heterogeneous case. # calculating pdet in this way results in NAs for any sites with no detections making lengths unequal when trying to plot vs fitted values unless I can retrospectively return NAs to some other value.
pdetMinus<-pdetMinus/(1-prob0); # Previous value of the cdf of xi.}## Get cdf's for occupancy residuals - as a function of binary detected/not.probOcc<-psi*(1-prob0); # Probability of occupancy.pOcc<-1-probOcc+xiOcc*probOcc; # CDF for occupancy, Bernoulli variable with param probOcc.pOccMinus<-xiOcc*(1-probOcc); # Previous value of the cdf of occupancy.## Jitter and get occupancy residuals.uOcc<-runif(nSites); # Standard uniform value to "jitter" the cdf.residOcc<-qnorm(pOcc*uOcc+pOccMinus*(1-uOcc)); # Dunn-Smyth residual, standard normal if cdf correct.## Jitter and get detection residuals.u<-runif(nSites); # Standard uniform value to "jitter" the cdf.residDet<-qnorm(pdet*u+pdetMinus*(1-u)); # Dunn-Smyth residual, standard normal if cdf correct.residuals<-list(occ=residOcc,det=residDet);return(residuals) # Return output (i.e., a list with occupancy residuals (occ) and detection residuals (det)).}
--
You received this message because you are subscribed to a topic in the Google Groups "unmarked" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/unmarked/aNp6s09kMUI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to unmarked+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/unmarked/b301c537-7f3d-4205-8b3c-dd6878e70b3bn%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/unmarked/a00f4435-524b-4617-9e95-5fdfd0e84881n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/unmarked/b94df34e-c965-4f41-b34a-240f4a0532d0n%40googlegroups.com.