2

I have a panel database and would like to run a regression considering fixed effects. When using Panel.Ols, two fixed effects work without problems.

My code looks like this:

df['countyCode'] = pd.Categorical(df['countyCode'])
df['state'] = pd.Categorical(df['state'])
df1 = df.set_index(['crdFirm','year'])
Y = 'income'
formula = Y + ' ~ 1 +  experience + tenureFirm + EntityEffects + TimeEffects'
mod = PanelOLS.from_formula(formula, df1, other_effects= df1[['countyCode']])
res = mod.fit()

However, I then receive the following error message when I try to use more than two fixed effects:

ValueError: At most two effects supported.

How can I run a panel regression with more than two fixed effects without getting this error message?

Henry Ecker
  • 34,399
  • 18
  • 41
  • 57
Stefan
  • 21
  • 2
  • 1
    The easiest solution is to include any additional effects as part of the model. Usually you want to include the effects with the smallest number of categories as part of the regressors since these are directly constructed. The alternative is to use [`AbsorbingLS`](https://bashtage.github.io/linearmodels/iv/absorbing/linearmodels.iv.absorbing.AbsorbingLS.html) to absorb the fixed effects and then you get the same parameter estimates as-if you estimated the model with many FE. – Kevin S Jan 18 '22 at 09:43
  • @KevinS for posterity, could you please make your comment an answer? – ebosi Oct 19 '22 at 09:05

0 Answers0