def test_QuasiPoisson(self): f = np.array(self.f).reshape((-1, 1)) dij = np.array(self.dij).reshape((-1, 1)) model = grav.BaseGravity(f, dij, 'exp', constant=False, Quasi=True) np.testing.assert_allclose(model.params, [0.01641585], atol=.0001) self.assertTrue(math.isnan(model.AIC)) np.testing.assert_allclose(model.cov_params, [[0.00079749]], atol=1.0e-8) self.assertAlmostEqual(model.deviance, 1087408.9707170483, delta=.0001) self.assertTrue(np.isnan(model.llf)) self.assertTrue(np.isnan(model.llnull)) np.testing.assert_allclose(model.pvalues, [0.56103881]) np.testing.assert_allclose(model.std_err, [0.02823993], atol=1.0e-8) np.testing.assert_allclose(model.tvalues, [0.58129922]) np.testing.assert_allclose(model.yhat, [ 5.42415692e+00, 3.98401807e+00, 3.75177744e+01, 8.73217546e+00, 3.38315236e+01, 5.76055685e+01, 6.11695077e+02, 3.98970414e+03, 5.42415692e+00, 2.12078133e+00, 3.52389616e+01, 8.43222048e+00, 1.00726025e+01, 2.72049640e+01, 2.81140796e+02, 1.71101560e+03, 3.98401807e+00, 2.12078133e+00, 6.05130899e+01, 1.35184658e+01, 2.13329799e+01, 5.49951210e+01, 5.80026424e+02, 3.57519614e+03, 3.75177744e+01, 3.52389616e+01, 6.05130899e+01, 4.55832329e+00, 1.20799918e+01, 4.59486946e+00, 2.44995584e+01, 1.52168163e+02, 8.73217546e+00, 8.43222048e+00, 1.35184658e+01, 4.55832329e+00, 7.72767984e+00, 7.46219749e+00, 7.36414576e+01, 4.82050643e+02, 3.38315236e+01, 1.00726025e+01, 2.13329799e+01, 1.20799918e+01, 7.72767984e+00, 3.82690126e+00, 3.06302472e+01, 1.75492594e+02, 5.76055685e+01, 2.72049640e+01, 5.49951210e+01, 4.59486946e+00, 7.46219749e+00, 3.82690126e+00, 1.08216970e+01, 6.97553001e+01, 6.11695077e+02, 2.81140796e+02, 5.80026424e+02, 2.44995584e+01, 7.36414576e+01, 3.06302472e+01, 1.08216970e+01, 6.54702760e+00, 3.98970414e+03, 1.71101560e+03, 3.57519614e+03, 1.52168163e+02, 4.82050643e+02, 1.75492594e+02, 6.97553001e+01, 6.54702760e+00 ])
def test_BaseGravity_exp(self): f = np.array(self.f).reshape((-1, 1)) dij = np.array(self.dij).reshape((-1, 1)) model = grav.BaseGravity(f, dij, 'exp', constant=False) np.testing.assert_allclose(model.params, [0.01641585], atol=.0001) self.assertAlmostEqual(model.AIC, 957622.28429746185, delta=.0001) np.testing.assert_allclose(model.cov_params, [[1.92096665e-10]]) self.assertAlmostEqual(model.deviance, 1087408.9707170483, delta=.0001) self.assertAlmostEqual(model.llf, -478810.14214873099, delta=.0001) self.assertAlmostEqual(model.llnull, -88037.0499629, delta=.0001) np.testing.assert_allclose(model.pvalues, [0.]) np.testing.assert_allclose(model.std_err, [1.38598941e-05]) np.testing.assert_allclose(model.tvalues, [1184.41355888]) np.testing.assert_allclose(model.yhat, [ 5.42415692e+00, 3.98401807e+00, 3.75177744e+01, 8.73217546e+00, 3.38315236e+01, 5.76055685e+01, 6.11695077e+02, 3.98970414e+03, 5.42415692e+00, 2.12078133e+00, 3.52389616e+01, 8.43222048e+00, 1.00726025e+01, 2.72049640e+01, 2.81140796e+02, 1.71101560e+03, 3.98401807e+00, 2.12078133e+00, 6.05130899e+01, 1.35184658e+01, 2.13329799e+01, 5.49951210e+01, 5.80026424e+02, 3.57519614e+03, 3.75177744e+01, 3.52389616e+01, 6.05130899e+01, 4.55832329e+00, 1.20799918e+01, 4.59486946e+00, 2.44995584e+01, 1.52168163e+02, 8.73217546e+00, 8.43222048e+00, 1.35184658e+01, 4.55832329e+00, 7.72767984e+00, 7.46219749e+00, 7.36414576e+01, 4.82050643e+02, 3.38315236e+01, 1.00726025e+01, 2.13329799e+01, 1.20799918e+01, 7.72767984e+00, 3.82690126e+00, 3.06302472e+01, 1.75492594e+02, 5.76055685e+01, 2.72049640e+01, 5.49951210e+01, 4.59486946e+00, 7.46219749e+00, 3.82690126e+00, 1.08216970e+01, 6.97553001e+01, 6.11695077e+02, 2.81140796e+02, 5.80026424e+02, 2.44995584e+01, 7.36414576e+01, 3.06302472e+01, 1.08216970e+01, 6.54702760e+00, 3.98970414e+03, 1.71101560e+03, 3.57519614e+03, 1.52168163e+02, 4.82050643e+02, 1.75492594e+02, 6.97553001e+01, 6.54702760e+00 ])
def test_BaseGravity_pow(self): f = np.array(self.f).reshape((-1, 1)) dij = np.array(self.dij).reshape((-1, 1)) model = grav.BaseGravity(f, dij, 'pow', constant=False) np.testing.assert_allclose(model.params, [1.27223738], atol=.0001) self.assertAlmostEqual(model.AIC, 377298.04716333596, delta=.0001) np.testing.assert_allclose(model.cov_params, [[4.31955426e-07]]) self.assertAlmostEqual(model.deviance, 409811.34329065739, delta=.0001) self.assertAlmostEqual(model.llf, -188648.02358166798, delta=.0001) self.assertAlmostEqual(model.llnull, -88037.0499629, delta=.0001) np.testing.assert_allclose(model.pvalues, [0.]) np.testing.assert_allclose(model.std_err, [0.00065723], atol=.000001) np.testing.assert_allclose(model.tvalues, [1935.74740017]) np.testing.assert_allclose(model.yhat, [ 363.76143383, 281.50403714, 959.7388893, 498.77506053, 925.03759732, 1106.44361848, 1984.54428735, 2749.95948574, 363.76143383, 129.70901679, 938.68096943, 488.56203387, 540.96136464, 852.80642651, 1683.84456031, 2397.81642174, 281.50403714, 129.70901679, 1123.57104159, 630.10766251, 773.76239688, 1090.36467516, 1963.64917204, 2703.75625368, 959.7388893, 938.68096943, 1123.57104159, 316.84652033, 595.67905738, 318.9700416, 818.55371165, 1454.18199247, 498.77506053, 488.56203387, 630.10766251, 316.84652033, 463.26843623, 453.2156204, 1192.42000515, 1891.29566175, 925.03759732, 540.96136464, 773.76239688, 595.67905738, 463.26843623, 271.12096396, 891.94447199, 1506.88882976, 1106.44361848, 852.80642651, 1090.36467516, 318.9700416, 453.2156204, 271.12096396, 562.42482847, 1173.32244253, 1984.54428735, 1683.84456031, 1963.64917204, 818.55371165, 1192.42000515, 891.94447199, 562.42482847, 416.01781589, 2749.95948574, 2397.81642174, 2703.75625368, 1454.18199247, 1891.29566175, 1506.88882976, 1173.32244253, 416.01781589 ])