'Computes the test statistic'

def _compute_test_stat(self, Y, X):

    dom_x = np.sort(np.unique(self.exog[:, self.test_vars]))
    n = np.shape(X)[0]
    model = KernelReg(Y, X, self.var_type, self.model.reg_type, self.bw, defaults=EstimatorSettings(efficient=False))
    X1 = copy.deepcopy(X)
    X1[:, self.test_vars] = 0
    m0 = model.fit(data_predict=X1)[0]
    m0 = np.reshape(m0, (n, 1))
    I = np.zeros((n, 1))
    for i in dom_x[1:]:
        X1[:, self.test_vars] = i
        m1 = model.fit(data_predict=X1)[0]
        m1 = np.reshape(m1, (n, 1))
        I += ((m1 - m0) ** 2)
    I = (I.sum(axis=0) / float(n))
    return I
