bashtage / linearmodels

Additional linear models including instrumental variable and panel data models that are missing from statsmodels.
https://bashtage.github.io/linearmodels/
University of Illinois/NCSA Open Source License
946 stars 184 forks source link

Effects option does not take effects for predict method? #260

Open FeiYao-Edinburgh opened 4 years ago

FeiYao-Edinburgh commented 4 years ago

Hi there,

I am using linearmodels to modelling panel data. I just found that the predict method returned me exactly identical results whether I set effects option True or False. They are identical to fitted_values, too, if predictions were made on model data. I believe they are all predictions made by slope and common constant only? Below I provide my codes and relevant outputs for you to check. If no difference, then I do not comprehend the significance of effects option. Or does this option has some other meanings that I do not know?

from linearmodels.panel import PanelOLS exog_vars = ["expersq", "union", "married"] exog = sm.add_constant(data[exog_vars]) mod = PanelOLS(data.lwage, exog, entity_effects=True) fe_res = mod.fit()

fe_res.predict(exog.head(), effects = False) fe_res.predict(exog.head(), effects = True) fe_res.fitted_values.head()


- Outputs
![image](https://user-images.githubusercontent.com/43779303/77660053-c035e800-6f70-11ea-81bd-ae95ccae8e75.png)

Thanks in advance!
bashtage commented 4 years ago

Effects are errors and so are not part of the prediction. They are not consistently estimated in the classic fixed T, large N setting. If one dimension is fixed and the other is large, so that the fixed dimension can be consistently estimated, then include these are dummy variables (e.g., time dummies in a large N setting.

bashtage commented 4 years ago

But yes, this seems suspicion.

FeiYao-Edinburgh commented 4 years ago

Effects are errors and so are not part of the prediction.

Thanks for your clarification!

bashtage commented 4 years ago

I need to check what this is supposed to do; at a minimum the docstring is inadequate.

bashtage commented 4 years ago

Thanks for the report!

bashtage commented 4 years ago

And the reproducible example.