LoslegenKostenlos loslegen

Adding lagged price effects

Next, you will check if the effects of temporary price changes on sales extend into the next period.

Like before, you shift the PRICE predictor back by using the function lag(). The result is assigned to a new variable Price.lag. The Price.lag variable is added to the log(SALES) ~ PRICE relationship. This simple lag-model can also be estimated by using the function lm().

Diese Übung ist Teil des Kurses

Building Response Models in R

Kurs anzeigen

Anleitung zur Übung

  • Create a lagged variable for PRICE named Price.lag.
  • Estimate a lagged response model explaining log(SALES) by PRICE and Price.lag. Use the function lm() and assign the result again to an object called lag.model.
  • Obtain the coefficients of the lag.model by using the function coef().

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# Take the lag of PRICE
Price.lag <- lag(___)

# Explain log(SALES) by PRICE and Price.lag
lag.model <- ___(___ ~ ___ + ___, data = sales.data)

# Obtain the coefficients
Code bearbeiten und ausführen