Learn R Programming

FlexReg (version 1.2)

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 without augmentation 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" without augmentation 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 = "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). The values \(y_i\) or \(y_i/n_i\) are the observed responses which are specified on the left-hand side of formula in the flexreg or flexreg_binom function, respectively. \(\hat{\mu}_i\) is the predicted value, the result of the predict function with 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" without augmentation 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}\).

References

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

Di Brisco, A. M., Migliorati, S. (2020). A new mixed-effects mixture model for constrained longitudinal data. Statistics in Medicine, 39(2), 129--145. doi:10.1002/sim.8406

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

Examples

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

Run the code above in your browser using DataLab