def summary(self): """:obj:`statsmodels.iolib.summary.Summary` : Summary table of model estimation results Supports export to csv, html and latex using the methods ``summary.as_csv()``, ``summary.as_html()`` and ``summary.as_latex()``. """ title = 'System ' + self._method + ' Estimation Summary' top_left = [('Estimator:', self._method), ('No. Equations.:', str(len(self.equation_labels))), ('No. Observations:', str(self.resids.shape[0])), ('Date:', self._datetime.strftime('%a, %b %d %Y')), ('Time:', self._datetime.strftime('%H:%M:%S')), ('', ''), ('', '')] top_right = [('Overall R-squared:', _str(self.rsquared)), ('Cov. Estimator:', self._cov_type), ('Num. Constraints: ', self._num_constraints), ('', ''), ('', ''), ('', ''), ('', '')] stubs = [] vals = [] for stub, val in top_left: stubs.append(stub) vals.append([val]) table = SimpleTable(vals, txt_fmt=fmt_2cols, title=title, stubs=stubs) # create summary table instance smry = Summary() # Top Table # Parameter table fmt = fmt_2cols fmt['data_fmts'][1] = '%10s' top_right = [('%-21s' % (' ' + k), v) for k, v in top_right] stubs = [] vals = [] for stub, val in top_right: stubs.append(stub) vals.append([val]) table.extend_right(SimpleTable(vals, stubs=stubs)) smry.tables.append(table) for i, eqlabel in enumerate(self.equation_labels): last_row = i == (len(self.equation_labels) - 1) results = self.equations[eqlabel] dep_name = results.dependent title = 'Equation: {0}, Dependent Variable: {1}'.format( eqlabel, dep_name) pad_bottom = results.instruments is not None and not last_row smry.tables.append( param_table(results, title, pad_bottom=pad_bottom)) if results.instruments: formatted = format_wide(results.instruments, 80) if not last_row: formatted.append([' ']) smry.tables.append( SimpleTable(formatted, headers=['Instruments'])) extra_text = ['Covariance Estimator:'] for line in str(self._cov_estimator).split('\n'): extra_text.append(line) if self._weight_estimtor: extra_text.append('Weight Estimator:') for line in str(self._weight_estimtor).split('\n'): extra_text.append(line) smry.add_extra_txt(extra_text) return smry
def test_format_wide(): k = 26 inputs = [chr(65 + i) * (20 + i) for i in range(k)] out = format_wide(inputs, 80) assert max(map(lambda v: len(v), out)) <= 80
def summary(self) -> Summary: """ Model estimation summary. Returns ------- Summary Summary table of model estimation results Supports export to csv, html and latex using the methods ``summary.as_csv()``, ``summary.as_html()`` and ``summary.as_latex()``. """ title = "System " + self._method + " Estimation Summary" top_left = [ ("Estimator:", self._method), ("No. Equations.:", str(len(self.equation_labels))), ("No. Observations:", str(self.resids.shape[0])), ("Date:", self._datetime.strftime("%a, %b %d %Y")), ("Time:", self._datetime.strftime("%H:%M:%S")), ("", ""), ("", ""), ] top_right = [ ("Overall R-squared:", _str(self.rsquared)), ("McElroy's R-squared:", _str(self.system_rsquared.mcelroy)), ("Judge's (OLS) R-squared:", _str(self.system_rsquared.judge)), ("Berndt's R-squared:", _str(self.system_rsquared.berndt)), ("Dhrymes's R-squared:", _str(self.system_rsquared.dhrymes)), ("Cov. Estimator:", self._cov_type), ("Num. Constraints: ", self._num_constraints), ] stubs = [] vals = [] for stub, val in top_left: stubs.append(stub) vals.append([val]) table = SimpleTable(vals, txt_fmt=fmt_2cols, title=title, stubs=stubs) # create summary table instance smry = Summary() # Top Table # Parameter table fmt = fmt_2cols fmt["data_fmts"][1] = "%10s" top_right = [("%-21s" % (" " + k), v) for k, v in top_right] stubs = [] vals = [] for stub, val in top_right: stubs.append(stub) vals.append([val]) table.extend_right(SimpleTable(vals, stubs=stubs)) smry.tables.append(table) for i, eqlabel in enumerate(self.equation_labels): last_row = i == (len(self.equation_labels) - 1) results = self.equations[eqlabel] dep_name = results.dependent title = "Equation: {0}, Dependent Variable: {1}".format( eqlabel, dep_name) pad_bottom = results.instruments is not None and not last_row smry.tables.append( param_table(results, title, pad_bottom=pad_bottom)) if results.instruments: formatted = format_wide(results.instruments, 80) if not last_row: formatted.append([" "]) smry.tables.append( SimpleTable(formatted, headers=["Instruments"])) extra_text = ["Covariance Estimator:"] for line in str(self._cov_estimator).split("\n"): extra_text.append(line) if self._weight_estimtor: extra_text.append("Weight Estimator:") for line in str(self._weight_estimtor).split("\n"): extra_text.append(line) smry.add_extra_txt(extra_text) return smry