Extract residuals for a given submodel from a ubmsFit object. Residuals are calculated separately for each submodel using the posterior predictive distribution of the latent state z, following Wright et al. (2019).
## S4 method for signature 'ubmsFit'residuals(object, submodel, draws =NULL,...)
Arguments
object: A fitted model of class ubmsFit
submodel: Submodel to get residuals for, for example "det"
draws: An integer indicating the number of draws to return. The default and maximum number of draws is the size of the posterior sample.
...: Currently ignored
Returns
A matrix of residual values with dimension draws by observations. Note that calculation of residuals for the detection submodel is conditional on z>0, so residuals for an observation in a posterior draw where z=0 are assigned value NA (Wright et al. 2019).
References
Wright, W. J., Irvine, K. M., & Higgs, M. D. (2019). Identifying occupancy model inadequacies: can residuals separately assess detection and presence? Ecology, 100(6), e02703.