Skip to content
Prev 290610 / 398498 Next

plot with a regression line(s)

There is no guarantee that x is sorted in ascending order for a glm (or any other model), so lines(x, fitted()) can give very spiny results. Even if sorted, non-linear fits with large gaps in x will not give smooth lines.

Better to use something along the lines of the budworm example in the glm help page, which uses predict() on a new sequence.
If you want something a bit more general, you can use either range(x) to get the new sequence limits or  par("usr")[1:2]  to gets the current plot x limits.


S Ellison
*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}