def _top_right(self) -> List[Tuple[str, str]]:
     top_right = [
         ("No. Observations:", str(self._resid.shape[0])),
         ("R²:", str_format(self.rsquared)),
         ("Adjusted. R²:", str_format(self.rsquared_adj)),
         ("Residual Variance:", str_format(self.residual_variance)),
         ("Long-run Variance:", str_format(self.long_run_variance)),
         ("", ""),
     ]
     return top_right
Esempio n. 2
0
    def summary(self, full: bool = False) -> Summary:
        """
        Summary of the model, containing estimated parameters and std. errors

        Parameters
        ----------
        full : bool, default False
            Flag indicating whether to include all estimated parameters
            (True) or only the parameters of the cointegrating vector

        Returns
        -------
        Summary
            A summary instance with method that support export to text, csv
            or latex.
        """
        if self._bandwidth != int(self._bandwidth):
            bw = str_format(self._bandwidth)
        else:
            bw = str(int(self._bandwidth))

        top_left = [
            ("Trend:", SHORT_TREND_DESCRIPTION[self._trend]),
            ("Leads:", str(self._leads)),
            ("Lags:", str(self._lags)),
            ("Cov Type:", str(self._cov_type)),
            ("Kernel:", str(self._kernel)),
            ("Bandwidth:", bw),
        ]

        top_right = self._top_right()
        smry = Summary()
        typ = "Cointegrating Vector" if not full else "Model"
        title = f"Dynamic OLS {typ} Summary"
        table = self._top_table(top_left, top_right, title)
        # Top Table
        # Parameter table
        smry.tables.append(table)
        if full:
            params = np.asarray(self.full_params)
            stubs = list(self.full_params.index)
            se = np.sqrt(np.diag(self.full_cov))
            tstats = params / se
            pvalues = 2 * (1 - stats.norm.cdf(np.abs(tstats)))
        else:
            params = np.asarray(self.params)
            stubs = list(self.params.index)
            se = np.asarray(self.std_errors)
            tstats = np.asarray(self.tvalues)
            pvalues = np.asarray(self.pvalues)

        title = "Cointegrating Vector" if not full else "Model Parameters"
        assert isinstance(se, np.ndarray)
        table = self._param_table(params, se, tstats, pvalues, stubs, title)
        smry.tables.append(table)

        return smry
    def summary(self) -> Summary:
        """
        Summary of the model, containing estimated parameters and std. errors

        Returns
        -------
        Summary
            A summary instance with method that support export to text, csv
            or latex.
        """
        if self._bandwidth != int(self._bandwidth):
            bw = str_format(self._bandwidth)
        else:
            bw = str(int(self._bandwidth))

        top_left = [
            ("Trend:", SHORT_TREND_DESCRIPTION[self._trend]),
            ("Kernel:", str(self._kernel)),
            ("Bandwidth:", bw),
            ("", ""),
            ("", ""),
            ("", ""),
        ]

        top_right = self._top_right()
        smry = Summary()
        title = self._estimator_type
        table = self._top_table(top_left, top_right, title)
        # Top Table
        # Parameter table
        smry.tables.append(table)
        params = np.asarray(self.params)
        stubs = list(self.params.index)
        se = np.asarray(self.std_errors)
        tstats = np.asarray(self.tvalues)
        pvalues = np.asarray(self.pvalues)

        title = "Cointegrating Vector"
        table = self._param_table(params, se, tstats, pvalues, stubs, title)
        smry.tables.append(table)

        return smry
Esempio n. 4
0
 def __init__(
     self,
     stat: float,
     pvalue: float,
     crit_vals: pd.Series,
     null: str = "No Cointegration",
     alternative: str = "Cointegration",
     trend: str = "c",
     order: int = 2,
     xsection: Optional[RegressionResults] = None,
     test_type: str = "Za",
     kernel_est: Optional[lrcov.CovarianceEstimator] = None,
     rho: float = 0.0,
 ) -> None:
     super().__init__(stat,
                      pvalue,
                      crit_vals,
                      null,
                      alternative,
                      trend,
                      order,
                      xsection=xsection)
     self.name = f"Phillips-Ouliaris {test_type} Cointegration Test"
     self._test_type = test_type
     assert kernel_est is not None
     self._kernel_est = kernel_est
     self._rho = rho
     self._additional_info.update({
         "Kernel":
         self.kernel,
         "Bandwidth":
         str_format(kernel_est.bandwidth),
         "Trend":
         self.trend,
         "Distribution Order":
         self.distribution_order,
     })