Logit.from_formula

167 views
Skip to first unread message

Thomas Haslwanter

unread,
Feb 17, 2013, 1:37:47 PM2/17/13
to pystat...@googlegroups.com
Hi,
I am trying to work through the examples in "Will it Python", and have difficulty with the statsmodel formula version of the logit command.

with

from pandas import *
from statsmodels.formula.api import logit
 
heights_weights = read_table('data/01_heights_weights_genders.csv', 
                             sep = ',', header = 0
heights_weights['Male'] = heights_weights['Gender'].map({'Male': 1, 'Female': 0})
male_logit = logit(formula = 'Male ~ Height + Weight', df = heights_weights).fit()

I get the error message

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-4-e6e05e292e29> in <module>()
      1 heights_weights['Male'] = heights_weights['Gender'].map({'Male': 1, 'Female': 0})
----> 2 male_logit = logit(formula = 'Male ~ Height + Weight', df = heights_weights).fit()
      3 print male_logit.summary()

TypeError: from_formula() takes at least 3 arguments (2 given)
 
Maybe I miss something, but from the documentation of the statsmodels "logit" command I don't understand what the 3rd required argument should be. I have tried to install the latest version of statsmodels, but this did not fix the problem.

Any hint where the problem might come from?

josef...@gmail.com

unread,
Feb 17, 2013, 2:06:30 PM2/17/13
to pystat...@googlegroups.com
On Sun, Feb 17, 2013 at 1:37 PM, Thomas Haslwanter
<thomas.h...@gmail.com> wrote:
> Hi,
> I am trying to work through the examples in "Will it Python", and have
> difficulty with the statsmodel formula version of the logit command.
>
> with
>
>> from pandas import *
>> from statsmodels.formula.api import logit
>>
>>
>>
>> heights_weights = read_table('data/01_heights_weights_genders.csv',
>>
>> sep = ',', header = 0)
>>
>> heights_weights['Male'] = heights_weights['Gender'].map({'Male': 1,
>> 'Female': 0})
>> male_logit = logit(formula = 'Male ~ Height + Weight', df =
>> heights_weights).fit()
>
>
> I get the error message
>
> ---------------------------------------------------------------------------
> TypeError Traceback (most recent call last)
> <ipython-input-4-e6e05e292e29> in <module>()
> 1 heights_weights['Male'] = heights_weights['Gender'].map({'Male': 1,
> 'Female': 0})
> ----> 2 male_logit = logit(formula = 'Male ~ Height + Weight', df =

IIRC `df` has been renamed to `data`.

Josef

> heights_weights).fit()
> 3 print male_logit.summary()
>
> TypeError: from_formula() takes at least 3 arguments (2 given)
>
>
> Maybe I miss something, but from the documentation of the statsmodels
> "logit" command I don't understand what the 3rd required argument should be.
> I have tried to install the latest version of statsmodels, but this did not
> fix the problem.
>
> Any hint where the problem might come from?
>
> --
> You received this message because you are subscribed to the Google Groups
> "pystatsmodels" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pystatsmodel...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Thomas Haslwanter

unread,
Feb 17, 2013, 2:39:05 PM2/17/13
to pystat...@googlegroups.com
Yep, that was it :)
Thanks for the quick reply !!!

Reply all
Reply to author
Forward
0 new messages