```{python}
import pandas as pd

import pyfixest as pf
```

### Chapter 14: Panel Data and Fixed Effects

In this example we replicate the results of the great (freely available reference!) Causal Inference for the Brave and True - Chapter 14. Please refer to the original text for a detailed explanation of the data.

```{python}
data_path = "https://raw.githubusercontent.com/bashtage/linearmodels/main/linearmodels/datasets/wage_panel/wage_panel.csv.bz2"
data_df = pd.read_csv(data_path)

data_df.head()
```

We have a classical panel data set with units (nr) and time (year).

We are interested in estimating the effect of marriage status on log wage, using a set of controls (union, hours) and individual (nr) and year fixed effects.

```{python}
panel_fit = pf.feols(
    fml="lwage ~ married + expersq + union + hours | nr + year",
    data=data_df,
    vcov={"CRV1": "nr + year"},
    demeaner=pf.MapDemeaner(backend="rust"),
)
```

```{python}
pf.etable(panel_fit)
```

We obtain the same results as in the book!
