Skip to contents

Computes residuals as the difference between observed values and fitted values. For type = "response", returns Y - fitted(object). For type = "pearson", returns response residuals scaled by the standard deviation the family assigns to a response with that fitted value \(\mu\) (fitted(object), which for a Poisson fit already carries the exposure):

familyvariance
normal\(\sigma^2_e\), the posterior mean residual variance
binary\(\mu (1 - \mu)\)
poisson\(\mu + \mu^2 (e^{\sigma^2_e} - 1)\), the variance of a count when \(y \sim \mathrm{Poisson}(e^z)\) and \(z \sim N(\eta, \sigma^2_e)\)
ordinalthe variance of the category distribution at the posterior-mean linear predictor; with explicit cutpoints the posterior-mean cutpoints, with data-induced cutpoints those that reproduce the observed category shares (the rule the posterior predictive draws use)

A cell whose variance is zero has no standardised residual and is NA.

Usage

# S3 method for class 'ame'
residuals(object, type = c("response", "pearson"), ...)

Arguments

object

Fitted AME model object (class "ame").

type

Character; "response" (default) for raw residuals or "pearson" for standardized residuals.

...

Additional arguments (not used).

Value

An n x n matrix (unipartite) or nA x nB matrix (bipartite) of residuals. Entries where the original data was NA remain NA.

Author

Cassy Dorff, Shahryar Minhas, Tosin Salau