Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get different Standard Errors from AbsorbingLS and PanelOLS #432

Open
huicaikrz opened this issue Jun 5, 2022 · 3 comments
Open

Get different Standard Errors from AbsorbingLS and PanelOLS #432

huicaikrz opened this issue Jun 5, 2022 · 3 comments

Comments

@huicaikrz
Copy link

huicaikrz commented Jun 5, 2022

I do fixed effect regression (time effect+entity effect) with AbsorbingLS as well as PanelOLS, I get same coefficient while the standard errors seems to be quite different. I tried different settings, like "clustered" with entity and time effect / robust/
unadjusted, but they are always different.

I checked source code and it seems that standard errors of the two models are relaized in different py file. May I know the difference? Since I thought that the stand errors should be same.

Thanks.

@bashtage
Copy link
Owner

bashtage commented Jun 5, 2022

They are different. Which standard errors are you using for the Panel model? Can you post a code example that shows the differences you are seeing?

@huicaikrz
Copy link
Author

huicaikrz commented Jun 11, 2022

Here's the sample code. I use the sample dataset from statsmodels and test three different settings of standard errors. They are all quite different. Among the three settings, I am quite interested in standard errors with "cov_type='clustered'".

from linearmodels import AbsorbingLS, PanelOLS
import numpy as np
import pandas as pd

from statsmodels.datasets import grunfeld
data = grunfeld.load_pandas().data
data.year = data.year.astype(np.int64)
data = data.set_index(['firm','year'], drop=False)
mod_panel = PanelOLS(data.invest, data[['value','capital']], entity_effects=True, time_effects=True)
res_panel1 = mod_panel.fit(cov_type='clustered', cluster_entity=True, cluster_time=True)
res_panel2 = mod_panel.fit(cov_type='robust')
res_panel3 = mod_panel.fit(cov_type='unadjusted')

cats = pd.DataFrame(pd.Categorical(data[col]) for col in ["firm", "year"])
mod_absorb = AbsorbingLS(data.invest, data[['value', 'capital']], absorb=cats)
for col in cats.columns:
    cats[col] = cats[col].astype('category').cat.codes
res_absorb1 = mod_absorb.fit(method='lsmr', cov_type='clustered', clusters=cats)
res_absorb2 = mod_absorb.fit(cov_type='robust')
res_absorb3 = mod_absorb.fit(cov_type='unadjusted')

print(res_panel1.summary, "\n\n")
print(res_absorb1.summary, "\n\n")
print(res_panel2.summary, "\n\n")
print(res_absorb2.summary, "\n\n")
print(res_panel3.summary, "\n\n")
print(res_absorb3.summary, "\n\n")`

@bashtage
Copy link
Owner

Thanks for the code. I can see they are different, but will need more time to determine. I suspect that the issue is a DoF correction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants