0

Having a multiindex dataframe with the index1: shops, index2: DateTime, and column: LogPrice, I want to take the EntityEffects and TimeEffects out of the data by estimating the residuals of the fixed effects model.

yit = constant + αi + δt + εit

LogPrice = Constant + EntityEffects + TimeEffects + Error

I am using the following code:

from linearmodels import PanelOLS
mod = PanelOLS.from_formula('LogPrice ~ 1 + EntityEffects + TimeEffects', data=data1)
print(mod.fit())

I get this error:

File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-
packages/linearmodels/iv/model.py", line 290 
p1 = (x.T @ x) * (1 - kappa) + kappa * ((x.T @ z) @ (pinvz @ x))
          ^
SyntaxError: invalid syntax

Could you help me to fix the problem, or do you know a work around? Many thanks in advance.

JaminSore
  • 3,758
  • 1
  • 25
  • 21
domod
  • 1
  • 2
  • Note: for fixed effects models you could also just use statsmodels OLS and use the formulas to create the dummy arrays for fixed effects. Additionally, you can use cluster or panel robust standard errors. – Josef Apr 27 '17 at 04:05

1 Answers1

1

linearmodels requires Python 3.5+, and you're using Python 3.4. From the requirements

Running

With the exception of Python 3.5+, which is a hard requirement, the others are the version that are being used in the test environment. It is possible that older versions work.

  • Python 3.5+: extensive use of @ operator
  • NumPy (1.11+)
  • SciPy (0.17+)
  • Pandas (0.19+)
  • xarray (0.9+)
  • Statsmodels (0.8+)
Community
  • 1
  • 1
JaminSore
  • 3,758
  • 1
  • 25
  • 21