API Reference#

class specification_curve.SpecificationCurve(df: pandas.core.frame.DataFrame, y_endog: Union[str, List[str]], x_exog: Union[str, List[str]], controls: List[str], exclu_grps: List[List[None]] = [[]], cat_expand: Union[str, List[None]] = [], always_include: List[str] = [])[source]#

Specification curve object. Uses a model to perform all variants of a specification. Stores the results of those regressions in a tidy format pandas dataframe. Plots the regressions in chart that can optionally be saved. Will iterate over multiple inputs for exog. and endog. variables. Note that categorical variables that are expanded cannot be mutually excluded from other categorical variables that are expanded.

fit(estimator=<class 'statsmodels.regression.linear_model.OLS'>) None[source]#

Fits a specification curve by performing regressions. :param estimator: statsmodels estimator. Defaults to sm.OLS. :type estimator: statsmodels.regression.linear_model or statsmodels.discrete.discrete_model, optional

plot(save_path=None, pretty_plots: bool = True, preferred_spec: List[None] = []) None[source]#

Makes plots of fitted specification curve. :param save_path: Exported fig filename. Defaults to None. :type save_path: _type_, optional :param pretty_plots: whether to use this package’s figure formatting. Defaults to True. :type pretty_plots: bool, optional :param preferred_spec: preferred specification. Defaults to []. :type preferred_spec: list, optional

specification_curve.load_example_data1() pandas.core.frame.DataFrame[source]#

Retrieves example data from a file included with the package. :returns: Example data suitable for regression. :rtype: pd.DataFrame

specification_curve.load_example_data2() pandas.core.frame.DataFrame[source]#

Generates fake data. :returns: Example data suitable for regression. :rtype: pd.DataFrame