[Rd] unexpected behaviour in lm() (PR#3657)

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Mon Aug 4 21:39:21 MEST 2003


ottk at bms.com writes:

> > lm(c(1:10) ~ c(1:10))
> 
> Call:
> lm(formula = c(1:10) ~ c(1:10))
> 
> Coefficients:
> (Intercept)  
>         5.5  

Unexpected: yes, bug: no.

Thing is that the lm logic removes the resonse from the set of
predictors. This is to support stuff like "y ~ .", I believe.

You get the same effect from

> x <- c(1:10)
> lm(x~x)

Call:
lm(formula = x ~ x)

Coefficients:
(Intercept)
        5.5


-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907



More information about the R-devel mailing list