Exemplo n.º 1
0
 def test_center(self, data):
     wm = HeteroskedasticWeightMatrix(True)
     z, e, nobs = data.z, data.e, data.nobs
     weight = wm.weight_matrix(data.x, z, e)
     ze = z * e
     ze -= ze.mean(0)
     assert_allclose(weight, ze.T @ ze / nobs)
Exemplo n.º 2
0
 def test_debiased(self, data):
     wm = HeteroskedasticWeightMatrix(debiased=True)
     z, e, nobs, nvar = data.z, data.e, data.nobs, data.nvar
     weight = wm.weight_matrix(data.x, z, e)
     ze = z * e
     scale = nobs / (nobs - nvar)
     assert_allclose(weight, scale * ze.T @ ze / nobs)
Exemplo n.º 3
0
    def test_config(self, data):
        wm = HeteroskedasticWeightMatrix()
        z, e, nobs = data.z, data.e, data.nobs
        weight = wm.weight_matrix(data.x, z, e)
        ze = z * e

        assert_allclose(weight, ze.T @ ze / nobs)
        assert wm.config['center'] is False
        assert wm.config['debiased'] is False
Exemplo n.º 4
0
 def test_heteroskedastic(self, data):
     c = IVGMMCovariance(data.x, data.y, data.z, data.params, data.i, 'robust')
     s = HeteroskedasticWeightMatrix().weight_matrix(data.x, data.z, data.e)
     x, z = data.x, data.z
     xzwswzx = x.T @ z @ s @ z.T @ x / data.nobs
     cov = data.xzizx_inv @ xzwswzx @ data.xzizx_inv
     cov = (cov + cov.T) / 2
     assert_allclose(c.cov, cov)
     assert c.config['debiased'] is False