Last data update: 2014.03.03

R: Residuals for grouped objects
residuals.groupedR Documentation

Residuals for grouped objects

Description

Computes a version of Bayesian latent residuals for grouped models.

Usage

## S3 method for class 'grouped'
residuals(object, standardized = FALSE, B = 100, ...)

Arguments

object

an object of class grouped.

standardized

logical; if TRUE the standardized residuals are computed.

B

the number of multiple imputations to be used to estimate the residuals.

...

additional parameters; currently none is used.

Details

In a grouped-data setting the ordinary definition of residuals is problematic since, in fact the value of the true response is known only up to the interval in which it lies. A possible solution to this problem provides the notion of Bayesian residuals (see e.g., Johnson and Albert, Section 3.4). In particular, the Bayesian residuals in the grouped-data setting are defined as follows:

r_i=Z_i - x_i^tβ,

where Z_i denotes the value of the underlying true response of the ith sample unit, x_i^t is the covariate vector of the ith sample unit, β are the regression coefficients and let also Y_i denote the observed data.

An estimation for r_i can be obtained under the following Multiple Imputation (MI) scheme:

Step 1:

Simulate new parameter values, say θ^*, from N(hat{θ}, C(hat{θ})), where hat{θ} are the MLEs (including both β and σ, see grouped) and C(hat{θ}) is their large sample covariance matrix.

Step 2:

Draw a value, say z_i^*, from the predictive distribution Z_i|Y_i under θ^* and compute the residuals r_i^*=z_i^*-x_i^tβ^*. In fact, p(z_i|y_i; θ^*=(β^*, σ^*)) is a truncated F distribution in the interval given by y_i, where F denotes the distribution implied by the value of the distribution argument used in grouped.

Step 3:

Repeat steps 1-2 B times and combine the estimates using the known formulas of MI.

This procedure explicitly acknowledges the ignorance of the true parameter values by drawing from their large sample posterior distribution while taking into account the sampling error.

Value

an object of class resid.grouped with the following components:

residuals

a vector of the estimated residuals.

mat.res

a numeric matrix containing the B realization of the latent residuals. If standardized = TRUE, then mat.res contains the values of r_i^*/σ^*. See Details above.

nam.res

a character vector specifying the sample units names.

B

the value of the B argument defined above.

standardized

the value of the standardized argument defined above.

fitted

a numeric vector of the fitted values of object.

Author(s)

Dimitris Rizopoulos d.rizopoulos@erasmusmc.nl

References

Johnson, V. and Albert, J. (1999), Ordinal Data Modeling, New York: Springer-Verlag.

See Also

grouped, summary.resid.grouped

Examples


m1 <- grouped(cbind(lo, up) ~ treat * x, link = "logit", data = Sdata)
resid(m1)
    
m2 <- grouped(equispaced(r, n) ~ x1 * x2, link = "logit", data = Seeds)
resid(m2)

Results