def test_GS_NN(self): est_Int = self.GS_NN.by_col(' est_Intercept') se_Int = self.GS_NN.by_col(' se_Intercept') t_Int = self.GS_NN.by_col(' t_Intercept') est_rural = self.GS_NN.by_col(' est_PctRural') se_rural = self.GS_NN.by_col(' se_PctRural') t_rural = self.GS_NN.by_col(' t_PctRural') est_pov = self.GS_NN.by_col(' est_PctPov') se_pov = self.GS_NN.by_col(' se_PctPov') t_pov = self.GS_NN.by_col(' t_PctPov') est_black = self.GS_NN.by_col(' est_PctBlack') se_black = self.GS_NN.by_col(' se_PctBlack') t_black = self.GS_NN.by_col(' t_PctBlack') yhat = self.GS_NN.by_col(' yhat') res = np.array(self.GS_NN.by_col(' residual')) std_res = np.array(self.GS_NN.by_col(' std_residual')).reshape((-1, 1)) localR2 = np.array(self.GS_NN.by_col(' localR2')).reshape((-1, 1)) inf = np.array(self.GS_NN.by_col(' influence')).reshape((-1, 1)) cooksD = np.array(self.GS_NN.by_col(' CooksD')).reshape((-1, 1)) model = GWR(self.coords, self.y, self.X, bw=49.000, kernel='gaussian', fixed=False) rslt = model.fit() AICc = get_AICc(rslt) AIC = get_AIC(rslt) BIC = get_BIC(rslt) CV = get_CV(rslt) self.assertAlmostEquals(np.floor(AICc), 896) self.assertAlmostEquals(np.floor(AIC), 894.0) self.assertAlmostEquals(np.floor(BIC), 922.0) self.assertAlmostEquals(np.around(CV, 2), 17.91) np.testing.assert_allclose(est_Int, rslt.params[:, 0], rtol=1e-04) np.testing.assert_allclose(se_Int, rslt.bse[:, 0], rtol=1e-04) np.testing.assert_allclose(t_Int, rslt.tvalues[:, 0], rtol=1e-04) np.testing.assert_allclose(est_rural, rslt.params[:, 1], rtol=1e-04) np.testing.assert_allclose(se_rural, rslt.bse[:, 1], rtol=1e-04) np.testing.assert_allclose(t_rural, rslt.tvalues[:, 1], rtol=1e-04) np.testing.assert_allclose(est_pov, rslt.params[:, 2], rtol=1e-04) np.testing.assert_allclose(se_pov, rslt.bse[:, 2], rtol=1e-04) np.testing.assert_allclose(t_pov, rslt.tvalues[:, 2], rtol=1e-04) np.testing.assert_allclose(est_black, rslt.params[:, 3], rtol=1e-02) np.testing.assert_allclose(se_black, rslt.bse[:, 3], rtol=1e-02) np.testing.assert_allclose(t_black, rslt.tvalues[:, 3], rtol=1e-02) np.testing.assert_allclose(yhat, rslt.mu, rtol=1e-05) np.testing.assert_allclose(res, rslt.resid_response, rtol=1e-04) np.testing.assert_allclose(std_res, rslt.std_res, rtol=1e-04) np.testing.assert_allclose(localR2, rslt.localR2, rtol=1e-05) np.testing.assert_allclose(inf, rslt.influ, rtol=1e-04) np.testing.assert_allclose(cooksD, rslt.cooksD, rtol=1e-00)
def test_GS_NN(self): est_Int = self.GS_NN.by_col(' est_Intercept') se_Int = self.GS_NN.by_col(' se_Intercept') t_Int = self.GS_NN.by_col(' t_Intercept') est_rural = self.GS_NN.by_col(' est_PctRural') se_rural = self.GS_NN.by_col(' se_PctRural') t_rural = self.GS_NN.by_col(' t_PctRural') est_pov = self.GS_NN.by_col(' est_PctPov') se_pov = self.GS_NN.by_col(' se_PctPov') t_pov = self.GS_NN.by_col(' t_PctPov') est_black = self.GS_NN.by_col(' est_PctBlack') se_black = self.GS_NN.by_col(' se_PctBlack') t_black = self.GS_NN.by_col(' t_PctBlack') yhat = self.GS_NN.by_col(' yhat') res = np.array(self.GS_NN.by_col(' residual')) std_res = np.array(self.GS_NN.by_col(' std_residual')).reshape((-1,1)) localR2 = np.array(self.GS_NN.by_col(' localR2')).reshape((-1,1)) inf = np.array(self.GS_NN.by_col(' influence')).reshape((-1,1)) cooksD = np.array(self.GS_NN.by_col(' CooksD')).reshape((-1,1)) model = GWR(self.coords, self.y, self.X, bw=49.000, kernel='gaussian', fixed=False) rslt = model.fit() AICc = get_AICc(rslt) AIC = get_AIC(rslt) BIC = get_BIC(rslt) CV = get_CV(rslt) self.assertAlmostEquals(np.floor(AICc), 896) self.assertAlmostEquals(np.floor(AIC), 894.0) self.assertAlmostEquals(np.floor(BIC), 922.0) self.assertAlmostEquals(np.around(CV, 2), 17.91) np.testing.assert_allclose(est_Int, rslt.params[:,0], rtol=1e-04) np.testing.assert_allclose(se_Int, rslt.bse[:,0], rtol=1e-04) np.testing.assert_allclose(t_Int, rslt.tvalues[:,0], rtol=1e-04) np.testing.assert_allclose(est_rural, rslt.params[:,1], rtol=1e-04) np.testing.assert_allclose(se_rural, rslt.bse[:,1], rtol=1e-04) np.testing.assert_allclose(t_rural, rslt.tvalues[:,1], rtol=1e-04) np.testing.assert_allclose(est_pov, rslt.params[:,2], rtol=1e-04) np.testing.assert_allclose(se_pov, rslt.bse[:,2], rtol=1e-04) np.testing.assert_allclose(t_pov, rslt.tvalues[:,2], rtol=1e-04) np.testing.assert_allclose(est_black, rslt.params[:,3], rtol=1e-02) np.testing.assert_allclose(se_black, rslt.bse[:,3], rtol=1e-02) np.testing.assert_allclose(t_black, rslt.tvalues[:,3], rtol=1e-02) np.testing.assert_allclose(yhat, rslt.mu, rtol=1e-05) np.testing.assert_allclose(res, rslt.resid_response, rtol=1e-04) np.testing.assert_allclose(std_res, rslt.std_res, rtol=1e-04) np.testing.assert_allclose(localR2, rslt.localR2, rtol=1e-05) np.testing.assert_allclose(inf, rslt.influ, rtol=1e-04) np.testing.assert_allclose(cooksD, rslt.cooksD, rtol=1e-00)