Find the right price for your competing products!
By: Haytham Omar Abd El Akher
Tags: Optimization, Rstats, Revenue, Data Science, Supply Chain

Supply Chain Data Science : Episode 1

Working with Inventorize Package in R

Wow, that’s so expensive !! how many times I have said this while shopping? actually what’s happening is a self argument between how much I value this smartphone and how much I am willing to pay for it. if I stay for a little bit in front of the smartphone stand, then probably the attractiveness/value of the smartphone is almost equal to how much I am willing to pay for it. And if I don’t walk away. well yes… the smartphone won!

Photo by Lindsay Moe on UnsplashWhile we are at the supermarket, one can wonder what drives the prices of competing products. We all know that supply chain costs play an important role in determining how much we will pay for cheddar cheese, parmesan cheese, or mozzarella. the number of labor hours put in making each of these lovely stables in our dining tables, the quality, and the logistics cost (transport -clearance -middlemen).

Not only those we might think, but there are also other intangible factors as well that we might consider as customer’s preferences, brand image, how much we like to eat pizzas, these kinds of things that you don’t see in an invoice. Retailers and revenue managers have the task of setting prices for these competing products to capture both the cost and these intangible factors.

let’s say for example that I am the one with the cheese craving, I have 6 dollars that I am willing to pay for any type of cheese but as I am a pizza lover, I will value Mozzarella cheese at 7 dollars, parmesan will sure also fill my craving but I will value it at 5. I don’t like cheddar so it’s value for me is probably at 3.so for me if I find a mozzarella pack for 5 dollars, it’s a bargain!

Retailers now these dynamics by experience and working in the business for a long time, they know what customers like, how they value the products, and for sure the costs associated with bringing the assortment of cheese to the shelf. You see, if I am the retailer and I only offer one type of cheese, I will not have to worry about this problem, I would simply try different prices and see at which price my profit is maximized. but since in our example, the products are not independent of each other and they are effectively competing with each other. the problem becomes an assortment pricing problem.

To put it simply, if I am the Retailer and I choose to decrease the price of cheddar, this will not only increase the demand on cheddar but most probably will also decrease the demand on both the mozzarella and the parmesan. This will eventually impact the total profit I am making at the end of the day.

I have developed a package in R called ‘Inventorize’ that tackle these kinds of decisions which supply chain and revenue managers deal with on daily basis and this will be the first episode in ‘Working with inventorize’ . Hopefully, an explanation of all the functions in this package will come at later stories in this ‘Supply chain Data Science Series’. the first version of the package was tackling only the cost side of the supply chain. But then I have made few updates to include revenue management analytical tools for these kinds of situations.

So, for this kind of problem, we will use a discrete choice model as this model can look at consumer choices based on the prices we set for our competing products and say Ok, the perceived value from your customers for each of these difference is so and so based on what you have shown me. and unlike linear regression, sales are not aggregated here, rather each sale is an event that happened, a customer came, she looked at the choices, and she chose Mozzarella because she valued this product more than than the price set for it.

Not only this, she specifically chose Mozzarella because the difference between her perceived value of Mozzarella and the price offered for Mozzarella was higher than the same differences in the other two products.

Now let’s start with a simple example in R, as we said, each sale is an event :

### randomize Example Customer_selection<- data.frame(Chedar_Cheese= round(runif(300,10,15),2),

Mozzarella=round(runif(300,8,10),2),

Parmesan=round(runif(300,9,12),2),Selection = as.numeric(rep(c(1,2,3,NA,2,3),50))) head(Customer_selection)

the output will be an event that happened in a given day where the prices were set and the customer chose to buy or not one of the products. notice that for the function to work, the selection has to be an integer or NA and corresponds to the column number of the product.

So, for an event that happened on day one, for example, a customer chose Cheddar cheese while on day 2 another Customer chose Mozzarella. you could have many events with the same pricing but ensure that there other days with different prices so that the consumer choice model gains information.

the second step is we use Inventorize package function ‘Multi_Competing_optimization’, this function effectively takes four arguments :

1- X : a data frame of product prices at every event.

2- y :integer vector with choices of a customer at each event, for example, if the competing products are only three, the possible choices are NA,1,2,3. NA being a consumer did not buy any thing at this event and he chose to walk away.

3- n_variables: Number of products competing with each other.

4-initial_products_cost: a vector of current costs for each product, for example, if we have three products, it could be c(1.8,2.5,3.9).or

if there are no costs, it would be c(0,0,0)

## run inventorize::Multi_Competing_optimization

sample_product<-Multi_Competing_optimization(X= Customer_selection[,1:3],

### the product prices at every event

y= Customer_selection[,4],

### a customer choice at an event

n_variables = 3,

#### no of products

initial_products_cost = c(8,6,3)) ###Cost of each Product

what the function is doing under the hood is utilizing a Multinomial logit model the calculates the intrinsic value for each product based on the observation at each event. and then using the prices of the products as variables for a non-linear optimization problem to maximize profit from each possible event. The function will return a data frame and a plot. as shown below :

and the following plot :

It makes you think why for the model to maximize profit , it chose to make the Parmesan cheese a bargain while increasing the price more than the attractiveness of both the mozzarella and Cheddar. If we look at the average prices before , we can see they were significantly different .

> comparison<- data.frame(Average_prices= colMeans(Customer_selection[,1:3]), + optimized_prices=sample_problem$optimized_prices)

> comparison

Average_prices optimized_prices

Cheddar_Cheese 12.40240 14.41166

Mozzarella 9.03370 12.41162

Parmesan 10.50523 9.41163

I would love to hear your thoughts on this function and if it was useful for you in your daily activities. there will be more explanations on the different functions in ‘inventorize’ that vary from stock calculations to maximizing service levels.

A note of thanks to Columbia University and Professor Prof. Daniel Guetta as this work is heavily referenced from their course ‘Supply and demand analytics’’

This function is in Inventorize 1.0.3, as I updated it today, it may take time to appear in CRAN. also, this function takes a considerable amount of time to run when the number of products/events increases.

Thank you and have a great day!

Haytham Omar

https://www.linkedin.com/in/haythamomar/