def get_heterogeneity_stats(self): """Get heterogeneity statistics.""" v = self.estimator.get_v(self.dataset) q_fe = q_gen(self.dataset.y, v, self.dataset.X, 0) df = self.dataset.y.shape[0] - self.dataset.X.shape[1] i2 = np.maximum(100.0 * (q_fe - df) / q_fe, 0.0) h = np.maximum(np.sqrt(q_fe / df), 1.0) p = ss.chi2.sf(q_fe, df) return {"Q": q_fe, "p(Q)": p, "I^2": i2, "H": h}
def test_q_gen(vars_with_intercept): result = q_gen(*vars_with_intercept, 8) assert round(result[0], 4) == 8.0161
def test_q_gen(vars_with_intercept): """Test pymare.stats.q_gen.""" result = q_gen(*vars_with_intercept, 8) assert round(result[0], 4) == 8.0161