# residuals2: Residuals for Linear and Generalized Linear Models In glmtoolbox: Set of Tools to Data Analysis using Generalized Linear Models

## Description

Computes residuals for a fitted linear or generalized linear model.

## Usage

 `1` ```residuals2(object, type, standardized = FALSE, plot.it = TRUE, identify, ...) ```

## Arguments

 `object` a object of the class lm or glm obtained from the fit of a linear or a generalized linear model. `type` an (optional) character string giving the type of residuals which should be returned. The available options for LMs are: (1) externally studentized ("external"); (2) internally studentized ("internal") (default). The available options for GLMs are: (1) "pearson"; (2) "deviance"; (3) "quantile" (default). `standardized` an (optional) logical switch indicating if the residuals should be standardized by dividing by the square root of (1-h), where h is a measure of leverage. By default, `standardized` is set to be FALSE. `plot.it` an (optional) logical switch indicating if a plot of the residuals is required. By default, `plot.it` is set to be TRUE. `identify` an (optional) integer value indicating the number of individuals to identify on the plot of residuals. This is only appropriate when `plot.it=TRUE`. `...` further arguments passed to or from other methods

## Value

A vector with the observed residuals type `type`.

## Examples

 ```1 2 3 4 5 6 7 8 9``` ```# Example 1 fit1 <- lm(Species ~ Biomass + pH + Biomass*pH, data=richness) residuals2(fit1, type="external", col="red", pch=20, col.lab="blue", col.axis="blue", col.main="black", family="mono", cex=0.8) # Example 2 fit2 <- glm(infections ~ frequency + location, family=poisson, data=swimmers) residuals2(fit2, type="quantile", col="red", pch=20,col.lab="blue", col.axis="blue",col.main="black",family="mono",cex=0.8) ```

glmtoolbox documentation built on Oct. 4, 2021, 9:08 a.m.