diff --git a/stargazer/stargazer.py b/stargazer/stargazer.py index 0bdc65e..404991e 100644 --- a/stargazer/stargazer.py +++ b/stargazer/stargazer.py @@ -144,6 +144,7 @@ def extract_data(self): for use or modification. They should not be able to be modified by any rendering parameters. """ + self.model_data = [] for m in self.models: self.model_data.append(self.extract_model_data(m)) @@ -344,7 +345,7 @@ class Renderer: def __init__(self, table, **kwargs): """ Initialize a new renderer. - + "table": Stargazer object to render """ diff --git a/stargazer/translators/__init__.py b/stargazer/translators/__init__.py index 33e70ee..090e87a 100644 --- a/stargazer/translators/__init__.py +++ b/stargazer/translators/__init__.py @@ -13,3 +13,10 @@ def register_class(klass, extractor): except ModuleNotFoundError: # linearmodels not found pass + +### PYFIXEST ### +try: + from .pyfixest import classes +except ModuleNotFoundError: + # pyfixest not found + pass \ No newline at end of file diff --git a/stargazer/translators/pyfixest.py b/stargazer/translators/pyfixest.py new file mode 100644 index 0000000..cc3aba7 --- /dev/null +++ b/stargazer/translators/pyfixest.py @@ -0,0 +1,52 @@ +""" +Compatibility layer with results from pyfixest. +""" + +from ..starlib import _extract_feature + +from . import register_class +from pyfixest.estimation.feols_ import Feols +from pyfixest.estimation.feiv_ import Feiv +from pyfixest.estimation.fepois_ import Fepois + +# For features that are simple attributes of "model", establish the +# mapping with internal name: + +pyfixest_map = { + 'r2' : '_r2', + 'cov_names' : '_coefnames', + 'nobs' : '_N', + } + +def extract_model_data(model): + + data = {} + for key, val in pyfixest_map.items(): + data[key] = _extract_feature(model, val) + + data['dependent_variable'] = model._fml.split("~")[0].replace(" ", "") + data['cov_values'] = model.coef() + data['cov_std_err'] = model.se() + data['p_values'] = model.pvalue() + data['conf_int_low_values'] = model.confint().iloc[:,0] + data['conf_int_high_values'] = model.confint().iloc[:,1] + + + data['resid_std_err'] = None + data['degree_freedom_resid'] = None + data["f_statistic"] = None + data["f_p_value"] = None + data["r2_adj"] = None + data["pseudo_r2"] = None + + return data + + +classes = [(Feols, extract_model_data), + (Fepois, extract_model_data), + (Feiv, extract_model_data) + ] + +for klass, translator in classes: + register_class(klass, translator) +