コード例 #1
0
def test_ic():
    #test information criteria
    #consistency check

    ics = [aic, aicc, bic, hqic]
    ics_sig = [aic_sigma, aicc_sigma, bic_sigma, hqic_sigma]

    for ic, ic_sig in zip(ics, ics_sig):
        assert_(ic(np.array(2),10,2).dtype == np.float, msg=repr(ic))
        assert_(ic_sig(np.array(2),10,2).dtype == np.float, msg=repr(ic_sig) )

        assert_almost_equal(ic(-10./2.*np.log(2.),10,2)/10,
                            ic_sig(2, 10, 2),
                            decimal=14)

        assert_almost_equal(ic_sig(np.log(2.),10,2, islog=True),
                            ic_sig(2, 10, 2),
                            decimal=14)


    #examples penalty directly from formula
    n, k = 10, 2
    assert_almost_equal(aic(0, 10, 2), 2*k, decimal=14)
    #next see Wikipedia
    assert_almost_equal(aicc(0, 10, 2),
                        aic(0, n, k) + 2*k*(k+1.)/(n-k-1.), decimal=14)
    assert_almost_equal(bic(0, 10, 2), np.log(n)*k, decimal=14)
    assert_almost_equal(hqic(0, 10, 2), 2*np.log(np.log(n))*k, decimal=14)
コード例 #2
0
ファイル: base.py プロジェクト: timgates42/statsmodels
 def hqic(self):
     """
     (float) Hannan-Quinn Information Criterion
     """
     # return (-2 * self.llf +
     #         2 * np.log(np.log(self.nobs_effective)) * self.df_model)
     return hqic(self.llf, self.nobs_effective, self.df_model)
コード例 #3
0
def test_ic():
    #test information criteria
    #consistency check

    ics = [aic, aicc, bic, hqic]
    ics_sig = [aic_sigma, aicc_sigma, bic_sigma, hqic_sigma]

    for ic, ic_sig in zip(ics, ics_sig):
        assert_(ic(np.array(2), 10, 2).dtype == np.float, msg=repr(ic))
        assert_(ic_sig(np.array(2), 10, 2).dtype == np.float, msg=repr(ic_sig))

        assert_almost_equal(ic(-10. / 2. * np.log(2.), 10, 2) / 10,
                            ic_sig(2, 10, 2),
                            decimal=14)

        assert_almost_equal(ic_sig(np.log(2.), 10, 2, islog=True),
                            ic_sig(2, 10, 2),
                            decimal=14)

    #examples penalty directly from formula
    n, k = 10, 2
    assert_almost_equal(aic(0, 10, 2), 2 * k, decimal=14)
    #next see Wikipedia
    assert_almost_equal(aicc(0, 10, 2),
                        aic(0, n, k) + 2 * k * (k + 1.) / (n - k - 1.),
                        decimal=14)
    assert_almost_equal(bic(0, 10, 2), np.log(n) * k, decimal=14)
    assert_almost_equal(hqic(0, 10, 2), 2 * np.log(np.log(n)) * k, decimal=14)
コード例 #4
0
def test_ic():
    # test information criteria

    # examples penalty directly from formula
    n = 10
    k = 2
    assert_almost_equal(aic(0, 10, 2), 2*k, decimal=14)
    # next see Wikipedia
    assert_almost_equal(aicc(0, 10, 2),
                        aic(0, n, k) + 2*k*(k+1.)/(n-k-1.), decimal=14)
    assert_almost_equal(bic(0, 10, 2), np.log(n)*k, decimal=14)
    assert_almost_equal(hqic(0, 10, 2), 2*np.log(np.log(n))*k, decimal=14)
コード例 #5
0
def test_ic():
    # test information criteria

    # examples penalty directly from formula
    n = 10
    k = 2
    assert_almost_equal(aic(0, 10, 2), 2*k, decimal=14)
    # next see Wikipedia
    assert_almost_equal(aicc(0, 10, 2),
                        aic(0, n, k) + 2*k*(k+1.)/(n-k-1.), decimal=14)
    assert_almost_equal(bic(0, 10, 2), np.log(n)*k, decimal=14)
    assert_almost_equal(hqic(0, 10, 2), 2*np.log(np.log(n))*k, decimal=14)
コード例 #6
0
 def hqic(self):
     """
     (float) Hannan-Quinn Information Criterion
     """
     # return -2*self.llf + 2*np.log(np.log(self.nobs))*self.params.shape[0]
     return hqic(self.llf, self.nobs, self.params.shape[0])
コード例 #7
0
 def hqic(self):
     """
     (float) Hannan-Quinn Information Criterion
     """
     # return -2*self.llf + 2*np.log(np.log(self.nobs))*self.params.shape[0]
     return hqic(self.llf, self.nobs, self.params.shape[0])