
Extract a Balanced Panel
get_balanced_panel.RdThis function extracts a balanced panel from the data for a specific adoption cohort. It drops units with missing observations at any point within its entire specified window (leads + adoption time, adoption time + lags). Units treated in the same period as the adoption cohort are marked as "treated," and units with their first treatment after the leads time of the specified adoption cohort are marked as "control."
Usage
get_balanced_panel(
data = data,
adoption_cohort,
lags,
leads,
time_var,
unit_id_var,
treated_period_var,
filter_units = TRUE
)Arguments
- data
The dataset to be used.
- adoption_cohort
Numeric, the specific adoption cohort.
- lags
Numeric, the number of lags.
- leads
Numeric, the number of leads.
- time_var
String, the name of the time variable.
- unit_id_var
String, the name of the unit ID variable.
- treated_period_var
String, the name of the treated period variable.
- filter_units
Logical, whether to filter only units with data on all time periods within the specified time window. Defaults to TRUE.
Examples
if (FALSE) { # \dontrun{
get_balanced_panel(data = fixest::base_stagg,
adoption_cohort = 5,
lags = 2,
leads = 3,
time_var = "year",
unit_id_var = "id",
treated_period_var = "year_treated")
} # }