BLMVarianceDecomposition class

class pytwoway.blm.BLMVarianceDecomposition(params)

Bases: object

Class for estimating BLM variance decomposition using bootstrapping.

Parameters

params (ParamsDict) – dictionary of parameters for BLM estimation. Run tw.blm_params().describe_all() for descriptions of all valid parameters.

fit(jdata, sdata, blm_model=None, n_samples=5, n_init_estimator=20, n_best=5, reallocate=False, reallocate_jointly=True, reallocate_period='first', Q_var=None, Q_cov=None, firm_clusters_as_ids=True, worker_types_as_ids=True, ncore=1, rng=None)

Estimate variance decomposition.

Parameters
  • jdata (BipartitePandas DataFrame) – event study or collapsed event study format labor data for movers

  • sdata (BipartitePandas DataFrame) – event study or collapsed event study format labor data for stayers

  • blm_model (BLMModel or None) – BLM model estimated using true data; if None, estimate model inside the method

  • n_samples (int) – number of bootstrap samples to estimate

  • n_init_estimator (int) – number of starting guesses to estimate for each bootstrap sample

  • n_best (int) – take the n_best estimates with the highest likelihoods, and then take the estimate with the highest connectedness, for each bootstrap sample

  • reallocate (bool) – if True, draw worker type proportions independently of firm type; if False, uses worker type proportions that are conditional on firm type

  • reallocate_jointly (bool) – if True, worker type proportions take the average over movers and stayers (i.e. all workers use the same type proportions); if False, consider movers and stayers separately

  • reallocate_period (str) – if ‘first’, compute type proportions based on first period parameters; if ‘second’, compute type proportions based on second period parameters; if ‘all’, compute type proportions based on average over first and second period parameters

  • Q_var (list of Q variances) – list of Q matrices to use when estimating variance term; None is equivalent to tw.Q.VarPsi() without controls, or tw.Q.VarCovariate(‘psi’) with controls

  • Q_cov (list of Q covariances) – list of Q matrices to use when estimating covariance term; None is equivalent to tw.Q.CovPsiAlpha() without controls, or tw.Q.CovCovariate(‘psi’, ‘alpha’) with controls

  • firm_clusters_as_ids (bool) – if True, regress on firm clusters; if False, regress on firm ids

  • worker_types_as_ids (bool) – if True, regress on true, simulated worker types; if False, regress on worker ids

  • ncore (int) – number of cores for multiprocessing

  • rng (np.random.Generator or None) – NumPy random number generator; None is equivalent to np.random.default_rng(None)