How can I import entity_effects and time_effects from PanelOLS?

75 views Asked by At

When I run the code:

from linearmodels.panel import PanelOLS, PooledOLS
from linearmodels.panel import EntityEffects, TimeEffects

I get the error:

ImportError: cannot import name 'EntityEffects' from 'linearmodels.panel' (/opt/anaconda3/lib/python3.9/site-packages/linearmodels/panel/__init__.py)

I'm trying to do PanelOLS controlling entity effects and time effects as below.

model_with_entity_and_time_pcse = PanelOLS.from_formula(f'{dependent_variable} ~ {" + ".join(independent_variables)}', data=df_final, entity_effects=True, time_effects=True).fit(cov_type='kernel')

Can you help me import the functions?

1

There are 1 answers

1
Balaji Srinivasan On

ImportError: cannot import name 'EntityEffects' from 'linearmodels.panel' (/opt/anaconda3/lib/python3.9/site-packages/linearmodels/panel/init.py)

This error clearly states that EntityEffects is not part of linearmodels package.

from linearmodels.panel import PanelOLS, PooledOLS

from linearmodels.panel import EntityEffects, TimeEffects // remove this line

EntityEffects, TimeEffects are not part of linearmodels package. so remove that line to get rid of this error.