Statsmodels: PatsyError: model is missing required outcome variables - once again ?

Created on 28 Jul 2019  路  2Comments  路  Source: statsmodels/statsmodels

Saw this issue was present last year (#5343), since i have no experience, nor understanding in statistics i can't tell if python broke again or if i'm doing something wrong.

I followed a video from youtube after looking for a way to get a power law equation from my data.

After doing this (most of the data in my y-axis(ctr) is negative after the log being done!):

dflog = np.log(df2[['ctr','position']])

model = ols(formula= 'ctr - position', data = dflog).fit()
print(model.params)

My data after log:
image

I get this error:

PatsyError                                Traceback (most recent call last)
<ipython-input-153-258c64865116> in <module>
      1 dflog = np.log(df2[['ctr','position']])
      2 
----> 3 model = ols(formula= 'ctr - position', data = dflog).fit()
      4 print(model.params)

~\Anaconda3\lib\site-packages\statsmodels\base\model.py in from_formula(cls, formula, data, subset, drop_cols, *args, **kwargs)
    153 
    154         tmp = handle_formula_data(data, None, formula, depth=eval_env,
--> 155                                   missing=missing)
    156         ((endog, exog), missing_idx, design_info) = tmp
    157 

~\Anaconda3\lib\site-packages\statsmodels\formula\formulatools.py in handle_formula_data(Y, X, formula, depth, missing)
     63         if data_util._is_using_pandas(Y, None):
     64             result = dmatrices(formula, Y, depth, return_type='dataframe',
---> 65                                NA_action=na_action)
     66         else:
     67             result = dmatrices(formula, Y, depth, return_type='dataframe',

~\Anaconda3\lib\site-packages\patsy\highlevel.py in dmatrices(formula_like, data, eval_env, NA_action, return_type)
    310                                       NA_action, return_type)
    311     if lhs.shape[1] == 0:
--> 312         raise PatsyError("model is missing required outcome variables")
    313     return (lhs, rhs)

PatsyError: model is missing required outcome variables
Python 3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.



md5-d488d43a30761ff511f61876ecfb2166



Requirement already satisfied: patsy in c:\users\esti\anaconda3\lib\site-packages (0.5.1)
Requirement already satisfied: six in c:\users\esti\anaconda3\lib\site-packages (from patsy) (1.12.0)
Requirement already satisfied: numpy>=1.4 in c:\users\esti\anaconda3\lib\site-packages (from patsy) (1.16.2)

Any thoughts ?
Thanks.

Most helpful comment

ctr - position needs to be ctr ~ position You have a minus when you need a tilde.

All 2 comments

ctr - position needs to be ctr ~ position You have a minus when you need a tilde.

Thanks. my bad.

Was this page helpful?
0 / 5 - 0 ratings