# Understanding the modelling formula of a poisson regression with 2 categorical predictors

I have the following dataset:

> df1
Location SalesQty product
1  location 3        1   prod1
2  location 3        0   prod1
3  location 3        3   prod1
4  location 5        3   prod1
5  location 5        0   prod1
6  location 5        4   prod1
7  location 3        2   prod2
8  location 3        5   prod2
9  location 5        2   prod2
10 location 5        1   prod2


I want to perform a poisson regression to predict/estimate the SalesQty of prod1 on location 3 and 5 and prod 2 on location 3 and 5 (I know there are not enough datapoints such that a predictor will be significant). The SalesQties can be visualised as:

If you run:

Reg <- glm(SalesQty ~ Location, family = "poisson", data = df1)


The predictions on each location is just the average per location. This is due to the least squares error per location.

If you run:

Reg <- glm(SalesQty ~ product + Location, family = "poisson", data = df1)


I am figuring out how the coefficients of each categorized predictor play a role in the formula for predicting the SalesQty of a product on a location.

Only considering the location, the formula will be: ln(SalesQty) = $$\beta_0$$ + $$\beta_5 I_5$$ with $$\beta_0$$ beiing the intercept corresponding to location 3. Now $$exp(\beta_0)$$ is the average of the SalesQties of location 3 and $$exp(\beta_0$$ + $$\beta_5)$$ is the average of the SalesQties of location 5. But when considering 2 categorical predictors, the location ánd the product, I don't see how to interpret the coeficients and the modelling formula.

I hope someone can send me in the right direction

Suppose your model is $$\log(\lambda) = \beta_0 + \beta_1 X_1 + \beta_2 X_2$$ and $$Y\sim \text{Poisson} (\lambda)$$. $$Y =$$ SalesQty. $$X_1 = 1$$ for prod2, = 0, otherwise. $$X_2=1$$ for location 5, = 0 otherwise.

Then

$$e^{\beta_0}$$ is mean for prod1 and location 3

$$e^{\beta_0+\beta_1}$$ is mean for prod2 and location 3

$$e^{\beta_0+\beta_2}$$ is mean for prod1 and location 5

$$e^{\beta_0+\beta_1+\beta_2}$$ is mean for prod2 and location 5

• Thanks for your answer. But if I run the regression and calculate $e^{\beta_0} = 1.920635$. However, the mean of weekly sales of product 1 on location 3 is $\frac{4}{3}$. I actually thought that 1.920635 is obtained by combining the mean of weekly sales of product 1 ($\frac{11}{6}$) and the mean of the weekly sales on location 3 ($\frac{11}{5}$) in some way. – Jorden Nov 9 '18 at 7:56
• If you add the interaction between location and production into model, you will get the estimates close to each observed mean. – user158565 Nov 9 '18 at 14:32
• It is a while ago, but I was wondering if you can mathematically proof that the estimate will equal (close to) the observed mean if the interaction between location and product is added. This would be very nice! – Jorden Jan 15 at 10:53