2 years ago
#54706
Stefan
Python panel data regression with more than two fixed effects
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?
python
pandas
linear-regression
panel-data
linearmodels
0 Answers
Your Answer