# NOT RUN {
data(ratings)
ratings.lm = lm(meanSizeRating ~ meanFamiliarity * Class +
I(meanFamiliarity^2), data = ratings)
ratings$fitted = fitted(ratings.lm)
plot(ratings$meanFamiliarity, ratings$meanSizeRating,
xlab = "mean familiarity", ylab = "mean size rating", type = "n")
text(ratings$meanFamiliarity, ratings$meanSizeRating,
substr(as.character(ratings$Class), 1, 1), col = 'darkgrey')
plants = ratings[ratings$Class == "plant", ]
animals = ratings[ratings$Class == "animal", ]
plants = plants[order(plants$meanFamiliarity),]
animals = animals[order(animals$meanFamiliarity),]
lines(plants$meanFamiliarity, plants$fitted)
lines(animals$meanFamiliarity, animals$fitted)
# }
Run the code above in your browser using DataLab