GLM and intercept

29 views
Skip to first unread message

burakb

unread,
Sep 10, 2010, 2:30:07 PM9/10/10
to pystatsmodels
Hi everyone, I am using a call like

glm = sm.GLM(y, X, family=sm.family.Poisson())
res = glm.fit()

The res object has attributes such as params, deviance, etc. I could
not see an "intercept" attribute which R summary() reports.. Is it
named differently for statmodels?

Thanks,

josef...@gmail.com

unread,
Sep 10, 2010, 3:20:01 PM9/10/10
to pystat...@googlegroups.com

if the intercept is the coefficient of the constant, then you have to
add it yourself to exog, X.

X = sm.add_constant(X) or something like this

then the intercept will be part of params.

(still no offset for Poisson, and GLM)

Josef


>
> Thanks,

burakb

unread,
Sep 10, 2010, 5:26:51 PM9/10/10
to pystatsmodels
This was useful, thank you.

On Sep 10, 10:20 pm, josef.p...@gmail.com wrote:

josef...@gmail.com

unread,
Sep 10, 2010, 6:39:57 PM9/10/10
to pystat...@googlegroups.com
On Fri, Sep 10, 2010 at 5:26 PM, burakb <burakb...@gmail.com> wrote:
> This was useful, thank you.

Hi,

I just saw your blog by chance.

The problem we had with 0*log(0) is only fixed in trunk, I think, not
in the last release version.

Any comments about your experience with statsmodels (and bug reports
and ...) will be very welcome.

Josef

burakb

unread,
Sep 11, 2010, 11:33:42 AM9/11/10
to pystatsmodels
Sure thing. I am a big believer in Python in science. Anything I can
do to help, I'll be happy to do so.

burakb

unread,
Sep 12, 2010, 10:56:10 AM9/12/10
to pystatsmodels

Skipper Seabold

unread,
Sep 12, 2010, 11:33:13 AM9/12/10
to pystat...@googlegroups.com
On Sun, Sep 12, 2010 at 10:56 AM, burakb <burakb...@gmail.com> wrote:
> Here is the cleaned-up GLM Poisson example -- blog post and attached
> code.
>
> http://ascratchpad.blogspot.com/2010/09/glm-and-python-scikitsstatsmodels.html
>
> http://dl.dropbox.com/u/1570604/aspfiles/arm/6.2.R.zip

Cool. FYI there is a convenience function for adding a constant, so
you can just do

X = sm.add_constant(X)

I quickly got tired of typing ones() everywhere.

Skipper

Reply all
Reply to author
Forward
0 new messages