How to use the pymer4.stats.rsquared function in pymer4

To help you get started, we’ve selected a few pymer4 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 ejolly / pymer4 / pymer4 / models / Lm.py View on Github external
if permute:
            results = results.rename(columns={"DF": "Num_perm", "P-val": "Perm-P-val"})

        self.coefs = results
        self.fitted = True
        self.residuals = res
        self.fits = (y.squeeze() - res).values
        self.data["fits"] = (y.squeeze() - res).values
        self.data["residuals"] = res

        # Fit statistics
        if "Intercept" in self.design_matrix.columns:
            center_tss = True
        else:
            center_tss = False
        self.rsquared = rsquared(y.squeeze(), res, center_tss)
        self.rsquared_adj = rsquared_adj(
            self.rsquared, len(res), len(res) - x.shape[1], center_tss
        )
        half_obs = len(res) / 2.0
        ssr = np.dot(res, res.T)
        self.logLike = (-np.log(ssr) * half_obs) - (
            (1 + np.log(np.pi / half_obs)) * half_obs
        )
        self.AIC = 2 * x.shape[1] - 2 * self.logLike
        self.BIC = np.log((len(res))) * x.shape[1] - 2 * self.logLike

        if summarize:
            return self.summary()