# Approaches on how to analyze product allocation (for multiple warehouses) by region in R?

Consider the following dataset:

#   color  type region_west region_cent region_east region_west_pct region_cent_pct region_east_pct
# 1   red shirt          24          17          48          0.2697          0.1910          0.5393
# 2  blue shirt          24          18          44          0.2791          0.2093          0.5116
# 3   red  pant          42          13          33          0.4773          0.1477          0.3750
# 4  blue  pant          46          17          41          0.4423          0.1635          0.3942
# 5   red   hat          46          38           8          0.5000          0.4130          0.0870
# 6  blue   hat          40          11          21          0.5556          0.1528          0.2917


color and type should be self explanatory - we can say the region column represent "sales" and percent of sales by row.

What are some approaches for answering questions such as:

1. Is color and/or type statistically different by region? Which regions? (e.g. post-hoc testing)
2. How many (or what percent) color = red items should I put in the West?
3. How many (or what percent) type = pant items should I place in the East?
4. How would you express a confidence interval around the number of color = red items in the West? What about a confidence interval for the percentage?
5. How are you correcting for making multiple comparisons? (e.g. Bonferonni)

Additional Assumptions: Assume these values represent a true population total sales. That is, all possible sales from the West, Central, and East region -- effectively demand. Additionally, we can assume the sales were made online and the customer resides in one of the three regions. This is essentially a warehouse distribution problem - say I have three warehouses, West, Central, and East - how much of each product should I place in each warehouse if these distributions are the assumed demand quantities.
My initial thoughts are chi-square, ANOVA, and/or regression/glm/gam but I thought this is a "neat" little example hitting on a lot of fundamentals represented on this board, so I'm hoping to get some variety in the responses.

Here's the original dataset:

df <- structure(list(color = structure(c(1L, 2L, 1L, 2L, 1L, 2L), .Label = c("red", "blue"), class = "factor"), type = structure(c(1L, 1L, 2L, 2L, 3L, 3L), .Label = c("shirt", "pant", "hat"), class = "factor"),     region_west = c(24L, 24L, 42L, 46L, 46L, 40L), region_cent = c(17L,     18L, 13L, 17L, 38L, 11L), region_east = c(48L, 44L, 33L,     41L, 8L, 21L), region_west_pct = c(0.2697, 0.2791, 0.4773,     0.4423, 0.5, 0.5556), region_cent_pct = c(0.191, 0.2093,     0.1477, 0.1635, 0.413, 0.1528), region_east_pct = c(0.5393,     0.5116, 0.375, 0.3942, 0.087, 0.2917)), .Names = c("color", "type", "region_west", "region_cent", "region_east", "region_west_pct", "region_cent_pct", "region_east_pct"), out.attrs = structure(list(    dim = 2:3, dimnames = structure(list(Var1 = c("Var1=red",     "Var1=blue"), Var2 = c("Var2=shirt", "Var2=pant", "Var2=hat"    )), .Names = c("Var1", "Var2"))), .Names = c("dim", "dimnames")), row.names = c(NA, -6L), class = "data.frame")


Here's the dataset in a "tidy" format:

df.tidy <- structure(list(color = structure(c(1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L), .Label = c("red", "blue"), class = "factor"), type = structure(c(1L, 1L, 2L, 2L, 3L, 3L, 1L, 1L, 2L, 2L, 3L, 3L, 1L, 1L, 2L, 2L, 3L, 3L, 1L, 1L, 2L, 2L, 3L, 3L, 1L, 1L, 2L, 2L, 3L, 3L, 1L, 1L, 2L, 2L, 3L, 3L, 1L, 1L, 2L, 2L, 3L, 3L, 1L, 1L, 2L, 2L, 3L, 3L, 1L, 1L, 2L, 2L, 3L, 3L), .Label = c("shirt", "pant", "hat"), class = "factor"),     region = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,     2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 1L, 1L,     2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L,     1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L    ), .Label = c("region_west", "region_cent", "region_east"    ), class = "factor"), sales = c(24L, 24L, 42L, 46L, 46L,     40L, 17L, 18L, 13L, 17L, 38L, 11L, 48L, 44L, 33L, 41L, 8L,     21L, 24L, 24L, 42L, 46L, 46L, 40L, 17L, 18L, 13L, 17L, 38L,     11L, 48L, 44L, 33L, 41L, 8L, 21L, 24L, 24L, 42L, 46L, 46L,     40L, 17L, 18L, 13L, 17L, 38L, 11L, 48L, 44L, 33L, 41L, 8L,     21L), pct = c(0.2697, 0.2791, 0.4773, 0.4423, 0.5, 0.5556,     0.2697, 0.2791, 0.4773, 0.4423, 0.5, 0.5556, 0.2697, 0.2791,     0.4773, 0.4423, 0.5, 0.5556, 0.191, 0.2093, 0.1477, 0.1635,     0.413, 0.1528, 0.191, 0.2093, 0.1477, 0.1635, 0.413, 0.1528,     0.191, 0.2093, 0.1477, 0.1635, 0.413, 0.1528, 0.5393, 0.5116,     0.375, 0.3942, 0.087, 0.2917, 0.5393, 0.5116, 0.375, 0.3942,     0.087, 0.2917, 0.5393, 0.5116, 0.375, 0.3942, 0.087, 0.2917    )), row.names = c(NA, -54L), class = "data.frame", .Names = c("color", "type", "region", "sales", "pct"))


Feel free to expand the dataset to a larger example.

• Choosing an appropriate statistical method is not a programming question and therefore doesn't belong on Stack Overflow. I've voted to migrate to Cross Validated where questions about statistical methods is on topic. Commented May 23, 2015 at 16:13
• Questions 2, 3, and 4 cannot be answered without further information. Overall it is important to explain how these data were obtained and what they represent. Are they a sample of something? How were the individual records in the sample selected? How were the values in those records measured? What do those values mean? Please edit this post to narrow its focus to one type of question and to include this essential information.
– whuber
Commented May 23, 2015 at 16:33
• @whuber I added some clarification to the question. Commented May 23, 2015 at 18:01