ComenzarEmpieza gratis

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.

Este ejercicio forma parte del curso

Forecasting Product Demand in R

Ver curso

Instrucciones del ejercicio

  • 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.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# 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 = ___)
Editar y ejecutar código