def _compute_likelihood_ratio_test(self):
        """
        This function computes the likelihood ratio test for the Cox model. We
        compare the existing model (with all the covariates) to the trivial model
        of no covariates.
        """
        if hasattr(self, "_log_likelihood_null"):
            ll_null = self._log_likelihood_null
        else:
            if self._batch_mode:
                ll_null = self._trivial_log_likelihood_batch(
                    self.durations.values, self.event_observed.values, self.weights.values
                )
            else:
                ll_null = self._trivial_log_likelihood_single(
                    self.durations.values, self.event_observed.values, self.weights.values
                )
        ll_alt = self._log_likelihood
        test_stat = 2 * ll_alt - 2 * ll_null
        degrees_freedom = self.hazards_.shape[0]
        p_value = chisq_test(test_stat, degrees_freedom=degrees_freedom)
        with np.errstate(invalid="ignore", divide="ignore"):
            return test_stat, degrees_freedom, -np.log2(p_value)
def _compute_likelihood_ratio_test ( self ) : if hasattr ( self , "_log_likelihood_null" ) : ll_null = self . _log_likelihood_null else : if self . _batch_mode : ll_null = self . _trivial_log_likelihood_batch ( self . durations . values , self . event_observed . values , self . weights . values ) else : ll_null = self . _trivial_log_likelihood_single ( self . durations . values , self . event_observed . values , self . weights . values ) ll_alt = self . _log_likelihood test_stat = 2 * ll_alt - 2 * ll_null degrees_freedom = self . hazards_ . shape [ 0 ] p_value = chisq_test ( test_stat , degrees_freedom = degrees_freedom ) with np . errstate ( invalid = "ignore" , divide = "ignore" ) : return test_stat , degrees_freedom , - np . log2 ( p_value )
This function computes the likelihood ratio test for the Cox model. We
        compare the existing model (with all the covariates) to the trivial model
        of no covariates.