get_residuals: Get Residuals

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/ares.r

Description

Extract adjusted residuals from the model

Usage

1
get_residuals(model, type = "adj_deviance", plot = FALSE, ...)

Arguments

model

a model fitted by fit_core

type

a quoted string indicating which type of residual to extract. Default is "adj_deviance". See Details

plot

a logical indicating whether the residuals should be plotted. See plot_residuals

...

further options for residuals

Details

The argument type may be either "deviance", "std_deviance", "std_scl_deviance" or "adj_deviance". Each of them behaves as described bellow.

deviance: Deviance residuals are estimated by r_{t}=sign(y_{t}-E(y_{t}))*√(d_{t}), where d_{t} is the deviance contribution of the t-th observation. See deviance for details on deviance component extraction.

std\_deviance: The deviance component is divided by (1-h_{t}), where h_{t} is the t-th element of the diagonal of the pseudo hat matrix of the approximating linear model. So they turn into r_{t}=sign(y_{t}-E(y_{t}))*√(d_{t}/(1-h_{t})).

std\_scl\_deviance: Just like the last one except for the dispersion parameter in its expression, so they have the form r_{t}=sign(y_{t}-E(y_{t}))*√(d_{t}/φ*(1-h_{t})), where φ is the estimated dispersion parameter of the model. See dispersion for φ estimation.

adj\_deviance: These are the deviance residuals multiplied by the estimated coefficient of skewness of the distribution. Thus, for a Poisson model they take the form r_{t}=sign(y_{t}-E(y_{t}))*√(d_{t})*K_{t}, where K_{t} is given by K_{t}=1/(6√(E(y_{t})).

Pierce and Shafer (1986) propose the use of the adjusted deviance residuals over other type of residuals.

Value

A vector of class residuals with extracted and adjusted residuals of the model.

Author(s)

Washington Junger wjunger@ims.uerj.br and Antonio Ponce de Leon ponce@ims.uerj.br

References

McGullagh, P., Nelder, J. A. (1989) Generalized linear models. Chapman and Hall.

Hastie, T., Tibshirani, R. (1990) Generalized additive models. 2 ed. Chapman and Hall.

Pierce, D. A., Schafer, D. W. (1986) Residuals in generalized linear models. Journal of the American Statistical Association, 81(396),977–986.

See Also

residuals,gam,glm

Examples

1
2
3
4
5
6
7
data(admrio)
setup(admrio,"date")
f <- resp5~s(time)+weekdays+s(tmpmax)+s(humid)
m <- fit_core(f)
r <- get_residuals(m,"adj_deviance")
## plot using appropriate method
plot(r)

wjunger/ares documentation built on Dec. 23, 2021, 5:17 p.m.