statsmodel: panel regression
Asked Answered
M

1

6

I am currently using from pandas.stats.plm import PanelOLS to run Panel regressions. I am needing to switch to statsmodel so that I can ouput heteroskedastic robust results. I have been unable to find notation on calling a panel regression for statsmodel. In general, I find the documentation for statsmodel not very user friendly. Is someone familiar with panel regression syntax in statsmodel?

Mccracken answered 16/5, 2016 at 10:47 Comment(0)
S
3

The linearmodels package is created to extend the statsmodels package to panelOLS (see https://github.com/bashtage/linearmodels). Here is the example from the package doc:

import numpy as np
from statsmodels.datasets import grunfeld
data = grunfeld.load_pandas().data
data.year = data.year.astype(np.int64)
# MultiIndex, entity - time
data = data.set_index(['firm','year'])
from linearmodels import PanelOLS
mod = PanelOLS(data.invest, data[['value','capital']], entity_effect=True)
res = mod.fit(cov_type='clustered', cluster_entity=True)

Best Daniel

Shurlocke answered 18/9, 2017 at 12:33 Comment(1)
Add group_debias=True to the last line if you want small-number of groups adjustment for clustered standard errors.Compendious

© 2022 - 2024 — McMap. All rights reserved.