Aan de slagGa gratis aan de slag

Fitting a Poisson regression

Continuing with the crab dataset you will fit your first Poisson regression model in this exercise.

The crab dataset has been preloaded in the workspace.

Deze oefening maakt deel uit van de cursus

Generalized Linear Models in Python

Cursus bekijken

Oefeninstructies

  • Import statsmodels.api library as sm.
  • Import glm from statsmodels.formula.api.
  • Using Poisson() for the response distribution fit the Poisson regression with satas the response and weight for the explanatory variable.
  • Display the model results using .summary().

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Import libraries
import ____.____ as sm
from ____.formula.api import ____

# Fit Poisson regression of sat by weight
model = ____('____ ~ ____', data = ____, family = ____.____.____).____

# Display model results
____(model.____)
Code bewerken en uitvoeren