Last chance! 50% off unlimited learning
Sale ends in
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.
# S3 method for BTm
residuals(object, type = c("deviance", "pearson", "working",
"response", "partial", "grouped"), by = object$id, ...)a model object for which inherits(model, "BTm") is
TRUE.
the type of residuals which should be returned. The
alternatives are: "deviance" (default), "pearson",
"working", "response", and "partial".
the grouping factor to use when type = "grouped".
arguments to pass on other methods.
A numeric vector of length equal to the number of players, with a
"weights" attribute.
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.
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.
# NOT RUN {
##
## 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)
# }
Run the code above in your browser using DataLab