[R] lm( ) for log10-transformed data
murdoch at stats.uwo.ca
Tue Aug 7 21:56:23 CEST 2007
On 8/7/2007 2:58 PM, Kim Milferstedt wrote:
> Dear help-list,
> I would like to perform a linear regression on the log10 of the two
> vectors ov.mag.min and res.600nm. The slope and intercept of the
> regression I use to plot a wider range of ov.mag.min in a double log plot.
> For a linear regression on only tow points, wouldn't I expect the
> results for two.points.min to match pretty exactly res.600nm? It does
> not seem to be the case here. I manually calculated the slope and
> intercept and got values of -0.71 and 1.5 that seem to work alright.
> What is it that I am missing here?
> Thanks already for your help,
> ov.mag.min <- c(50, 1000)
> res.600nm <- c(2.0, 0.231)
> lm.line.min <- lm( log(ov.mag.min,10)
> intercept.min <- lm.line.min$coefficients
> slope.min <- lm.line.min$coefficients
> two.points.min <- log(ov.mag.min,10)
> round(res.600nm,2) ==
The convention in the lm() function is to express a model as
response ~ predictor. So you should expect
round(ov.mag.min,2) == round(10^(log(res.600nm,
not the other way around, and this does evaluate to two TRUE values.
More information about the R-help