增量价值有多大?
您还记得第一个简单响应模型的糟糕表现。现在,您想看看加入滞后项能带来多大增益。因此,您把所有营销工具及其滞后效应合并到一个名为 extended.model 的模型中。通过对 extended.model 对象使用 fitted.values() 函数,您可以得到模型预测值。由于滞后操作会导致首个观测值缺失,需要在预测值向量末尾追加 NA 以对齐。
这一次,为了检查模型,请使用 plot() 显示 log(SALES) 与运行索引之间的关系。同样地,使用 lines() 将模型预测值添加到图中。lines() 函数会用线段把预测数据点与运行索引连接起来。
本练习是课程的一部分
在 R 中构建响应模型
练习说明
- 估计一个扩展响应模型,用所有营销工具及其滞后项来解释
log(SALES)。将结果赋给名为extended.model的对象。 - 对
extended.model对象使用fitted.values()函数获得模型预测值。将结果赋给名为predicted.values的对象。 - 使用
plot()函数显示log(SALES)与运行索引之间的关系。 - 使用
lines()函数将模型预测值添加到图中。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# 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
___(___ ~ ___)