Пример #1
0
    def summary(self, alpha=0.05, float_format="%.3f", method="normal"):
        """
        A summary of all the main results.

        Parameters
        ----------
        alpha : float
            `1 - alpha` is the nominal coverage probability of the
            confidence intervals.
        float_format : str
            Used for formatting numeric values in the summary.
        method : str
            The method for producing the confidence interval.  Currently
            must be 'normal' which uses the normal approximation.
        """
        def fmt(x):
            if isinstance(x, str):
                return x
            return float_format % x

        co_lcb, co_ucb = self.oddsratio_pooled_confint(alpha=alpha,
                                                       method=method)
        clo_lcb, clo_ucb = self.logodds_pooled_confint(alpha=alpha,
                                                       method=method)
        headers = ["Estimate", "LCB", "UCB"]
        stubs = ["Pooled odds", "Pooled log odds", "Pooled risk ratio", ""]
        data = [[fmt(x) for x in [self.oddsratio_pooled, co_lcb, co_ucb]],
                [fmt(x) for x in [self.logodds_pooled, clo_lcb, clo_ucb]],
                [fmt(x) for x in [self.riskratio_pooled, "", ""]],
                ['', '', '']]
        tab1 = iolib.SimpleTable(data,
                                 headers,
                                 stubs,
                                 data_aligns="r",
                                 table_dec_above='')

        headers = ["Statistic", "P-value", ""]
        stubs = ["Test of OR=1", "Test constant OR"]
        rslt1 = self.test_null_odds()
        rslt2 = self.test_equal_odds()
        data = [[fmt(x) for x in [rslt1.statistic, rslt1.pvalue, ""]],
                [fmt(x) for x in [rslt2.statistic, rslt2.pvalue, ""]]]
        tab2 = iolib.SimpleTable(data, headers, stubs, data_aligns="r")
        tab1.extend(tab2)

        headers = ["", "", ""]
        stubs = ["Number of tables", "Min n", "Max n", "Avg n", "Total n"]
        ss = self.table.sum(0).sum(0)
        data = [["%d" % self.table.shape[2], '', ''], ["%d" % min(ss), '', ''],
                ["%d" % max(ss), '', ''], ["%.0f" % np.mean(ss), '', ''],
                ["%d" % sum(ss), '', '', '']]
        tab3 = iolib.SimpleTable(data, headers, stubs, data_aligns="r")
        tab1.extend(tab3)

        return tab1
Пример #2
0
    def summary(self, alpha=0.05, float_format="%.3f"):
        """
        Produce a summary of the analysis.

        Parameters
        ----------
        alpha : float
            `1 - alpha` is the nominal coverage probability of the interval.
        float_format : str
            Used to format numeric values in the table.
        method : str
            The method for producing the confidence interval.  Currently
            must be 'normal' which uses the normal approximation.
        """

        fmt = float_format

        headers = ["Statistic", "P-value", "DF"]
        stubs = ["Symmetry", "Homogeneity"]
        sy = self.symmetry()
        hm = self.homogeneity()
        data = [[fmt % sy.statistic, fmt % sy.pvalue,
                 '%d' % sy.df],
                [fmt % hm.statistic, fmt % hm.pvalue,
                 '%d' % hm.df]]
        tab = iolib.SimpleTable(data,
                                headers,
                                stubs,
                                data_aligns="r",
                                table_dec_above='')

        return tab
Пример #3
0
    def summary(self, alpha=0.05, float_format="%.3f", method="normal"):
        """
        Summarizes results for a 2x2 table analysis.

        Parameters
        ----------
        alpha : float
            `1 - alpha` is the nominal coverage probability of the confidence
            intervals.
        float_format : str
            Used to format the numeric values in the table.
        method : str
            The method for producing the confidence interval.  Currently
            must be 'normal' which uses the normal approximation.
        """
        def fmt(x):
            if isinstance(x, str):
                return x
            return float_format % x

        headers = ["Estimate", "SE", "LCB", "UCB", "p-value"]
        stubs = [
            "Odds ratio", "Log odds ratio", "Risk ratio", "Log risk ratio"
        ]

        lcb1, ucb1 = self.oddsratio_confint(alpha, method)
        lcb2, ucb2 = self.log_oddsratio_confint(alpha, method)
        lcb3, ucb3 = self.riskratio_confint(alpha, method)
        lcb4, ucb4 = self.log_riskratio_confint(alpha, method)
        data = [[
            fmt(x)
            for x in [self.oddsratio, "", lcb1, ucb1,
                      self.oddsratio_pvalue()]
        ],
                [
                    fmt(x) for x in [
                        self.log_oddsratio, self.log_oddsratio_se, lcb2, ucb2,
                        self.oddsratio_pvalue()
                    ]
                ],
                [
                    fmt(x) for x in
                    [self.riskratio, "", lcb3, ucb3,
                     self.riskratio_pvalue()]
                ],
                [
                    fmt(x) for x in [
                        self.log_riskratio, self.log_riskratio_se, lcb4, ucb4,
                        self.riskratio_pvalue()
                    ]
                ]]
        tab = iolib.SimpleTable(data,
                                headers,
                                stubs,
                                data_aligns="r",
                                table_dec_above='')
        return tab