def test_kappa(self, data):
     c = HeteroskedasticCovariance(data.x, data.y, data.z, data.params,
                                   debiased=False, kappa=.99)
     assert c.debiased is False
     assert c.config == {'debiased': False, 'kappa': 0.99}
     c2 = HeteroskedasticCovariance(data.x, data.y, data.z, data.params)
     assert_allclose(c.s, c2.s)
     assert c.s2 == c2.s2
     vk_inv = inv(data.vk)
     assert_allclose(c.cov, vk_inv @ c.s @ vk_inv / data.nobs)
Exemplo n.º 2
0
 def test_kappa_debiased(self, data):
     c = HeteroskedasticCovariance(
         data.x, data.y, data.z, data.params, debiased=True, kappa=0.99
     )
     assert c.debiased is True
     assert c.config == {"debiased": True, "kappa": 0.99}
     c2 = HeteroskedasticCovariance(
         data.x, data.y, data.z, data.params, debiased=True
     )
     assert_allclose(c.s, c2.s)
     assert c.s2 == c2.s2
     vk_inv = inv(data.vk)
     assert_allclose(c.cov, vk_inv @ c.s @ vk_inv / data.nobs)
Exemplo n.º 3
0
def test_heteroskedastic_cov_kappa(data):
    c = HeteroskedasticCovariance(data.x,
                                  data.y,
                                  data.z,
                                  data.params,
                                  debiased=False,
                                  kappa=0.99)
    assert c.debiased is False
    assert c.config == {"debiased": False, "kappa": 0.99}
    c2 = HeteroskedasticCovariance(data.x, data.y, data.z, data.params)
    assert_allclose(c.s, c2.s)
    assert c.s2 == c2.s2
    vk_inv = inv(data.vk)
    assert_allclose(c.cov, vk_inv @ c.s @ vk_inv / data.nobs)
Exemplo n.º 4
0
def test_heteroskedastic_cov_asymptotic(data):
    c = HeteroskedasticCovariance(data.x, data.y, data.z, data.params)
    assert c.debiased is False
    assert c.config == {"debiased": False, "kappa": 1}
    assert_allclose(c.s2, data.s2)
    xhat, eps, nobs = data.xhat, data.e, data.nobs
    assert_allclose(c.s, (xhat * eps).T @ (xhat * eps) / nobs)
 def test_debiased(self, data):
     c = HeteroskedasticCovariance(data.x, data.y, data.z, data.params,
                                   debiased=True)
     xhat, eps, nobs, nvar = data.xhat, data.e, data.nobs, data.nvar
     assert c.debiased is True
     assert c.config == {'debiased': True, 'kappa': 1}
     s = (xhat * eps).T @ (xhat * eps) / (nobs - nvar)
     assert_allclose(c.s, s)
     assert_allclose(c.cov, data.vinv @ s @ data.vinv / nobs)