How to use the linearmodels.utility.pval_format function in linearmodels

To help you get started, we’ve selected a few linearmodels examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bashtage / linearmodels / linearmodels / panel / results.py View on Github external
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()``.
        """

        smry = super(PanelEffectsResults, self).summary

        is_invalid = np.isfinite(self.f_pooled.stat)
        f_pool = _str(self.f_pooled.stat) if is_invalid else '--'
        f_pool_pval = pval_format(self.f_pooled.pval) if is_invalid else '--'
        f_pool_name = self.f_pooled.dist_name if is_invalid else '--'

        extra_text = []
        if is_invalid:
            extra_text.append('F-test for Poolability: {0}'.format(f_pool))
            extra_text.append('P-value: {0}'.format(f_pool_pval))
            extra_text.append('Distribution: {0}'.format(f_pool_name))
            extra_text.append('')

        if self.included_effects:
            effects = ', '.join(self.included_effects)
            extra_text.append('Included effects: ' + effects)

        if self.other_info is not None:
            ncol = self.other_info.shape[1]
            extra_text.append('Model includes {0} other effects'.format(ncol))
github bashtage / linearmodels / linearmodels / asset_pricing / results.py View on Github external
def _single_table(params, se, name, param_names, first=False):
        tstats = (params / se)
        pvalues = 2 - 2 * stats.norm.cdf(tstats)
        ci = params + se * stats.norm.ppf([[0.025, 0.975]])
        param_data = np.c_[params, se, tstats, pvalues, ci]

        data = []
        for row in param_data:
            txt_row = []
            for i, v in enumerate(row):
                f = _str
                if i == 3:
                    f = pval_format
                txt_row.append(f(v))
            data.append(txt_row)
        title = '{0} Coefficients'.format(name)
        table_stubs = param_names
        if first:
            header = ['Parameter', 'Std. Err.', 'T-stat', 'P-value', 'Lower CI', 'Upper CI']
        else:
            header = None
        table = SimpleTable(data, stubs=table_stubs, txt_fmt=fmt_params, headers=header,
                            title=title)

        return table
github bashtage / linearmodels / linearmodels / system / results.py View on Github external
title = self._method + ' Estimation Summary'

        top_left = [('Eq. Label:', self.equation_label),
                    ('Dep. Variable:', self.dependent),
                    ('Estimator:', self._method),
                    ('No. Observations:', self.nobs),
                    ('Date:', self._datetime.strftime('%a, %b %d %Y')),
                    ('Time:', self._datetime.strftime('%H:%M:%S')),

                    ('', '')]

        top_right = [('R-squared:', _str(self.rsquared)),
                     ('Adj. R-squared:', _str(self.rsquared_adj)),
                     ('Cov. Estimator:', self._cov_type),
                     ('F-statistic:', _str(self.f_statistic.stat)),
                     ('P-value (F-stat)', pval_format(self.f_statistic.pval)),
                     ('Distribution:', str(self.f_statistic.dist_name)),
                     ('', '')]

        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'
github bashtage / linearmodels / linearmodels / panel / results.py View on Github external
('Min Obs:', _str(self.entity_info['min'])),
                    ('Max Obs:', _str(self.entity_info['max'])),
                    ('', ''),
                    ('Time periods:', str(int(self.time_info['total']))),
                    ('Avg Obs:', _str(self.time_info['mean'])),
                    ('Min Obs:', _str(self.time_info['min'])),
                    ('Max Obs:', _str(self.time_info['max'])),
                    ('', '')]

        is_invalid = np.isfinite(self.f_statistic.stat)
        f_stat = _str(self.f_statistic.stat) if is_invalid else '--'
        f_pval = pval_format(self.f_statistic.pval) if is_invalid else '--'
        f_dist = self.f_statistic.dist_name if is_invalid else '--'

        f_robust = _str(self.f_statistic_robust.stat) if is_invalid else '--'
        f_robust_pval = pval_format(self.f_statistic_robust.pval) if is_invalid else '--'
        f_robust_name = self.f_statistic_robust.dist_name if is_invalid else '--'

        top_right = [('R-squared:', _str(self.rsquared)),
                     ('R-squared (Between):', _str(self.rsquared_between)),
                     ('R-squared (Within):', _str(self.rsquared_within)),
                     ('R-squared (Overall):', _str(self.rsquared_overall)),
                     ('Log-likelihood', _str(self._loglik)),
                     ('', ''),
                     ('F-statistic:', f_stat),
                     ('P-value', f_pval),
                     ('Distribution:', f_dist),
                     ('', ''),
                     ('F-statistic (robust):', f_robust),
                     ('P-value', f_robust_pval),
                     ('Distribution:', f_robust_name),
                     ('', ''),
github bashtage / linearmodels / linearmodels / asset_pricing / results.py View on Github external
Supports export to csv, html and latex  using the methods ``summary.as_csv()``,
        ``summary.as_html()`` and ``summary.as_latex()``.
        """

        title = self.name + ' Estimation Summary'

        top_left = [('No. Test Portfolios:', len(self._portfolio_names)),
                    ('No. Factors:', len(self._factor_names)),
                    ('No. Observations:', self.nobs),
                    ('Date:', self._datetime.strftime('%a, %b %d %Y')),
                    ('Time:', self._datetime.strftime('%H:%M:%S')),
                    ('Cov. Estimator:', self._cov_type),
                    ('', '')]

        j_stat = _str(self.j_statistic.stat)
        j_pval = pval_format(self.j_statistic.pval)
        j_dist = self.j_statistic.dist_name

        top_right = [('R-squared:', _str(self.rsquared)),
                     ('J-statistic:', j_stat),
                     ('P-value', j_pval),
                     ('Distribution:', j_dist),
                     ('', ''),
                     ('', ''),
                     ('', '')]

        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)
github bashtage / linearmodels / linearmodels / iv / results.py View on Github external
def _top_right(self):
        f_stat = _str(self.f_statistic.stat)
        if isnan(self.f_statistic.stat):
            f_stat = '      N/A'

        return [('R-squared:', _str(self.rsquared)),
                ('Adj. R-squared:', _str(self.rsquared_adj)),
                ('F-statistic:', f_stat),
                ('P-value (F-stat):', pval_format(self.f_statistic.pval)),
                ('Distribution:', str(self.f_statistic.dist_name)),
                ('R-squared (No Effects):', _str(round(self.absorbed_rsquared, 5))),
                ('Varaibles Absorbed:', _str(self.df_absorbed))
                ]
github bashtage / linearmodels / linearmodels / iv / results.py View on Github external
def _top_right(self):
        f_stat = _str(self.f_statistic.stat)
        if isnan(self.f_statistic.stat):
            f_stat = '      N/A'

        return [('R-squared:', _str(self.rsquared)),
                ('Adj. R-squared:', _str(self.rsquared_adj)),
                ('F-statistic:', f_stat),
                ('P-value (F-stat)', pval_format(self.f_statistic.pval)),
                ('Distribution:', str(self.f_statistic.dist_name)),
                ('', ''),
                ('', '')]
github bashtage / linearmodels / linearmodels / panel / results.py View on Github external
('Cov. Estimator:', self._cov_type),
                    ('', ''),
                    ('Entities:', str(int(self.entity_info['total']))),
                    ('Avg Obs:', _str(self.entity_info['mean'])),
                    ('Min Obs:', _str(self.entity_info['min'])),
                    ('Max Obs:', _str(self.entity_info['max'])),
                    ('', ''),
                    ('Time periods:', str(int(self.time_info['total']))),
                    ('Avg Obs:', _str(self.time_info['mean'])),
                    ('Min Obs:', _str(self.time_info['min'])),
                    ('Max Obs:', _str(self.time_info['max'])),
                    ('', '')]

        is_invalid = np.isfinite(self.f_statistic.stat)
        f_stat = _str(self.f_statistic.stat) if is_invalid else '--'
        f_pval = pval_format(self.f_statistic.pval) if is_invalid else '--'
        f_dist = self.f_statistic.dist_name if is_invalid else '--'

        f_robust = _str(self.f_statistic_robust.stat) if is_invalid else '--'
        f_robust_pval = pval_format(self.f_statistic_robust.pval) if is_invalid else '--'
        f_robust_name = self.f_statistic_robust.dist_name if is_invalid else '--'

        top_right = [('R-squared:', _str(self.rsquared)),
                     ('R-squared (Between):', _str(self.rsquared_between)),
                     ('R-squared (Within):', _str(self.rsquared_within)),
                     ('R-squared (Overall):', _str(self.rsquared_overall)),
                     ('Log-likelihood', _str(self._loglik)),
                     ('', ''),
                     ('F-statistic:', f_stat),
                     ('P-value', f_pval),
                     ('Distribution:', f_dist),
                     ('', ''),