What's the value added?
You still remember the bad performance of your first simple response model. Now, you are getting curious about the value added by taking lags. Therefore, you combine all the marketing tools and their lagged-effects in one model named extended.model
. You obtain the model predictions by using the function fitted.values()
on the extended.model
object. To account for the loss of the first observation due to the lag operation you append NA
to the vector of predicted values.
This time, to check your model, you display the relation between log(SALES)
and the running index by using plot()
. Likewise, you add the model predictions to the graph by using lines()
. The lines()
function joins the predicted data points and the running index using line segments.
This exercise is part of the course
Building Response Models in R
Exercise instructions
- Estimate an extended response model explaining
log(SALES)
by all marketing tools and their lagged terms. Assign the result to an object namedextended.model
. - Obtain the model predictions by using the function
fitted.values()
on theextended.model
object. Assign the result to an object namedpredicted.values
. - Display the relation between
log(SALES)
and the running index by using the functionplot()
. - Add the model predictions to the graph by using the function
lines()
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Extend the sales resonse model
___ <- ___(___ ~ PRICE + Price.lag + DISPLAY + Display.lag + COUPON + Coupon.lag + DISPLAYCOUPON + DisplayCoupon.lag, data = sales.data)
# Obtain the model predictions
predicted.values <- c(NA,___(___))
# Plot log(SALES) against the running index
___(___ ~ 1, data = sales.data)
# Add the model predictions to the plot
___(___ ~ ___)