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, Kim ov.mag.min <- c(50, 1000) res.600nm <- c(2.0, 0.231) lm.line.min <- lm( log(ov.mag.min,10) ~ log(res.600nm,10) ) intercept.min <- lm.line.min$coefficients[1] slope.min <- lm.line.min$coefficients[2] two.points.min <- log(ov.mag.min,10) round(res.600nm,2) == round(10^(two.points.min*slope.min+intercept.min),2) round(res.600nm,2) round(10^(two.points.min*-0.71+1.5),2) __________________________________________ Kim Milferstedt University of Illinois at Urbana-Champaign Department of Civil and Environmental Engineering 4125 Newmark Civil Engineering Laboratory 205 North Mathews Avenue MC-250 Urbana, IL 61801 USA phone: (001) 217 333-9663 fax: (001) 217 333-6968 email: milferst at uiuc.edu http://cee.uiuc.edu/research/morgenroth
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, > > Kim > > ov.mag.min <- c(50, 1000) > res.600nm <- c(2.0, 0.231) > > > lm.line.min <- lm( log(ov.mag.min,10) > ~ > log(res.600nm,10) > ) > > intercept.min <- lm.line.min$coefficients[1] > slope.min <- lm.line.min$coefficients[2] > > > two.points.min <- log(ov.mag.min,10) > > round(res.600nm,2) == > round(10^(two.points.min*slope.min+intercept.min),2) > > round(res.600nm,2) > round(10^(two.points.min*-0.71+1.5),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, 10)*slope.min+intercept.min),2) not the other way around, and this does evaluate to two TRUE values. Duncan Murdoch
Reasonably Related Threads
- removing a specific number of digist from a character string
- R for copying and pasting selected image files?
- update index in "for" statement during calculation
- barplot with different color combination for each bar
- which points within an ellipsoid? Sorting data in 3d