LoslegenKostenlos loslegen

Fitting negative binomial

The negative binomial allows for the variance to exceed the mean, which is what you have measured in the previous exercise in your data crab. In this exercise you will recall the previous fit of the Poisson regression using the log link function and additionally fit negative binomial model also using the log link function.

You will analyze and see how the statistical measures were changed.

The model crab_pois and crab is loaded in your workspace.

Diese Übung ist Teil des Kurses

Generalized Linear Models in Python

Kurs anzeigen

Anleitung zur Übung

  • Define a formula for the regression model so that sat is predicted by width.
  • Fit the negative binomial using NegativeBinomial() and save the model as crab_NB.
  • Print the summaries of the Poisson model crab_pois and the newly fitted negative binomial model.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Define the formula for the model fit
formula = '____ ~ ____'

# Fit the GLM negative binomial model using log link function
crab_NB = smf.glm(formula = ____, data = ____, 
				  family = ____.____.____).____

# Print Poisson model's summary
print(____.____)

# Print the negative binomial model's summary
print(____.____)
Code bearbeiten und ausführen