Argument in `predict.lm` function

Viewed 237

The head of the predict.lm function is

predict.lm <- function (object, newdata, se.fit = FALSE, scale = NULL, df = Inf,
                        interval = c("none", "confidence", "prediction"), level = 0.95,
                        type = c("response", "terms"), terms = NULL, na.action = na.pass,
                        pred.var = res.var/weights, weights = 1, ...)

I'm having some trouble understanding how the argument pred.var = res.var/weights is evaluated.

I know that it stands for the variance of the residues, but it is passed as a variable as oposed to a character string where it could later be read and translated.

The help for this function is not explicit about this issue, which I think could be related to the way R actually works and not so much with this particular function.

Some how, the argument pred.var will default to the variance of the residues - sd(fit$residuals)^2 - but I cannot see how.

1 Answers
Related