[R] lm for log log

(Ted Harding) Ted.Harding at manchester.ac.uk
Sun Jun 20 15:08:43 CEST 2010


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.

Ted.

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



More information about the R-help mailing list