Skip to content

Lm gives different results depending on x-bit architecture

2 messages · AdamMarczak, Uwe Ligges

#
Dear all,

I have encountered problem when developing application. My linear regression
does give different results depending on architecture.

Following example describes my problem perfectly.

    xxx <- data.frame(a=c(0.2,0.2,0.2,0.2,0.2),b=c(7,8,9,10,11))
    lm(a~b,xxx)
    summary(lm(a~b,xxx))$r.squared

returns on 32-bit R:

    Call:
    lm(formula = a ~ b, data = xxx)
?
    Coefficients:
    (Intercept)??????????? b?
    ??2.000e-01?? -1.503e-18?
?
    >summary(lm(a~b,xxx))$r.squared
    [1] 0

and on 64-bit R:

    Call:
    lm(formula = a ~ b, data = xxx)
?
    Coefficients:
    (Intercept)??????????? b?
    ?  2.0e-01??           0
?
    >summary(lm(a~b,xxx))$r.squared
    [1] NA

It is very easy to notice slope should be 0 in the above case. I also
understand it is related to the precision of 32 and 64 bit and dependant on
how those are internally written, but maybe someone had this problem and
found any solution.

With regards,
Adam.



--
View this message in context: http://r.789695.n4.nabble.com/Lm-gives-different-results-depending-on-x-bit-architecture-tp3776027p3776027.html
Sent from the R help mailing list archive at Nabble.com.
#
On 29.08.2011 13:54, AdamMarczak wrote:
Not necessarily, since the same precision is used by R. It may even be 
the result of using different compilers (or just compiler versions) for 
producing the 32-bit and the 64-bit version.
If you want to see if b is numerically equal to zero, use all.equal().

Uwe Ligges