Learn R Programming

HZIP (version 0.1.1)

residuals.HZIP: Compute Residuals for HZIP Models

Description

This function calculates residuals for objects of class HZIP usingrandomized quantile residuals. The computation is performed efficiently using C++ functions for predicting random effects and calculating residuals.

Usage

# S3 method for HZIP
residuals(object, ...)

Value

A numeric vector of residuals with length equal to the total number of observations in the dataset.

Arguments

object

An object of class HZIP, typically returned from hzip.

...

Additional arguments (not used).

Details

The function internally groups the data by individual (Ind), constructs model matrices for both zero-inflation and count parts of the model, and then calls the C++ functions predict_HZIP_cpp_vec and r_ij_cpp_vec to efficiently compute the residuals. Random effects are integrated using adaptive quadrature based on the supplied nodes and weights.

Examples

Run this code
# \donttest{
fit.salamander <- hzip(y ~ mined|mined+spp,data = salamanders)
residuals(fit.salamander)
# }

Run the code above in your browser using DataLab