Trim a panel to a balanced rectangle
panel_balance.RdReduces a panel to a balanced set: a block of years in which every retained
organization is observed in every retained year. Balancing trims (drops
organizations and/or years) – the complement of panel_complete(), which
fills gaps instead.
Usage
panel_balance(
data,
years = NULL,
strategy = c("window", "max_rectangle"),
min_years = 2L,
id = "EIN2",
time = "TAX_YEAR"
)Value
The balanced rows, with a "balance" attribute listing the retained
years and the organization keep/drop counts.
Details
The year window is the trade-off lever. A wide window keeps more years but fewer organizations; a narrow one keeps more organizations. Two strategies:
"window"Balance over
years(or, by default, the full observed range): keep only organizations observed in every one of those years, and drop the other years."max_rectangle"Search contiguous year windows (within
yearsif given) and pick the one that maximizes retained observations (organizations x years), subject tomin_years.