residuals.BTm {BradleyTerry2} | R Documentation |
Residuals from a Bradley-Terry Model
Description
Computes residuals from a model object of class "BTm"
. In additional
to the usual options for objects inheriting from class "glm"
, a
"grouped"
option is implemented to compute player-specific residuals
suitable for diagnostic checking of a predictor involving player-level
covariates.
Usage
## S3 method for class 'BTm'
residuals(
object,
type = c("deviance", "pearson", "working", "response", "partial", "grouped"),
by = object$id,
...
)
Arguments
object |
a model object for which |
type |
the type of residuals which should be returned. The
alternatives are: |
by |
the grouping factor to use when |
... |
arguments to pass on other methods. |
Details
For type
other than "grouped"
see residuals.glm()
.
For type = "grouped"
the residuals returned are weighted means of
working residuals, with weights equal to the binomial denominators in the
fitted model. These are suitable for diagnostic model checking, for example
plotting against candidate predictors.
Value
A numeric vector of length equal to the number of players, with a
"weights"
attribute.
Author(s)
David Firth and Heather Turner
References
Firth, D. (2005) Bradley-Terry models in R. Journal of Statistical Software 12(1), 1–12.
Turner, H. and Firth, D. (2012) Bradley-Terry models in R: The BradleyTerry2 package. Journal of Statistical Software, 48(9), 1–21.
See Also
Examples
##
## See ?springall
##
springall.model <- BTm(cbind(win.adj, loss.adj),
col, row,
~ flav[..] + gel[..] +
flav.2[..] + gel.2[..] + flav.gel[..] + (1 | ..),
data = springall)
res <- residuals(springall.model, type = "grouped")
with(springall$predictors, plot(flav, res))
with(springall$predictors, plot(gel, res))
## Weighted least-squares regression of these residuals on any variable
## already included in the model yields slope coefficient zero:
lm(res ~ flav, weights = attr(res, "weights"),
data = springall$predictors)
lm(res ~ gel, weights = attr(res, "weights"),
data = springall$predictors)