Generalized Linear Models in Python
Ita Cirovic Donev
Data Science Consultant
Poisson regression model $$ log(\lambda)=\beta_0+\beta_1x_1 $$
The response function: $$ \lambda=exp(\beta_0 + \beta_1x_1) $$ or $$ \lambda=exp(\beta_0) \times exp(\beta_1x_1) $$
Poisson regression model $$ log(\lambda)=\beta_0+\beta_1x_1 $$
The response function: $$ \lambda=exp(\beta_0 + \beta_1x_1) $$ or $$ \lambda=exp(\beta_0) \color{red}{\times} exp(\beta_1x_1) $$
$exp(\beta_0)$
$exp(\beta_1)$
model = glm('sat ~ weight', data = crab,
family = sm.families.Poisson()).fit()
Generalized Linear Model Regression Results (print cut)
=============================================================================
coef std err z P>|z| [0.025 0.975]
-----------------------------------------------------------------------------
Intercept -0.4284 0.179 -2.394 0.017 -0.779 -0.078
weight 0.5893 0.065 9.064 0.000 0.462 0.717
=============================================================================
model.params
Intercept -0.428405
weight 0.589304
np.exp(0.589304)
1.803
print(model.conf_int())
0 1
Intercept -0.779112 -0.077699
weight 0.461873 0.716735
print(np.exp(crab_fit.conf_int()))
0 1
Intercept 0.458813 0.925243
weight 1.587044 2.047737
Generalized Linear Models in Python