Exemplo n.º 1
0
 def test_debiased(self, data):
     wm = HomoskedasticWeightMatrix(debiased=True)
     weight = wm.weight_matrix(data.x, data.z, data.e)
     z, e, nobs, nvar = data.z, data.e, data.nobs, data.nvar
     s2 = (e - e.mean()).T @ (e - e.mean()) / nobs
     scale = nobs / (nobs - nvar)
     assert_allclose(weight, scale * s2 * z.T @ z / nobs)
Exemplo n.º 2
0
 def test_config(self, data):
     wm = HomoskedasticWeightMatrix()
     z, e, nobs = data.z, data.e, data.nobs
     weight = wm.weight_matrix(data.x, z, e)
     s2 = (e - e.mean()).T @ (e - e.mean()) / nobs
     assert_allclose(weight, s2 * z.T @ z / nobs)
     assert wm.config['center'] is False
     assert wm.config['debiased'] is False
Exemplo n.º 3
0
 def test_defaults(self, data):
     wm = HomoskedasticWeightMatrix()
     z, e, nobs = data.z, data.e, data.nobs
     weight = wm.weight_matrix(data.x, z, e)
     s2 = (e - e.mean()).T @ (e - e.mean()) / nobs
     assert_allclose(weight, s2 * z.T @ z / nobs)
Exemplo n.º 4
0
 def test_center(self, data):
     wm = HomoskedasticWeightMatrix(True)
     weight = wm.weight_matrix(data.x, data.z, data.e)
     z, e, nobs = data.z, data.e, data.nobs
     s2 = (e - e.mean()).T @ (e - e.mean()) / nobs
     assert_allclose(weight, s2 * z.T @ z / nobs)