Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
You have already created a fitted regression model object for a data set, and you want to plot the lines for that model.
Usually the easiest way to overlay a fitted model is to simply
ask stat_smooth() to do it for you,
as described in Adding Fitted Regression Model Lines. Sometimes,
however, you may want to create the model yourself and then add it to
your graph. This allows you to be sure that the model you’re using for
other calculations is the same one that you see.
In this example, we’ll build a quadratic model using lm() with
ageYear as a predictor of heightIn. Then we’ll use the predict() function and find the predicted values of heightIn across the range of values for the
predictor, ageYear: