[R-SIG-Mac]bug in lm()?

Jan de Leeuw deleeuw@stat.ucla.edu
Fri, 1 Mar 2002 10:42:07 -0800


Here is a couple of other different results (Darwin, version 1.4.1 -- by 
the way
upgrading will correct some problems).
===========================================================
 > dummy1 <- c(1:10)
 > dummy2 <- c(1:10)
 > lm(dummy1~dummy2)

Call:
lm(formula = dummy1 ~ dummy2)

Coefficients:
(Intercept)       dummy2
   1.221e-15    1.000e+00
===========================================================
 > lm(c(1:10)~c(1:10))

Call:
lm(formula = c(1:10) ~ c(1:10))

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

Call:
lm(formula = (c(1:10)) ~ (c(1:10)))

Coefficients:
(Intercept)      c(1:10)
   1.221e-15    1.000e+00
===========================================================
It looks to me there is no problem, everything gives (0,1), except for
lm(c(1:10)~c(1:10)), which may not be legal R (by the way, I also
get 5.5 with the Solaris version). The examples below illustrate the
problem is with naming the dependent  variable c(1:10)
===========================================================

 > lm(c(1:10)~(c(1:10)))

Call:
lm(formula = c(1:10) ~ (c(1:10)))

Coefficients:
(Intercept)
         5.5

 > lm((c(1:10))~c(1:10))

Call:
lm(formula = (c(1:10)) ~ c(1:10))

Coefficients:
(Intercept)      c(1:10)
   1.221e-15    1.000e+00


On Friday, March 1, 2002, at 07:30 AM, Christof Bigler wrote:

> After having used lm(), I encountered some odd results in the Darwin 
> version (Mac G4, OS X Version 10.1.3). Then I tried out this (in the 
> Darwin and the Carbon version):
>
>> > dummy1 <- c(1:10)
>> > dummy2 <- c(1:10)
>
> Darwin version (1.4.0):
>
> a)
>> > lm(dummy1~dummy2)
>>
>> Call:
>> lm(formula = dummy1 ~ dummy2)
>>
>> Coefficients:
>> (Intercept)       dummy2
>>   2.442e-15    1.000e+00
>>
> b)
>> > lm(c(1:10)~c(1:10))
>>
>> Call:
>> lm(formula = c(1:10) ~ c(1:10))
>>
>> Coefficients:
>> (Intercept)
>>          22
>
> Carbon version (1.3.1, yes I know!):
>
> c)
>> > lm(dummy1 ~ dummy2)
>>
>> Call:
>> lm(formula = dummy1 ~ dummy2)
>>
>> Coefficients:
>> (Intercept)       dummy2
>>           0            1
>>
> d)
>> > lm(c(1:10)~c(1:10))
>>
>> Call:
>> lm(formula = c(1:10) ~ c(1:10))
>>
>> Coefficients:
>> (Intercept)
>>         5.5
>>
>
> Are there any explanations, why one can get 4 different results 
> (although just one is correct)?
>
> Christof
>
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac@stat.math.ethz.ch
> http://www.stat.math.ethz.ch/mailman/listinfo/r-sig-mac
>
>
===
Jan de Leeuw; Professor and Chair, UCLA Department of Statistics;
US mail: 9432 Boelter Hall, Box 951554, Los Angeles, CA 90095-1554
phone (310)-825-9550;  fax (310)-206-5658;  email: deleeuw@stat.ucla.edu
homepage: http://www.stat.ucla.edu/~deleeuw
========================================================
           No matter where you go, there you are. --- Buckaroo Banzai
                    http://www.stat.ucla.edu/~deleeuw/sounds/nomatter.au
========================================================