Attrition Utilities module

Classes for estimating attrition using increasing (building up from a fixed set of firms) or decreasing (with varying sets of firms) fractions of movers.

class pytwoway.attrition_utils.attrition_utils.AttritionDecreasing(subset_fractions=None)

Bases: object

Generate decreasing subsets of a dataset to estimate the effects of attrition. Do this by first drawing successively decreasing fractions of movers from the original dataset.

Parameters

subset_fractions (NumPy Array or None) – fractions of movers to consider for each subset. Must be (weakly) monotonically decreasing. None is equivalent to np.linspace(0.5, 0.1, 5).

class pytwoway.attrition_utils.attrition_utils.AttritionIncreasing(subset_fractions=None, n_subsample_draws=5, subsample_min_firms=20)

Bases: object

Generate increasing subsets of a dataset to estimate the effects of attrition. Do this by first drawing a given fraction of all movers. Fix the set of firms connected by these movers. Then, constructively rebuild the data by adding back successively increasing fractions of the previously dropped movers that belong to the fixed set of firms.

Parameters
  • subset_fractions (NumPy Array or None) – fractions of movers to consider for each subset. Must be (weakly) monotonically increasing. None is equivalent to np.linspace(0.1, 0.5, 5).

  • n_subsample_draws (int) – maximum number of attempts to draw a valid initial subsample (this is necessary because the random draw may ultimately drop too many observations)

  • subsample_min_firms (int) – minimum number of firms necessary for an initial subsample to be considered valid. This should be at least the number of clusters used when estimating the CRE model.