Residuals for a regimix object.
Description
Returns the (absolute) deviance residuals or the randomised quantile residuals from a regimix object.
Arguments
object 
an object obtained from fitting a RCP mixture model. Such as that generated from a call to regimix(qv). 
... 
ignored 
type 
either "RQR" (the default) or "deviance" (the old default). See details. 
quiet 
should information be printed during the function? quiet=FALSE gives the information, whereas quiet=TRUE does not. 
Details
The randomised quantile residuals ("RQR", from Dunn and Smyth, 1996) are defined by their marginal distribution function (marginality is over other species observations within that site; see Foster et al, in prep). The result is one residual per species per site and they all should be standard normal variates. Within a site they are likely to be correlated (as they share a common latent factor), but across sampling locations they will be independent.
The deviance residuals (as used here), are actually just square root of minus two times the loglikelihood contribution for each sampling location. We do not subtract the loglikelihood of the saturated model as, at the time of writing, we are unsure what this loglikelihood should be (latent factors confuse things here). This implies that the residuals will not have mean zero and their variance might also be heteroskedastic. This was not realised when writing the original RCP paper (Foster et al, 2013), obviously. We still believe that these residuals have some utility, but we are unsure where that utility stops. For general useage, the "RQR" residuals should probably be preferred.
Value
For type=="RQR", a numberofsites by numberofspecies matrix with the randomised quantile residuals, which should be distributed as a standard normal variate. 

For type=="deviance" a numeric vector of size object$n containing the deviance residuals. 
Method
residuals( object, ..., type="RQR", quiet=FALSE)
Author(s)
Scott D. Foster
References
Dunn, P.K. and Smyth G.K. (1996) Randomized Quantile Residuals. Journal of Computational and Graphical Statistics 5: 236–244.
Foster, S.D., Givens, G.H., Dornan, G.J., Dunstan, P.K. and Darnell, R. (2013) Modelling Regions of Common Profiles Using Biological and Environmental Data. Environmetrics 24: 489–499. DOI: 10.1002/env.2245
Foster, S.D., Lyons, M. and Hill, N. (in prep.) Ecological Groupings of Sample Sites in the presence of sampling artefacts.