3
$\begingroup$

I have six variables: sales (weekly), product category, customer segment, store location, week and product placement (aisle, entrance, ...). For each category, segment and location, I observe sales for different product placements. For the first three weeks, I observe "aisle", for weeks 4-6, I observe entrance and so on.

I am trying to estimate whether product placement has an impact on sales and what placement is maximizing sales. Here is a generated sample of my data in R for illustration:

library(dplyr)
library(lme4)

product_category <- c("catA", "catB", "catC", "catD", "catE")
customer_segment <- c("custA", "custB", "custC")
store_location <- c("locA", "locB", "locC", "locD")
placement <- c("aisle", "window", "wherever")

df1 <- expand.grid(product_category = product_category, 
               customer_segment = customer_segment, 
               store_location = store_location, placement = placement)

weeks <- rep(1:3, each = 15, times = 4)

df2 <- bind_cols(df1, sales = runif(dim(df1)[1], 10, 100)) %>% 
  arrange(store_location) %>% 
  mutate(weeks = as.factor(weeks))

My first idea was to use linear regression and test the significance of product placement. However, my observations are most likely not independent (in terms of time and spatially) and I decided to use a mixed effect model, in which I treat placement as fixed effect and for all the other variables I add a random intercept. I use the lme4 package in R and my code looks as follows:

df2 <- df2 %>% mutate_if(is.character, as.factor)

lme4::lmer(sales ~ placement + (1|weeks) + (1|product_category) +  (1|customer_segment) + (1|store_location), data = df2, REML = F)

I am new to mixed effect models. Is this an appropriate way of estimating the impact of product placement? Are there alternatives?

$\endgroup$
2
  • 1
    $\begingroup$ Please edit the question to include the details of your data, and the model you are proposing. $\endgroup$ Aug 11 at 19:39
  • $\begingroup$ @Rober Long, I adjusted my question. Thanks for the input! $\endgroup$ Aug 12 at 7:08
2
$\begingroup$

The model:

lmer(sales ~ placement + (1|weeks) + (1|product_category) +  (1|customer_segment) + (1|store_location), data = df2, REML = F)

seems to be a reasonable approach to this problem, provided that you have more categories, locations and segments than shown in your simulation. A good rule of thumb is 10. 20 is better. 6 is on the cusp of being too few. For the weeks variable, it would be better to code this as 1 through however many weeks there are in total, rather than 1-3 repeated (since 3 levels is too few to fit random intercepts).

The model will estimate fixed effects for placement which, by default, will provide 2 estimates: each one being the estimated difference in sales between each of these estimates and the reference level for placement, along with a global intercept which will contain the reference level for placement.

$\endgroup$
3
  • $\begingroup$ Can I ask you one more thing. If I want to determine the interaction effect of product category and placement on sales but at the same time, I know that I should model product category as a random effect. How would you proceed? I'm a little bit lost since I think that modeling it as fixed and random effect at the same time does not make sense (apart from running in computational problems). Thank you very much! $\endgroup$ Sep 3 at 13:47
  • $\begingroup$ If you have specific interest in the estimate for an interaction involving product_category then you would need to fit this as a fixed effect, not random. For example: sales ~ placement*product_category + (1|weeks) + (1|customer_segment) + (1|store_location) $\endgroup$ Sep 3 at 18:26
  • $\begingroup$ Thanks a lot! 🤞🏻 $\endgroup$ Sep 6 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.