[R] Funny behaviour of coef() and vcov() if X is singular

BXC (Bendix Carstensen) bxc at steno.dk
Mon Sep 27 13:57:12 CEST 2004


coef() and vcov() have different dimensions if a model contains alised
parameters
as the following example illustrates.

A search on "alised" gave noting as far as I could see.

Is this a known bug?

Bendix C
----------------------
Bendix Carstensen
Senior Statistician
Steno Diabetes Center
Niels Steensens Vej 2
DK-2820 Gentofte
Denmark
tel: +45 44 43 87 38
mob: +45 30 75 87 38
fax: +45 44 43 07 06
bxc at steno.dk
www.biostat.ku.dk/~bxc
----------------------

> x <- rnorm(100)
> y <- rnorm(100)
> z <- rnorm(100)
> summary( mu <- lm( y ~x + I(x-z)+z ) )

Call:
lm(formula = y ~ x + I(x - z) + z)

Residuals:
      Min        1Q    Median        3Q       Max 
-1.917325 -0.633091 -0.003363  0.561464  2.473183 

Coefficients: (1 not defined because of singularities)
            Estimate Std. Error t value Pr(>|t|)
(Intercept)  0.07806    0.09118   0.856   0.3940
x           -0.27373    0.11415  -2.398   0.0184
I(x - z)     0.08617    0.08524   1.011   0.3146
z                 NA         NA      NA       NA

Residual standard error: 0.9061 on 97 degrees of freedom
Multiple R-Squared: 0.05813,    Adjusted R-squared: 0.03871 
F-statistic: 2.993 on 2 and 97 DF,  p-value: 0.05476 

> coef( mu )
(Intercept)           x    I(x - z)           z 
 0.07805884 -0.27373500  0.08617152          NA 
> vcov( mu )
              (Intercept)             x      I(x - z)
(Intercept)  8.313341e-03 -5.702109e-05  0.0007248947
x           -5.702109e-05  1.303028e-02 -0.0057006507
I(x - z)     7.248947e-04 -5.700651e-03  0.0072657814
> length( coef( mu ) )
[1] 4
> dim( vcov( mu ) )
[1] 3 3
> version
         _              
platform i386-pc-mingw32
arch     i386           
os       mingw32        
system   i386, mingw32  
status                  
major    1              
minor    9.1            
year     2004           
month    06             
day      21             
language R




More information about the R-help mailing list