# did.estimation.lpdid

`did.estimation.lpdid(data, yname, idname, tname, gname, vcov=None, pre_window=None, post_window=None, never_treated=0, att=True, xfml=None)`

Local projections approach to estimation.

Estimate a Difference-in-Differences / Event Study Model via the Local Projections Approach.

## Parameters

Name | Type | Description | Default
--- | --- | --- | ---
`data` | DataFrame | The DataFrame containing all variables. | required
`yname` | str | The name of the dependent variable. | required
`idname` | str | The name of the id variable. | required
`tname` | str | Variable name for calendar period. | required
`gname` | str | Unit-specific time of initial treatment. | required
`vcov` | (str, dict) | The type of inference to employ. Defaults to {“CRV1”: idname}. Options include “iid”, “hetero”, or a dictionary like {“CRV1”: idname}. | `None`
`pre_window` | int | The number of periods before the treatment to include in the estimation. Default is the minimum relative year in the data. | `None`
`post_window` | int | The number of periods after the treatment to include in the estimation. Default is the maximum relative year in the data. | `None`
`never_treated` | int | Value in gname indicating units never treated. Default is 0. | `0`
`att` | bool | If True, estimates the pooled average treatment effect on the treated (ATT). Default is False. | `True`
`xfml` | str | Formula for the covariates. Not yet supported. | `None`

## Returns

Type | Description
--- | ---
DataFrame | A DataFrame with the estimated coefficients.

## Examples

    import pandas as pd
    from pyfixest.did.estimation import lpdid

    url = "https://raw.githubusercontent.com/py-econometrics/pyfixest/master/pyfixest/did/data/df_het.csv"
    df_het = pd.read_csv(url)

    fit = lpdid(
        df_het,
        yname="dep_var",
        idname="unit",
        tname="year",
        gname="g",
        vcov={"CRV1": "state"},
        pre_window=-20,
        post_window=20,
        att=False
    )

    fit.tidy().head()
    fit.iplot(figsize= [1200, 400], coord_flip=False).show()

To get the ATT, set `att=True`:

    fit = lpdid(
        df_het,
        yname="dep_var",
        idname="unit",
        tname="year",
        gname="g",
        vcov={"CRV1": "state"},
        pre_window=-20,
        post_window=20,
        att=True
    )
    fit.tidy()

| Estimate | Std. Error | t value | Pr(>|t|) | 2.5% | 97.5% | N
--- | --- | --- | --- | --- | --- | --- | ---
treat_diff | 2.506746 | 0.071357 | 35.129648 | 0.0 | 2.362413 | 2.65108 | 5716.0