LoslegenKostenlos loslegen

Calculating price elasticity

Now that you know about price elasticities, let's see how elastic prices are for the high end product in the metropolitan region! Grand training and validation data sets have already been created for you and are stored in the objects bev_xts_train and bev_xts_valid.

You already have the sales for the high end product loaded in the workspace as MET_hi. You first need to extract the prices out of the bev_xts_train object. The column names for prices in the bev_xts_train object is MET.hi.p.

Diese Übung ist Teil des Kurses

Forecasting Product Demand in R

Kurs anzeigen

Anleitung zur Übung

  • Save the log of the prices for the high end product (MET.hi.p) as a vector.
  • Load the log of the sales and log of prices in a data frame.
  • Build regression model predicting the log of sales with the log of prices.

Interaktive Übung

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

# Save the prices of each product
l_MET_hi_p <- as.vector(___(bev_xts_train[,"___"]))

# Save as a data frame
MET_hi_train <- data.frame(as.vector(log(MET_hi)), l_MET_hi_p)
colnames(MET_hi_train) <- c("log_sales", "log_price")

# Calculate the regression
model_MET_hi <- lm(___ ~ ___, data = ___)
Code bearbeiten und ausführen