regtools.lag package

Submodules

regtools.lag.create module

regtools.lag.create.create_lagged_variables(df, lag_cols, id_col=None, date_col='Date', num_lags=1, fill_method='ffill', fill_limit=None)[source]

Note: partially inplace

regtools.lag.create.varname_to_lagged_varname(varname, num_lags=1)[source]
Return type

str

regtools.lag.main module

regtools.lag.main.create_lagged_variables_return_yvars_xvars_interaction_tuples(df, yvar, xvars, interaction_tuples=None, num_lags=0, lag_variables='xvars', lag_period_var='Date', lag_id_var='TICKER', fill_method='ffill', fill_limit=None)[source]
Return type

Tuple[DataFrame, str, Union[str, List[str]], Optional[List[Tuple[str, str]]], Union[str, List[str]]]

regtools.lag.plot module

regtools.lag.plot.interacted_lag_plot_from_lag_result_df(result_df, yvar, main_iv, date_var='Year', outpath=None, clear_figure=True)[source]

Creates a plot of effect of main_iv on yvar at different quantiles. To be used after reg_for_each_quantile_produce_result_df

Parameters
  • result_df – pd.DataFrame, result from reg_for_each_quantile_produce_result_df

  • yvar – str, label of dependent variable

  • main_iv – str, label of independent variable of interest

  • outpath – str, filepath to output figure. must include matplotlib supported extension such as .pdf or .png

  • clear_figure – bool, True wipe memory of matplotlib figure after running function

Returns

regtools.lag.plot.interacted_lag_plot_from_reg_result_list(results, lag_tuple, main_iv, interaction_tuples, yvar, interaction_var_value=13.27, date_var='Year', outpath=None, clear_figure=True)[source]
regtools.lag.plot.produce_simplified_result_df(results, lag_tuple, main_iv, interaction_tuples, interaction_var_value=13.27)[source]

regtools.lag.remove module

class regtools.lag.remove.SimplifiedBase[source]

Bases: object

class regtools.lag.remove.SimplifiedModel(**kwargs)[source]

Bases: regtools.lag.remove.SimplifiedBase

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

class regtools.lag.remove.SimplifiedRegressionResult(**kwargs)[source]

Bases: regtools.lag.remove.SimplifiedBase

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

direct_attrs = ['params', 'pvalues', 'tvalues', 'nobs', 'rsquared_adj', 'bse', 'conf_int', 'normalized_cov_params', 'cov_params_default', 'scale', 'cov_params', 't_test']
classmethod from_statsmodels_result(result)[source]
model_attrs = ['exog_names', 'endog_names']
classmethod pop_model_attrs(attr_dict)[source]

Note: pops from attr_dict inplace

exception regtools.lag.remove.UnsupportedResultAttributeException[source]

Bases: Exception

exception regtools.lag.remove.VariableIsNotLaggedVariableException[source]

Bases: Exception

regtools.lag.remove.lag_varname_to_varname(varname, num_lags=1)[source]
regtools.lag.remove.lag_varname_to_varname_and_lag(varname)[source]
Return type

Tuple[str, int]

regtools.lag.remove.remove_lag_names_from_reg_results(reg_list, lags=(1, ))[source]

Note: partially inplace