# How to properly write negative binomial regression?

I am modeling the number of likes in a given hour, where $$y_t$$ gives the number of new likes on an item in the hour $$t$$, and seeing how the slope changes after a certain break-point. I assume that $$Y_t \sim NB (\mu_t, {\mu_t}^2 /k)$$.

I then estimate a generalized linaer model with a log-link function: $$\log(E[y]) = \log(\mu) = \beta_0 + \beta_1 T + \beta_2I_tT$$

where $$T$$ is hours since posted, and $$I$$ is $$1$$ if after invention and $$0$$ if before intervention.

1. Is this a correct way to explain the situation? Or should the GLM equation also have an error term?
2. Should the GLM be subscripted to be for hour $$t$$?
3. How do I interpret $$\beta_1$$ and $$\beta_2$$. I believe: Before the intervention, $$Y$$ decreases by $$(\beta_1*100)\%$$ every hour. And after the intervention, $$Y$$ decreases by $$(\beta_1*\beta_2*100)\%$$ every hour.

• You may want to enter the indicator variable as a separate variable with its own coefficient, & then have an interaction b/t T & the indicator. That will allow for an instantaneous shift at the time of the intervention. (Eg, imagine the intervention increases the rate, but doesn't change the slope over time.) Commented Nov 20, 2020 at 18:41

The GLM does not have an error term as in the usual linear model. The reason is, instead imposing a probabilistic structure onto an error term, in GLMs we impose a probabilistic structure onto the response variable, i.e. the exponential family of probability distributions. The good news is that you can move from the linear model a GLM, since the normal distribution is a part of the exponential family.

Now, with regards to the parametrization you suggest, I don't see many issues if your assumption of the treatment only has an effect with an interaction with the number of hours is correct. I'd argue that the assumption can be tested statistically, and that having the interaction can result in a "higher" or "lower" together with the difference in slope.

• Thanks, makes sense. Quick question: How do I interpret β1 and β2. I believe: Before the intervention, Y decreases by (β1∗100)% every hour. And after the intervention, Y decreases by (β1∗β2∗100)% every hour. Is that right? I read somewhere about things being on 'the same scale' as originally even after a link transformation
– asd
Commented Nov 20, 2020 at 18:53
• @asd, the betas will be increases (however, the betas can take negative values, in which case a negative increase is a decrease). B1 is change in log count per unit time; B2 is the difference b/t the change in log count per unit time after intervention from before the intervention. Ie, if slope before is 5, & slope after is 7, then B1=5, & B2=2. Commented Nov 20, 2020 at 19:34
• @gung I'm trying to make it more interpretable to get out of a log scale. So is it that: Before the intervention, Y increases (B1*100)% every hour. And after the intervention, Y increases by (B1*100)% - (B2*100)% every hour?
– asd
Commented Nov 20, 2020 at 19:52
• @asd, after the intervention, Y increases by (B1*100)% + (B2*100)%. Thus, if the slope before were 5, & after were 7, then B2=2. Commented Nov 20, 2020 at 19:55
• Question: Should all of these things be at the "T" level or "IT" level? In other words, is it: 𝑌_t∼𝑁𝐵(u_t, (u_t)^2 / k) OR 𝑌_i𝑡∼ 𝑁𝐵(𝜇_it, (𝜇_i𝑡)^2/𝑘) . Commented Nov 24, 2020 at 23:58