Learn R Programming

FlexReg (version 1.1)

residuals.flexreg: Residuals Method for flexreg Objects

Description

Method that computes various types of residuals from objects of class `flexreg`. If the model type is FB or FBB and cluster = T, the method returns also residuals with respect to cluster means.

Usage

# S3 method for flexreg
residuals(
  object,
  type = "raw",
  cluster = FALSE,
  estimate = "mean",
  q = NULL,
  ...
)

Arguments

object

an object of class `flexreg`, usually the result of flexreg or flexreg_binom.

type

a character indicating type of residuals (raw or standardized).

cluster

logical. If the model is "FB" or "FBB", cluster=T returns the cluster means. By default cluster = F.

estimate

a character indicating the type of estimate: mean (default), median, or quantile.

q

if estimate is quantile, a numeric value of probability in (0, 1).

...

additional arguments. Currently not used.

Details

Raw residuals are defined as \(r_i=y_i-\hat{\mu}_i\) (or \(r_i= y_i/n_i-\hat{\mu}_i\) for binomial data) for \(i=1, \dots, n\). The values \(y_i\) for \(i,\dots,n\) are referred to the observed response variable and they are specified on the left-hand side of formula in the flexreg function. \(\hat{\mu}_i\) for \(i=1, \dots, n\) is the predicted value. It can be computed separately through the predict function by setting type=response. Standardized residuals are defined as \(\frac{r_i}{\widehat{Var}(y_i)}\) where \(\widehat{Var}(y_i)\) is the variance of the dependent variable evaluated at the posterior means (default, otherwise quantile of order q) of the parameters. If the model is "FB" or "FBB" and cluster=T, the cluster residuals are computed as the difference between the observed response/relative response and the cluster means \(\hat{\lambda}_{1i}\) and \(\hat{\lambda}_{2i}\) for \(i=1, \dots, n\).

References

Migliorati, S., Di Brisco, A. M., Ongaro, A. (2018) A New Regression Model for Bounded Responses. Bayesian Analysis, 13(3), 845--872. doi:10.1214/17-BA1079

Ascari, R., Migliorati, S. (2021). A new regression model for overdispersed binomial data accounting for outliers and an excess of zeros. Statistics in Medicine, 40(17), 3895--3914. doi:10.1002/sim.9005

Examples

Run this code
{
data("Reading")
FB <- flexreg(accuracy ~ iq, Reading, type="FB", n.iter=1000)
residuals(FB, type="raw", cluster=TRUE)
}

Run the code above in your browser using DataLab