Richard Chandler <[EMAIL PROTECTED]> writes: > Hello, > > I'm trying to plot a fitted lm() line on a plot when the one > explanatory variable is log transformed and log="x". I get different > lines using abline and predict.lm(). > > #Example > x <- 1:100 > y <- rnorm(100) > plot(y ~ x, log="x") > abline(lm(y ~ log(x))) > lines(x, predict(lm(y ~ log(x))), lwd=2) > > I'm sure I'm missing something but could someone tell me which line is > correct? Thanks.
Base 10 is what you're missing. The latter form is agnostic with respect to base, the former is not (since the fitted values are the same, but regression coefficients differ). So you need to know to use abline(lm(y ~ log10(x))). You don't really notice which kind of log is being used until you look at par(usr) for a plot with logged axes. -- O__ ---- Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
