Extract model residuals
Extracts several types of residuals from an object of class HLfit
.
## S3 method for class 'HLfit' residuals(object, type = c("deviance", "pearson", "response", "std_dev_res"), force=FALSE, ...)
object |
An object of class |
type |
The type of residuals which should be returned. The alternatives are: |
force |
Boolean: to force recomputation of the |
... |
For consistency with the generic. |
Following Lee et al. (2006, p.52), the standardized deviance residuals returned for type="std_dev_res"
are defined as the deviance residuals divided by φ√(1-q), where the deviance residuals are defined as for a GLM, φ is the dispersion parameter of the response family (a vector of values, for heteroscedastic cases), and q is a vector of leverages given by hatvalues(., type="std")
(see hatvalues
for details about these specific standardizing leverages).
A vector of residuals
Lee, Y., Nelder, J. A. and Pawitan, Y. (2006). Generalized linear models with random effects: unified analysis via h-likelihood. Chapman & Hall: London.
data("wafers") fit <- fitme(y ~X1+(1|batch) ,data=wafers, init=list(phi=NaN)) # : this 'init' # implies that standardized deviance residuals are saved in the # fit result, allowing the following comparison: r1 <- residuals(fit, type="std_dev_res") # gets stored value r2 <- residuals(fit, type="std_dev_res", force=TRUE) # forced recomputation if (diff(range(r1-r2))>1e-14) stop()
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.