1

I am getting different trend lines when I use:

plot(x=time,y=eat)
abline(lm(eat~time))

versus

ggplot(data,aes(x=time,y=eat)) + geompoint()+ stat_smooth(method=lm,se=TRUE)

Why is there a difference in the two trend lines when plotted using different methods?

Is there a way to calculate the slope of the lines obtained via stat_smooth?

When I plot the line using the slope/intercept obtained from summary(lm(eat~time)), it does not match with the line obtained from stat_smooth

sharp
  • 61
  • 8
  • 2
    Can you please give a reproducible example? – DatamineR Mar 23 '16 at 19:45
  • Thanks, the typo was made in only reproducing the question here. I have corrected it above – sharp Mar 23 '16 at 20:00
  • When I try with `mtcars`, I get identical looking results. Can you provide a reproducible example? Also, it appears you've `attach`ed your data, which is risky. Are you sure the vectors `eat` and `time` in your workspace still match the corresponding columns of `data`? – Gregor Thomas Mar 23 '16 at 20:33
  • [See here](http://stackoverflow.com/q/5963269/903061) for tips on making reproducible examples. You should share data (in order of preference) 1. using built-in data, 2. simulating (with a random seed), 3. actual data using `dput()`. – Gregor Thomas Mar 23 '16 at 20:34
  • Thank you will look into it. – sharp Mar 24 '16 at 01:10

0 Answers0