<commit_before>import os
import numpy as np
import pandas as pd
import statsmodels.api as sm
from numpy.testing import *
from patsy import dmatrices
from statsmodels.regression.quantile_regression import QuantReg
from results_quantile_regression import (
      biweight_chamberlain, biweight_hsheather, biweight_bofinger,
      cosine_chamberlain, cosine_hsheather, cosine_bofinger,
      gaussian_chamberlain, gaussian_hsheather, gaussian_bofinger,
      epan2_chamberlain, epan2_hsheather, epan2_bofinger,
      parzen_chamberlain, parzen_hsheather, parzen_bofinger,
      #rectangle_chamberlain, rectangle_hsheather, rectangle_bofinger,
      #triangle_chamberlain, triangle_hsheather, triangle_bofinger,
      #epanechnikov_chamberlain, epanechnikov_hsheather, epanechnikov_bofinger,
      epanechnikov_hsheather_q75, Rquantreg)

idx = ['income', 'Intercept']
class CheckModelResults(object):
    def test_params(self):
        assert_allclose(np.ravel(self.res1.params.ix[idx]),
                            self.res2.table[:,0], rtol=1e-3)
    def test_bse(self):
        assert_allclose(np.ravel(self.res1.bse.ix[idx]),
                            self.res2.table[:,1], rtol=1e-3)
    def test_pvalues(self):
        assert_allclose(np.ravel(np.round(self.res1.pvalues.ix[idx], 3)),
                            self.res2.table[:,3], rtol=1e-3)
    def test_conf_int(self):
        assert_allclose(self.res1.conf_int().ix[idx],
                self.res2.table[:,-2:], rtol=1e-3)
    def test_nobs(self):
        assert_allclose(self.res1.nobs, self.res2.N, rtol=1e-3)
    def test_df_model(self):
        assert_allclose(self.res1.df_model, self.res2.df_m, rtol=1e-3)
    def test_df_resid(self):
        assert_allclose(self.res1.df_resid, self.res2.df_r, rtol=1e-3)
    def test_prsquared(self):
        assert_allclose(self.res1.prsquared, self.res2.psrsquared, rtol=1e-3)
    def test_sparsity(self):
        assert_allclose(np.array(self.res1.sparsity),
                            self.res2.sparsity, rtol=1e-3)
    def test_bandwidth(self):
        assert_allclose(np.array(self.res1.bandwidth),
                            self.res2.kbwidth, rtol=1e-3)


d = {('biw','bofinger'): biweight_bofinger,<commit_msg>pvalues test + tolerance<commit_after>import os
import scipy
import numpy as np
import pandas as pd
import statsmodels.api as sm
from numpy.testing import *
from patsy import dmatrices
from statsmodels.regression.quantile_regression import QuantReg
from results_quantile_regression import (
      biweight_chamberlain, biweight_hsheather, biweight_bofinger,
      cosine_chamberlain, cosine_hsheather, cosine_bofinger,
      gaussian_chamberlain, gaussian_hsheather, gaussian_bofinger,
      epan2_chamberlain, epan2_hsheather, epan2_bofinger,
      parzen_chamberlain, parzen_hsheather, parzen_bofinger,
      #rectangle_chamberlain, rectangle_hsheather, rectangle_bofinger,
      #triangle_chamberlain, triangle_hsheather, triangle_bofinger,
      #epanechnikov_chamberlain, epanechnikov_hsheather, epanechnikov_bofinger,
      epanechnikov_hsheather_q75, Rquantreg)

idx = ['income', 'Intercept']
class CheckModelResults(object):
    def test_params(self):
        assert_allclose(np.ravel(self.res1.params.ix[idx]),
                            self.res2.table[:,0], rtol=1e-3)
    def test_bse(self):
        assert_allclose(np.ravel(self.res1.bse.ix[idx]),
                            self.res2.table[:,1], rtol=1e-3)
    def test_tvalues(self):
        assert_allclose(np.ravel(self.res1.tvalues.ix[idx]),
                            self.res2.table[:,2], rtol=1e-2)
    def test_pvalues(self):
        pvals_stata = scipy.stats.t.sf(self.res2.table[:, 2] , self.res2.df_r)
        assert_allclose(np.ravel(self.res1.pvalues.ix[idx]),
                        pvals_stata, atol=1e-3)
    def test_conf_int(self):
        assert_allclose(self.res1.conf_int().ix[idx],
                self.res2.table[:,-2:], rtol=1e-3)
    def test_nobs(self):
        assert_allclose(self.res1.nobs, self.res2.N, rtol=1e-3)
    def test_df_model(self):
        assert_allclose(self.res1.df_model, self.res2.df_m, rtol=1e-3)
    def test_df_resid(self):
        assert_allclose(self.res1.df_resid, self.res2.df_r, rtol=1e-3)
    def test_prsquared(self):
        assert_allclose(self.res1.prsquared, self.res2.psrsquared, rtol=1e-3)
    def test_sparsity(self):
        assert_allclose(np.array(self.res1.sparsity),
                            self.res2.sparsity, rtol=1e-3)
    def test_bandwidth(self):
        assert_allclose(np.array(self.res1.bandwidth),
                            self.res2.kbwidth, rtol=1e-3)


d = {('biw','bofinger'): biweight_bofinger,
{'fraction_non_alphanumeric': 0.10935159426492617, 'fraction_numerical': 0.02246950567087524, 'mean_word_length': 3.2529572338489534, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6717193', 'n_tokens_mistral': 1756, 'n_tokens_neox': 1702, 'n_words': 237}