'Hausman\'s specification test
See Also
spec_hausman : generic function for Hausman\'s specification test'

def spec_hausman(self, dof=None):

    (endog, exog) = (self.model.endog, self.model.exog)
    resols = OLS(endog, exog).fit()
    normalized_cov_params_ols = resols.model.normalized_cov_params
    se2 = (resols.ssr / len(endog))
    params_diff = (self.params - resols.params)
    cov_diff = (np.linalg.pinv(self.model.xhatprod) - normalized_cov_params_ols)
    if (not dof):
        dof = np_matrix_rank(cov_diff)
    cov_diffpinv = np.linalg.pinv(cov_diff)
    H = (np.dot(params_diff, np.dot(cov_diffpinv, params_diff)) / se2)
    pval = stats.chi2.sf(H, dof)
    return (H, pval, dof)
