1 | av.frame.lm(model, variable, ...)
|
model |
|
variable |
|
... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (model, variable, ...)
{
mod.mat <- model.matrix(model)
var.names <- colnames(mod.mat)
omit <- grep(variable, var.names)
if (0 == length(omit))
stop(paste(variable, "is not matched among columns of the model matrix."))
cat("x.var =", var.names[omit[1]], "\n", "omitted vars =",
var.names[omit[-1]], "\n")
response <- response(model)
x.var <- mod.mat[, omit[1]]
Xpred <- mod.mat[, -omit]
preds <- predict(update(model, na.action = na.exclude))
responseName <- responseName(model)
if (is.null(weights(model)))
wt <- rep(1, length(response))
else wt <- weights(model)
res <- lsfit(mod.mat[, -omit], cbind(mod.mat[, omit[1]],
response), wt = wt, intercept = FALSE)$residuals
ret <- matrix(NA, nrow = length(preds), ncol = 2)
ret[!is.na(preds), ] <- res
data.frame(x.res = ret[, 1], y.res = ret[, 2])
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.