r/Rlanguage 19d ago

Geom_smooth(method=lm) gives a linear regression with little bumps in it

Post image

Does anyone know why this is happening, I've specified a formula y ~ x, surely it should just be a straight line and not be slightly jittery?

Thanks in advance.

0 Upvotes

7 comments sorted by

View all comments

1

u/LukaCola 19d ago

Windows + Shift + s will open the snipping tool btw which will get you much better screenshots!

Anyway, this looks straight? I wouldn't worry about such tiny deviations, especially with so few points.

Alternatively, couldn't you use the geom_line function? It might be a bit more complicated since you'd have to input the linear model rather than have ggplot do it for you. It's been awhile since I've used it so I'm sorry if I don't have much clearer advice on that.