Predictive performance
You can use your model to make predictions for any chosen price level. Obtaining reasonable predictions is dependent on the correctness of your assumption that volume sales and unit price are linearly related.
You will display the relation between SALES
and PRICE
in a simple scatterplot by using the function plot()
. Just like the lm()
function, the plot()
function can also operate on the formula argument SALES ~ PRICE
, and will create the required graph. Next, you add the model predictions by using the function abline()
, which adds a straight line specified in sales intercept/price slope form when applied to the linear.model
object.
This exercise is part of the course
Building Response Models in R
Exercise instructions
- Display the relation between
SALES
andPRICE
by using the functionplot()
. - Again, explain
SALES
byPRICE
and assign the result to an object namedlinear.model
. - Add the model predictions by applying the function
abline()
to thelinear.model
object.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Plot SALES against PRICE
___(___ ~ ___, data = sales.data)
# Explain SALES by PRICE
linear.model <- ___(___ ~ ___, data = sales.data)
# Add the model predictions
___(___)