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
.
This is a part of the course
“Forecasting Product Demand in R”
Exercise instructions
- 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.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# 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 = ___)
This exercise is part of the course
Forecasting Product Demand in R
Learn how to identify important drivers of demand, look at seasonal effects, and predict demand for a hierarchy of products from a real world example.
Economic theory has a lot to say about predicting values of demand. Obviously, external factors like price, seasonality, and timing of promotions will drive some aspects of product demand. In this chapter you'll learn about the basics around price elasticity models and how to incorporate seasonality and promotion timing factors into our product demand forecasts.
Exercise 1: Price elasticityExercise 2: Calculating price elasticityExercise 3: Interpret results from elasticityExercise 4: Seasonal / holiday / promotional effectsExercise 5: Visualize holiday / promotion effectsExercise 6: Create holiday / promotional effect variablesExercise 7: Regression for holiday / promotional effectsExercise 8: Significant holiday or promotional effects?Exercise 9: Forecasting with regressionExercise 10: Create future predictor variablesExercise 11: Forecast future values of demandExercise 12: Visualizing forecasts of regressionWhat is DataCamp?
Learn the data skills you need online at your own pace—from non-coding essentials to data science and machine learning.