I am confused about the interpretation for the negative binomial regression with python pymc3
package. I am not sure how to interpret the mu
and alpha
in GLM. Here I have a simple vector, and I want to find the NB regression model for itself:
# The data
y = [100,200,300,400,50,300,60,89,90,100,100]
data = {'y':y, 'x':[1]*len(y)}
basic_model = pm.Model()
with basic_model:
fml = 'y~x'
pm.glm.GLM.from_formula(formula=fml, data=data, family=pm.glm.families.NegativeBinomial())
# draw 500 posterior samples
trace = pm.sample(500)
summary = pm.summary(trace, varnames=rvs)[['mean','hpd_2.5','hpd_97.5']]
print(summary)
Then I got output like:
mean hpd_2.5 hpd_97.5
Intercept -281.884463 -684.069010 718.375125
x 287.000388 -714.168056 689.477911
mu 26.674426 3.526181 63.358150
alpha 2.461808 1.353676 3.452103
I understand that the Intercept
& x
part as y = exp(-281.884463*287.000388*x)
from here.
But how to interpret the mu
and alpha
? I tried to use stats.gamma.rvs(alpha, scale=mu / alpha, size=size)
but the histogram looks way off. Thank you!