Linear model, a special case of GLM
In this exercise you will fit a linear model two ways, one using the ols()
function and one using the glm()
function. This will show how a linear model is a special case of a generalized linear model (GLM).
You will use the preloaded salary
dataset introduced in the video.
Recall that the linear model in Python is defined as:
ols(formula = 'y ~ X', data = my_data).fit()
and the generalized linear model can be trained using
glm(formula = 'y ~ X', data = my_data, family = sm.families.___).fit()
This exercise is part of the course
Generalized Linear Models in Python
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
import ____ as ____
from ____.____.____ import ____, ____
# Fit a linear model
model_lm = ols(formula = '____ ~ ____',
data = ____).fit()
# View model coefficients
print(model_lm.params)