[R] problem with log axis

Zembower, Kevin kzembowe at jhuccp.org
Thu Nov 1 19:12:06 CET 2007


Well, here are two attempts that I would have bet on to work, but don't:
#Doesn't seems to show up any line at all:
abline(a=as.numeric(r1$coefficients["(Intercept)"]),
b=as.numeric(r1$coefficients["log(x)"]))
#Line doesn't match points:
abline(r1, untf=TRUE)

So much for furthering knowledge and this discussion...

-Kevin

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of R Heberto Ghezzo, Dr
Sent: Thursday, November 01, 2007 1:40 PM
To: r-help at r-project.org
Subject: [R] problem with log axis

Hello,
if I do:
  x <- c(0.5,1,3,6,10,20,40)
  y <- 10-log(x)+rnorm(7,0,0.05)
  r1 <- lm(y ~ log(x))
  plot(log(x),y)
  abline(r1)
#
I get a nice plot with the regression line almost over the points.
but:
  plot(x,y,log="x")
  abline(r1)
gives me exactly the same plot for the points but the regression line
is completely off !
I would like the plot with the real values of X on the axis, not the
log(X)
can somebody tell me why the "abline" is not correct in the second case?
Thanks
H.Ghezzo
McGill University
Montreal - Canada

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list