#### Utility Functions defined by Fox in the 'car' package (as of 6-25-2012)
#### These are used in the crTest function,
# citation:
# John Fox and Sanford Weisberg (2011). An {R} Companion to
# Applied Regression, Second Edition. Thousand Oaks CA: Sage.
# URL: http://socserv.socsci.mcmaster.ca/jfox/Books/Companion
has.intercept <- function (model, ...) {
UseMethod("has.intercept")
}
has.intercept.default <- function(model, ...) any(names(coefficients(model))=="(Intercept)")
term.names <- function (model, ...) {
UseMethod("term.names")
}
term.names.default <- function (model, ...) {
term.names <- labels(terms(model))
if (has.intercept(model)) c("(Intercept)", term.names)
else term.names
}
predictor.names <- function(model, ...) {
UseMethod("predictor.names")
}
predictor.names.default <- function(model, ...){
predictors <- attr(terms(model), "variables")
as.character(predictors[3:length(predictors)])
}
responseName <- function (model, ...) {
UseMethod("responseName")
}
responseName.default <- function (model, ...) deparse(attr(terms(model), "variables")[[2]])
response <- function(model, ...) {
UseMethod("response")
}
response.default <- function (model, ...) model.response(model.frame(model))
is.aliased <- function(model){
!is.null(alias(model)$Complete)
}
df.terms <- function(model, term, ...){
UseMethod("df.terms")
}
df.terms.default <- function(model, term, ...){
if (is.aliased(model)) stop("Model has aliased term(s); df ambiguous.")
if (!missing(term) && 1 == length(term)){
assign <- attr(model.matrix(model), "assign")
which.term <- which(term == labels(terms(model)))
if (0 == length(which.term)) stop(paste(term, "is not in the model."))
sum(assign == which.term)
}
else {
terms <- if (missing(term)) labels(terms(model)) else term
result <- numeric(0)
for (term in terms) result <- c(result, Recall(model, term))
names(result) <- terms
result
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.