Python's statsmodels
module offers a set of methods to estimate GLM
as illustrated in https://www.statsmodels.org/devel/examples/notebooks/generated/glm.html
e.g.
glm_binom = sm.GLM(data.endog, data.exog, family=sm.families.Binomial())
What is the link function in above example? Is it logit
link? How can I use other link like loglog
?
I tried below without any success
glm_binom = sm.GLM(data.endog, data.exog, family=sm.families.Binomial(link = 'loglog'))
Any pointer will be very helpful
In the latest statsmodels stable release (currently v0.13.2), only the following link functions are available for each sm.families.family
:
Family | ident | log | logit | probit | cloglog | pow | opow | nbinom | loglog | logc |
---|---|---|---|---|---|---|---|---|---|---|
Gaussian | X | X | X | X | X | X | X | X | X | |
Inv Gaussian | X | X | X | |||||||
Binomial | X | X | X | X | X | X | X | X | X | |
Poisson | X | X | X | |||||||
Neg Binomial | X | X | X | X | ||||||
Gamma | X | X | X | |||||||
Tweedie | X | X | X |
Alternatively, the list of available link functions can be obtained by:
sm.families.family.<familyname>.links
Lastly, in order to change the default link function of the GLM in statsmodels you need to specify the link
parameter in the family
parameter:
sm.GLM(y, X, family=sm.families.Binomial(link=sm.families.links.loglog()))
P.S. The default link for the Binomial family is the logit link.