I'm trying to run a fixed-effects model using panel data, here is a sample of my data:
| type | id | time | treatment | employment | wage |
|---|---|---|---|---|---|
| 0 | 1 | 0 | 0 | 30.0 | NaN |
| 1 | 1 | 1 | 1 | 3.5 | 4.30 |
| 2 | 2 | 0 | 0 | 6.5 | NaN |
| 3 | 2 | 1 | 0 | NaN | 4.45 |
| 4 | 3 | 0 | 1 | 3.0 | NaN |
And this is the code I am using:
model_fe = PanelOLS.from_formula('employment ~ wage + EntityEffects', final_data)
However, I'm getting the error
FactorEvaluationError: Unable to evaluate factor `employment`. [NameError: `employment` is not present in the dataset or evaluation context.]
I'm unsure why this is happening, any help would be much appreciated.
Panel OLS usually is on muli-index, the first one being your type or id, and the second index needs to be time. So if you just
set_index()your code will work: