Re: [R] lm for log log

From: Ted Harding <>
Date: Sun, 20 Jun 2010 14:08:43 +0100 (BST)

On 20-Jun-10 12:02:58, Ekaterina Pek wrote:
> Hi,
> It's rather statistical question than R-question.
> There is some linear correlation but the picture "plot(a,b) +
> abline(lm(b~a))" is quite crowded in the left lower corner. The
> picture "plot(log(a), log(b)) + abline(lm(log(b)~log(a))" is much
> nicer ("Milky Way"). Is it correct to use the second kind of picture
> for illustration ? I use Spearman's rho and it's the same for both
> linear models.
> Regards,
> Kate.

lm(log(b) ~ log(a)) is not the same model as lm(b ~ a) even if, with the second, you subsequently represent it using log(a) and log(b). Therefore, in principle, you should not use abline(lm(log(b)~log(a))) to represent the result of lm(b ~ a) on a log scale.

It may turn out that there is very little difference between the two. Or it may not so turn out. Spearman's rho is not definitive.

It may be that lm(log(b) ~ log(a)) is, from a substantive point of view, a more appropriate model for whetever it is than lm(b ~ a). Or it may not be. This is a separate question. Again, Spearman's rho is not definitive.

If you think that lm(b ~ a) is the correct model to use, then use it and plot the results on a log scale. Then plot the fit on the log scale. However, the linear fit of lm(b ~ a) will not become a straight line on the log scale, and you would need to plot is by segments.

So, for coefficients A,B from the linear fit of lm(b ~ a), you could use

  plot(log(a), log(b)) ; lines(log(a0), log(A + B*a0))

where a0 is a suitably selected set of values of a defining the breakpoints between line segments.


E-Mail: (Ted Harding) <> Fax-to-email: +44 (0)870 094 0861
Date: 20-Jun-10                                       Time: 14:08:39
------------------------------ XFMail ------------------------------

______________________________________________ mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Sun 20 Jun 2010 - 13:11:07 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 20 Jun 2010 - 17:50:33 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive