0
$\begingroup$

I am working on a probabilistic prediction model using statsmodel GLM with a poisson distribution.

here is what my dataset looks like:

    Quantity  Month  cannibal_numbers  category_performance
0        0.0     11                 0                     7
1     3985.0      1                 1                     2
2     7690.0      2                 5                     4
3    10070.0      4                 3                    10

Quantity is the predicted variable and the 3 other columns are the predictors.

following the statsmodels documentation, I built the poisson regression model this way:


expr = """Quantity ~ Month  + cannibal_numbers + category_performance"""
        y, X = dmatrices(expr, series, return_type='dataframe')

poisson_fit = sm.GLM(y, X, family=sm.families.Poisson()).fit()

poisson_predict = poisson_fit.predict()

which outputs an array of values like:

[[ 6618.35282151  6567.43783427  7107.1456507   7346.89891295
 10760.13376055  8410.8161072   6725.47592503  7749.58865646
  7208.92846463 11486.1036904   7922.13056598  6315.34214322]

I am stuck here. What to get is the probability that Quantity will be 1, 2, 3 etc.. until n. I have no clue on how to achieve this.

I have read the answer from this post and seems to be what I am trying to achieve Forecasting count data after fitting a Poisson regression model

How could this be done in statsmodels? Thank you in advance for any guidance

$\endgroup$

Your Answer

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

Browse other questions tagged or ask your own question.