Hi all.

I have a doubt with weighted linear regression. I've noted that supplying
integer weights gives different residuals df than giving 'double' weights.
Here an example:

x <- 1:5
y <- -1 + 2*x + rnorm(length(x))*0.1
y <- c(y, x + rnorm(length(x))*0.1)
dat <- data.frame(x=rep(x,2), y = y)
#integer weights:
dat$w1 <- rep(0:1, each=length(x))
#double weights:
dat$w2 <- dat$w1
dat$w2[dat$w2==0] <- .Machine$double.neg.eps
dat$w2[dat$w2==1] <- 1- .Machine$double.neg.eps
lm(x~y, data=dat, weights=w1)$df.residual
#[1] 3
lm(x~y, data=dat, weights=w2)$df.residual
#[1] 8

Estimated coefficients are, as expected, the same in the two cases, but
residuals df changes a lot.
This also has strong effect on residual standard error estimation, an thus
in many other model summaries, which in the above case to me seems more
sensible in the first case.
Why a so different evaluation of residuals df?

Antonio, Fabio Di Narzo.

	[[alternative HTML version deleted]]


