1. Learn
  2. /
  3. Courses
  4. /
  5. Generalized Linear Models in Python

Connected

Exercise

Estimate parameter lambda

In the video you learned how the log link function provides for the linear combination in the parameters defining the Poisson regression model of the form

$$ log(\lambda)=\beta_0+\beta_1x_1 $$

To obtain the response function in terms of lambda we exponentiated the model function to obtain

$$ \lambda=E(y)=exp(\beta_0 + \beta_1x_1) $$ $$ \lambda=E(y)=exp(\beta_0) \times exp(\beta_1x_1) $$

In this exercise, you will use this formulation with the horseshoe crab data to compute the estimate of the mean \(y\) for the female crab width.

Dataset crab is preloaded in the workspace.

Instructions 1/2

undefined XP
    1
    2
  • Import statsmodels.api library as sm and glm from statsmodels.formula.api.
  • Fit and print a Poisson regression model with sat as the response and width as explanatory variable.