ComeçarComece de graça

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.

Este exercício faz parte do curso

Building Response Models in R

Ver curso

Instruções do exercício

  • Display the relation between SALES and PRICE by using the function plot().
  • Again, explain SALES by PRICE and assign the result to an object named linear.model.
  • Add the model predictions by applying the function abline() to the linear.model object.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Plot SALES against PRICE
___(___ ~ ___, data = sales.data)

# Explain SALES by PRICE
linear.model <- ___(___ ~ ___, data = sales.data)

# Add the model predictions
___(___)
Editar e executar o código