[Rd] confint for coefficients from lm model (PR#10496)

Christian.Lajaunie at ensmp.fr Christian.Lajaunie at ensmp.fr
Wed Dec 5 18:40:23 CET 2007


Full_Name: Christian Lajaunie
Version: 2.5.1
OS: Fedora  fc6
Submission from: (NULL) (193.251.63.39)


confint() does not use the appropriate variance term when the design
matrix contains a zero column (which of course should not happen). 
Example:

A 10x2 matrix with trivial column 1:

> junk <- data.frame(x=rep(0,10), u=factor(sample(c("Y", "N"), 10, replace=T)))

The response:
> ans <- as.integer(junk$u) + rnorm(10)
and the model:
> junk.model <- lm(ans ~ junk$x + junk$u)

3 coefficients:

> coefficients(junk.model)
(Intercept)      junk$x     junk$uY 
  0.6808802          NA   1.5912192

and a 2x2 variance (X^tX)^-1:
 
> vcov(junk.model)
            (Intercept)     junk$uY
(Intercept)  0.09905378 -0.09905378
junk$uY     -0.09905378  0.19810756

result in no confidence interval for the third term:

> confint(junk.model)
                  2.5 %   97.5 %
(Intercept) -0.04488412 1.406644
junk$x               NA       NA
junk$uY              NA       NA

confint() seems to be looking for diag(vcov(junk.model))[3]
instead of diag(vcov(junk.model))[2]



More information about the R-devel mailing list