bashtage/linearmodels

ENH: Remove constraint on the number of fixed effects

LulinS opened this issue · 1 comments

I am wondering if it's possible to remove the constraint on the number of fixed effects in PanelOLS().

I think that some how you can overcome the issue by creating a column that merges the various categorical variables that you want to add as fixed effects.

Let's say you want to study how the crime_rate is influenced by the number of police_stations within 5 km from the crimes occurencies. The variables available are neighborhoods, cities , states (also time of occurence is a variable itself)

Normally you could set only one among neighborhoods, cities, states as fixed effect. However, you could simply set the 3 components as an unique index of the panel, as follows:

df['unique_index'] = df['neighborhoods'] +"_"+ df['cities']+ "_"+ df['states'] 
df= df.set_index(['unique_index', 'month_year'])

However this applies only if we have not individuals, which are already unique by definition.