Python OLS model: __init__() missing 1 required positional argument: 'endog'
Asked Answered
C

1

6
import statsmodels.api as sm
xdat = rets['EUROSTOXX']
xdat = sm.add_constant(xdat)
ydat = rets['VSTOXX']
model = sm.OLS(y=ydat,x=xdat).fit()

I don't understand why there is an error popping up as stated on the topic. The following is the tail of the Dataframe of rets

Out[105]:
            EUROSTOXX   VSTOXX
2014-12-23  0.011835    -0.039307
2014-12-24  -0.002449   0.000000
2014-12-29  0.000160    0.121598
2014-12-30  -0.015574   0.048998
2014-12-31  0.003336    0.000000
Contredanse answered 26/12, 2017 at 12:26 Comment(0)
T
7

According to the documentation of OLS, the function's parameters aren't called y and x, but endog and exog. You can simply change your function call to:

model = sm.OLS(ydat, xdat).fit()

or:

model = sm.OLS(endog=ydat, exog=xdat).fit()
Tiphanie answered 26/12, 2017 at 13:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.