BLMModel class

class pytwoway.blm.BLMModel(params, rng=None)

Bases: object

Class for estimating BLM using a single set of starting values.

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

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

compute_connectedness_measure(all=False)

Computes graph connectedness measure among the movers within each type and updates self.connectedness to be the smallest value.

Parameters

all (bool) – if True, set self.connectedness to be the vector of connectedness for all worker types instead of the minimum

fit_A(jdata, compute_NNm=True)

Run fit_movers() and update A while keeping S and pk1 fixed.

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

  • compute_NNm (bool) – if True, compute matrix giving the number of movers who transition from one firm type to another (e.g. entry (1, 3) gives the number of movers who transition from firm type 1 to firm type 3)

fit_S(jdata, compute_NNm=True)

Run fit_movers() and update S while keeping A and pk1 fixed.

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

  • compute_NNm (bool) – if True, compute matrix giving the number of movers who transition from one firm type to another (e.g. entry (1, 3) gives the number of movers who transition from firm type 1 to firm type 3)

fit_movers(jdata, compute_NNm=True)

EM algorithm for movers.

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

  • compute_NNm (bool) – if True, compute matrix giving the number of movers who transition from one firm type to another (e.g. entry (1, 3) gives the number of movers who transition from firm type 1 to firm type 3)

fit_movers_cstr_uncstr(jdata, compute_NNm=True)

Run fit_movers(), first constrained, then using results as starting values, run unconstrained.

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

  • compute_NNm (bool) – if True, compute matrix giving the number of movers who transition from one firm type to another (e.g. entry (1, 3) gives the number of movers who transition from firm type 1 to firm type 3)

fit_pk(jdata, compute_NNm=True)

Run fit_movers() and update pk1 while keeping A and S fixed.

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

  • compute_NNm (bool) – if True, compute matrix giving the number of movers who transition from one firm type to another (e.g. entry (1, 3) gives the number of movers who transition from firm type 1 to firm type 3)

fit_stayers(sdata, compute_NNs=True)

EM algorithm for stayers.

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

  • compute_NNs (bool) – if True, compute vector giving the number of stayers at each firm type (e.g. entry (1) gives the number of stayers at firm type 1)

plot_log_earnings(period='first', grid=True, dpi=None)

Plot log-earnings by worker-firm type pairs.

Parameters
  • period (str) – ‘first’ plots log-earnings in the first period; ‘second’ plots log-earnings in the second period; ‘all’ plots the average over log-earnings in the first and second periods

  • grid (bool) – if True, plot grid

  • dpi (float or None) – dpi for plot

plot_type_proportions(period='first', subset='all', dpi=None)

Plot proportions of worker types at each firm class.

Parameters
  • period (str) – ‘first’ plots type proportions in the first period; ‘second’ plots type proportions in the second period; ‘all’ plots the average over type proportions in the first and second periods

  • subset (str) – ‘all’ plots a weighted average over movers and stayers; ‘movers’ plots movers; ‘stayers’ plots stayers

  • dpi (float or None) – dpi for plot