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_elev = self.GS_NN.by_col(' est_Elev') se_elev = self.GS_NN.by_col(' se_Elev') t_elev = self.GS_NN.by_col(' t_Elev') est_slope = self.GS_NN.by_col(' est_Slope') se_slope = self.GS_NN.by_col(' se_Slope') t_slope = self.GS_NN.by_col(' t_Slope') est_sin = self.GS_NN.by_col(' est_SinAspct') se_sin = self.GS_NN.by_col(' se_SinAspct') t_sin = self.GS_NN.by_col(' t_SinAspct') est_cos = self.GS_NN.by_col(' est_CosAspct') se_cos = self.GS_NN.by_col(' se_CosAspct') t_cos = self.GS_NN.by_col(' t_CosAspct') est_south = self.GS_NN.by_col(' est_AbsSouth') se_south = self.GS_NN.by_col(' se_AbsSouth') t_south = self.GS_NN.by_col(' t_AbsSouth') est_strm = self.GS_NN.by_col(' est_DistStrm') se_strm = self.GS_NN.by_col(' se_DistStrm') t_strm = self.GS_NN.by_col(' t_DistStrm') yhat = self.GS_NN.by_col(' yhat') pdev = self.GS_NN.by_col(' localpdev') model = GWR(self.coords, self.y, self.X, bw=64, family=Binomial(), kernel='gaussian', fixed=False) rslt = model.fit() AICc = get_AICc(rslt) AIC = get_AIC(rslt) BIC = get_BIC(rslt) self.assertAlmostEquals(np.floor(AICc), 276.0) self.assertAlmostEquals(np.floor(AIC), 273.0) self.assertAlmostEquals(np.floor(BIC), 331.0) np.testing.assert_allclose(est_Int, rslt.params[:,0], rtol=1e-00) np.testing.assert_allclose(se_Int, rslt.bse[:,0], rtol=1e-00) np.testing.assert_allclose(t_Int, rslt.tvalues[:,0], rtol=1e-00) np.testing.assert_allclose(est_elev, rslt.params[:,1], rtol=1e-00) np.testing.assert_allclose(se_elev, rslt.bse[:,1], rtol=1e-00) np.testing.assert_allclose(t_elev, rslt.tvalues[:,1], rtol=1e-00) np.testing.assert_allclose(est_slope, rslt.params[:,2], rtol=1e-00) np.testing.assert_allclose(se_slope, rslt.bse[:,2], rtol=1e-00) np.testing.assert_allclose(t_slope, rslt.tvalues[:,2], rtol=1e-00) np.testing.assert_allclose(est_sin, rslt.params[:,3], rtol=1e01) np.testing.assert_allclose(se_sin, rslt.bse[:,3], rtol=1e01) np.testing.assert_allclose(t_sin, rslt.tvalues[:,3], rtol=1e01) np.testing.assert_allclose(est_cos, rslt.params[:,4], rtol=1e01) np.testing.assert_allclose(se_cos, rslt.bse[:,4], rtol=1e01) np.testing.assert_allclose(t_cos, rslt.tvalues[:,4], rtol=1e01) np.testing.assert_allclose(est_south, rslt.params[:,5], rtol=1e01) np.testing.assert_allclose(se_south, rslt.bse[:,5], rtol=1e01) np.testing.assert_allclose(t_south, rslt.tvalues[:,5], rtol=1e01) np.testing.assert_allclose(est_strm, rslt.params[:,6], rtol=1e02) np.testing.assert_allclose(se_strm, rslt.bse[:,6], rtol=1e01) np.testing.assert_allclose(t_strm, rslt.tvalues[:,6], rtol=1e02) np.testing.assert_allclose(yhat, rslt.mu, rtol=1e-00)
def test_BS_F(self): est_Int = self.BS_F.by_col(' est_Intercept') se_Int = self.BS_F.by_col(' se_Intercept') t_Int = self.BS_F.by_col(' t_Intercept') est_elev = self.BS_F.by_col(' est_Elev') se_elev = self.BS_F.by_col(' se_Elev') t_elev = self.BS_F.by_col(' t_Elev') est_slope = self.BS_F.by_col(' est_Slope') se_slope = self.BS_F.by_col(' se_Slope') t_slope = self.BS_F.by_col(' t_Slope') est_sin = self.BS_F.by_col(' est_SinAspct') se_sin = self.BS_F.by_col(' se_SinAspct') t_sin = self.BS_F.by_col(' t_SinAspct') est_cos = self.BS_F.by_col(' est_CosAspct') se_cos = self.BS_F.by_col(' se_CosAspct') t_cos = self.BS_F.by_col(' t_CosAspct') est_south = self.BS_F.by_col(' est_AbsSouth') se_south = self.BS_F.by_col(' se_AbsSouth') t_south = self.BS_F.by_col(' t_AbsSouth') est_strm = self.BS_F.by_col(' est_DistStrm') se_strm = self.BS_F.by_col(' se_DistStrm') t_strm = self.BS_F.by_col(' t_DistStrm') yhat = self.BS_F.by_col(' yhat') pdev = np.array(self.BS_F.by_col(' localpdev')).reshape((-1,1)) model = GWR(self.coords, self.y, self.X, bw=19642.170, family=Binomial(), kernel='bisquare', fixed=True) rslt = model.fit() AICc = get_AICc(rslt) AIC = get_AIC(rslt) BIC = get_BIC(rslt) self.assertAlmostEquals(np.floor(AICc), 275.0) self.assertAlmostEquals(np.floor(AIC), 271.0) self.assertAlmostEquals(np.floor(BIC), 349.0) np.testing.assert_allclose(est_Int, rslt.params[:,0], rtol=1e-00) np.testing.assert_allclose(se_Int, rslt.bse[:,0], rtol=1e-00) np.testing.assert_allclose(t_Int, rslt.tvalues[:,0], rtol=1e-00) np.testing.assert_allclose(est_elev, rslt.params[:,1], rtol=1e-00) np.testing.assert_allclose(se_elev, rslt.bse[:,1], rtol=1e-00) np.testing.assert_allclose(t_elev, rslt.tvalues[:,1], rtol=1e-00) np.testing.assert_allclose(est_slope, rslt.params[:,2], rtol=1e-00) np.testing.assert_allclose(se_slope, rslt.bse[:,2], rtol=1e-00) np.testing.assert_allclose(t_slope, rslt.tvalues[:,2], rtol=1e-00) np.testing.assert_allclose(est_sin, rslt.params[:,3], rtol=1e01) np.testing.assert_allclose(se_sin, rslt.bse[:,3], rtol=1e01) np.testing.assert_allclose(t_sin, rslt.tvalues[:,3], rtol=1e01) np.testing.assert_allclose(est_cos, rslt.params[:,4], rtol=1e01) np.testing.assert_allclose(se_cos, rslt.bse[:,4], rtol=1e01) np.testing.assert_allclose(t_cos, rslt.tvalues[:,4], rtol=1e01) np.testing.assert_allclose(est_south, rslt.params[:,5], rtol=1e01) np.testing.assert_allclose(se_south, rslt.bse[:,5], rtol=1e01) np.testing.assert_allclose(t_south, rslt.tvalues[:,5], rtol=1e01) np.testing.assert_allclose(est_strm, rslt.params[:,6], rtol=1e02) np.testing.assert_allclose(se_strm, rslt.bse[:,6], rtol=1e01) np.testing.assert_allclose(t_strm, rslt.tvalues[:,6], rtol=1e02) np.testing.assert_allclose(yhat, rslt.mu, rtol=1e-01)
def test_BS_NN_Offset(self): est_Int = self.BS_NN_OFF.by_col(' est_Intercept') se_Int = self.BS_NN_OFF.by_col(' se_Intercept') t_Int = self.BS_NN_OFF.by_col(' t_Intercept') est_OCC = self.BS_NN_OFF.by_col(' est_OCC_TEC') se_OCC = self.BS_NN_OFF.by_col(' se_OCC_TEC') t_OCC = self.BS_NN_OFF.by_col(' t_OCC_TEC') est_OWN = self.BS_NN_OFF.by_col(' est_OWNH') se_OWN = self.BS_NN_OFF.by_col(' se_OWNH') t_OWN = self.BS_NN_OFF.by_col(' t_OWNH') est_POP = self.BS_NN_OFF.by_col(' est_POP65') se_POP = self.BS_NN_OFF.by_col(' se_POP65') t_POP = self.BS_NN_OFF.by_col(' t_POP65') est_UNEMP = self.BS_NN_OFF.by_col(' est_UNEMP') se_UNEMP = self.BS_NN_OFF.by_col(' se_UNEMP') t_UNEMP = self.BS_NN_OFF.by_col(' t_UNEMP') yhat = self.BS_NN_OFF.by_col(' yhat') pdev = np.array(self.BS_NN_OFF.by_col(' localpdev')).reshape((-1,1)) model = GWR(self.coords, self.y, self.X, bw=100, offset=self.off, family=Poisson(), kernel='bisquare', fixed=False) rslt = model.fit() AICc = get_AICc(rslt) AIC = get_AIC(rslt) BIC = get_BIC(rslt) self.assertAlmostEquals(np.floor(AICc), 367.0) self.assertAlmostEquals(np.floor(AIC), 361.0) self.assertAlmostEquals(np.floor(BIC), 451.0) np.testing.assert_allclose(est_Int, rslt.params[:,0], rtol=1e-02, atol=1e-02) np.testing.assert_allclose(se_Int, rslt.bse[:,0], rtol=1e-02, atol=1e-02) np.testing.assert_allclose(t_Int, rslt.tvalues[:,0], rtol=1e-01, atol=1e-02) np.testing.assert_allclose(est_OCC, rslt.params[:,1], rtol=1e-03, atol=1e-02) np.testing.assert_allclose(se_OCC, rslt.bse[:,1], rtol=1e-02, atol=1e-02) np.testing.assert_allclose(t_OCC, rslt.tvalues[:,1], rtol=1e-01, atol=1e-02) np.testing.assert_allclose(est_OWN, rslt.params[:,2], rtol=1e-04, atol=1e-02) np.testing.assert_allclose(se_OWN, rslt.bse[:,2], rtol=1e-02, atol=1e-02) np.testing.assert_allclose(t_OWN, rslt.tvalues[:,2], rtol=1e-01, atol=1e-02) np.testing.assert_allclose(est_POP, rslt.params[:,3], rtol=1e-03, atol=1e-02) np.testing.assert_allclose(se_POP, rslt.bse[:,3], rtol=1e-02, atol=1e-02) np.testing.assert_allclose(t_POP, rslt.tvalues[:,3], rtol=1e-01, atol=1e-02) np.testing.assert_allclose(est_UNEMP, rslt.params[:,4], rtol=1e-04, atol=1e-02) np.testing.assert_allclose(se_UNEMP, rslt.bse[:,4], rtol=1e-02, atol=1e-02) np.testing.assert_allclose(t_UNEMP, rslt.tvalues[:,4], rtol=1e-01, atol=1e-02) np.testing.assert_allclose(yhat, rslt.mu, rtol=1e-03, atol=1e-02) np.testing.assert_allclose(pdev, rslt.pDev, rtol=1e-04, atol=1e-02)
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_OCC = self.GS_NN.by_col(' est_OCC_TEC') se_OCC = self.GS_NN.by_col(' se_OCC_TEC') t_OCC = self.GS_NN.by_col(' t_OCC_TEC') est_OWN = self.GS_NN.by_col(' est_OWNH') se_OWN = self.GS_NN.by_col(' se_OWNH') t_OWN = self.GS_NN.by_col(' t_OWNH') est_POP = self.GS_NN.by_col(' est_POP65') se_POP = self.GS_NN.by_col(' se_POP65') t_POP = self.GS_NN.by_col(' t_POP65') est_UNEMP = self.GS_NN.by_col(' est_UNEMP') se_UNEMP = self.GS_NN.by_col(' se_UNEMP') t_UNEMP = self.GS_NN.by_col(' t_UNEMP') yhat = self.GS_NN.by_col(' yhat') pdev = np.array(self.GS_NN.by_col(' localpdev')).reshape((-1, 1)) model = GWR(self.coords, self.y, self.X, bw=50, family=Poisson(), kernel='gaussian', fixed=False) rslt = model.fit() AICc = get_AICc(rslt) AIC = get_AIC(rslt) BIC = get_BIC(rslt) self.assertAlmostEquals(np.floor(AICc), 21070.0) self.assertAlmostEquals(np.floor(AIC), 21069.0) self.assertAlmostEquals(np.floor(BIC), 21111.0) np.testing.assert_allclose(est_Int, rslt.params[:, 0], rtol=1e-04) np.testing.assert_allclose(se_Int, rslt.bse[:, 0], rtol=1e-02) np.testing.assert_allclose(t_Int, rslt.tvalues[:, 0], rtol=1e-02) np.testing.assert_allclose(est_OCC, rslt.params[:, 1], rtol=1e-03) np.testing.assert_allclose(se_OCC, rslt.bse[:, 1], rtol=1e-02) np.testing.assert_allclose(t_OCC, rslt.tvalues[:, 1], rtol=1e-02) np.testing.assert_allclose(est_OWN, rslt.params[:, 2], rtol=1e-04) np.testing.assert_allclose(se_OWN, rslt.bse[:, 2], rtol=1e-02) np.testing.assert_allclose(t_OWN, rslt.tvalues[:, 2], rtol=1e-02) np.testing.assert_allclose(est_POP, rslt.params[:, 3], rtol=1e-02) np.testing.assert_allclose(se_POP, rslt.bse[:, 3], rtol=1e-02) np.testing.assert_allclose(t_POP, rslt.tvalues[:, 3], rtol=1e-02) np.testing.assert_allclose(est_UNEMP, rslt.params[:, 4], rtol=1e-02) np.testing.assert_allclose(se_UNEMP, rslt.bse[:, 4], rtol=1e-02) np.testing.assert_allclose(t_UNEMP, rslt.tvalues[:, 4], rtol=1e-02) np.testing.assert_allclose(yhat, rslt.mu, rtol=1e-04) np.testing.assert_allclose(pdev, rslt.pDev, rtol=1e-05)
def test_BS_F(self): est_Int = self.BS_F.by_col(' est_Intercept') se_Int = self.BS_F.by_col(' se_Intercept') t_Int = self.BS_F.by_col(' t_Intercept') est_OCC = self.BS_F.by_col(' est_OCC_TEC') se_OCC = self.BS_F.by_col(' se_OCC_TEC') t_OCC = self.BS_F.by_col(' t_OCC_TEC') est_OWN = self.BS_F.by_col(' est_OWNH') se_OWN = self.BS_F.by_col(' se_OWNH') t_OWN = self.BS_F.by_col(' t_OWNH') est_POP = self.BS_F.by_col(' est_POP65') se_POP = self.BS_F.by_col(' se_POP65') t_POP = self.BS_F.by_col(' t_POP65') est_UNEMP = self.BS_F.by_col(' est_UNEMP') se_UNEMP = self.BS_F.by_col(' se_UNEMP') t_UNEMP = self.BS_F.by_col(' t_UNEMP') yhat = self.BS_F.by_col(' yhat') pdev = np.array(self.BS_F.by_col(' localpdev')).reshape((-1, 1)) model = GWR(self.coords, self.y, self.X, bw=26029.625, family=Poisson(), kernel='bisquare', fixed=True) rslt = model.fit() AICc = get_AICc(rslt) AIC = get_AIC(rslt) BIC = get_BIC(rslt) self.assertAlmostEquals(np.floor(AICc), 13294.0) self.assertAlmostEquals(np.floor(AIC), 13247.0) self.assertAlmostEquals(np.floor(BIC), 13485.0) np.testing.assert_allclose(est_Int, rslt.params[:, 0], rtol=1e-05) np.testing.assert_allclose(se_Int, rslt.bse[:, 0], rtol=1e-03) np.testing.assert_allclose(t_Int, rslt.tvalues[:, 0], rtol=1e-03) np.testing.assert_allclose(est_OCC, rslt.params[:, 1], rtol=1e-04) np.testing.assert_allclose(se_OCC, rslt.bse[:, 1], rtol=1e-02) np.testing.assert_allclose(t_OCC, rslt.tvalues[:, 1], rtol=1e-02) np.testing.assert_allclose(est_OWN, rslt.params[:, 2], rtol=1e-04) np.testing.assert_allclose(se_OWN, rslt.bse[:, 2], rtol=1e-03) np.testing.assert_allclose(t_OWN, rslt.tvalues[:, 2], rtol=1e-03) np.testing.assert_allclose(est_POP, rslt.params[:, 3], rtol=1e-04) np.testing.assert_allclose(se_POP, rslt.bse[:, 3], rtol=1e-02) np.testing.assert_allclose(t_POP, rslt.tvalues[:, 3], rtol=1e-02) np.testing.assert_allclose(est_UNEMP, rslt.params[:, 4], rtol=1e-04) np.testing.assert_allclose(se_UNEMP, rslt.bse[:, 4], rtol=1e-02) np.testing.assert_allclose(t_UNEMP, rslt.tvalues[:, 4], rtol=1e-02) np.testing.assert_allclose(yhat, rslt.mu, rtol=1e-05) np.testing.assert_allclose(pdev, rslt.pDev, rtol=1e-05)
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_OCC = self.GS_NN.by_col(' est_OCC_TEC') se_OCC = self.GS_NN.by_col(' se_OCC_TEC') t_OCC = self.GS_NN.by_col(' t_OCC_TEC') est_OWN = self.GS_NN.by_col(' est_OWNH') se_OWN = self.GS_NN.by_col(' se_OWNH') t_OWN = self.GS_NN.by_col(' t_OWNH') est_POP = self.GS_NN.by_col(' est_POP65') se_POP = self.GS_NN.by_col(' se_POP65') t_POP = self.GS_NN.by_col(' t_POP65') est_UNEMP = self.GS_NN.by_col(' est_UNEMP') se_UNEMP = self.GS_NN.by_col(' se_UNEMP') t_UNEMP = self.GS_NN.by_col(' t_UNEMP') yhat = self.GS_NN.by_col(' yhat') pdev = np.array(self.GS_NN.by_col(' localpdev')).reshape((-1,1)) model = GWR(self.coords, self.y, self.X, bw=50, family=Poisson(), kernel='gaussian', fixed=False) rslt = model.fit() AICc = get_AICc(rslt) AIC = get_AIC(rslt) BIC = get_BIC(rslt) self.assertAlmostEquals(np.floor(AICc), 21070.0) self.assertAlmostEquals(np.floor(AIC), 21069.0) self.assertAlmostEquals(np.floor(BIC), 21111.0) np.testing.assert_allclose(est_Int, rslt.params[:,0], rtol=1e-04) np.testing.assert_allclose(se_Int, rslt.bse[:,0], rtol=1e-02) np.testing.assert_allclose(t_Int, rslt.tvalues[:,0], rtol=1e-02) np.testing.assert_allclose(est_OCC, rslt.params[:,1], rtol=1e-03) np.testing.assert_allclose(se_OCC, rslt.bse[:,1], rtol=1e-02) np.testing.assert_allclose(t_OCC, rslt.tvalues[:,1], rtol=1e-02) np.testing.assert_allclose(est_OWN, rslt.params[:,2], rtol=1e-04) np.testing.assert_allclose(se_OWN, rslt.bse[:,2], rtol=1e-02) np.testing.assert_allclose(t_OWN, rslt.tvalues[:,2], rtol=1e-02) np.testing.assert_allclose(est_POP, rslt.params[:,3], rtol=1e-02) np.testing.assert_allclose(se_POP, rslt.bse[:,3], rtol=1e-02) np.testing.assert_allclose(t_POP, rslt.tvalues[:,3], rtol=1e-02) np.testing.assert_allclose(est_UNEMP, rslt.params[:,4], rtol=1e-02) np.testing.assert_allclose(se_UNEMP, rslt.bse[:,4], rtol=1e-02) np.testing.assert_allclose(t_UNEMP, rslt.tvalues[:,4], rtol=1e-02) np.testing.assert_allclose(yhat, rslt.mu, rtol=1e-04) np.testing.assert_allclose(pdev, rslt.pDev, rtol=1e-05)
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_elev = self.GS_NN.by_col(' est_Elev') se_elev = self.GS_NN.by_col(' se_Elev') t_elev = self.GS_NN.by_col(' t_Elev') est_slope = self.GS_NN.by_col(' est_Slope') se_slope = self.GS_NN.by_col(' se_Slope') t_slope = self.GS_NN.by_col(' t_Slope') est_sin = self.GS_NN.by_col(' est_SinAspct') se_sin = self.GS_NN.by_col(' se_SinAspct') t_sin = self.GS_NN.by_col(' t_SinAspct') est_cos = self.GS_NN.by_col(' est_CosAspct') se_cos = self.GS_NN.by_col(' se_CosAspct') t_cos = self.GS_NN.by_col(' t_CosAspct') est_south = self.GS_NN.by_col(' est_AbsSouth') se_south = self.GS_NN.by_col(' se_AbsSouth') t_south = self.GS_NN.by_col(' t_AbsSouth') est_strm = self.GS_NN.by_col(' est_DistStrm') se_strm = self.GS_NN.by_col(' se_DistStrm') t_strm = self.GS_NN.by_col(' t_DistStrm') yhat = self.GS_NN.by_col(' yhat') pdev = self.GS_NN.by_col(' localpdev') model = GWR(self.coords, self.y, self.X, bw=64, family=Binomial(), kernel='gaussian', fixed=False) rslt = model.fit() AICc = get_AICc(rslt) AIC = get_AIC(rslt) BIC = get_BIC(rslt) self.assertAlmostEquals(np.floor(AICc), 276.0) self.assertAlmostEquals(np.floor(AIC), 273.0) self.assertAlmostEquals(np.floor(BIC), 331.0) np.testing.assert_allclose(est_Int, rslt.params[:, 0], rtol=1e-00) np.testing.assert_allclose(se_Int, rslt.bse[:, 0], rtol=1e-00) np.testing.assert_allclose(t_Int, rslt.tvalues[:, 0], rtol=1e-00) np.testing.assert_allclose(est_elev, rslt.params[:, 1], rtol=1e-00) np.testing.assert_allclose(se_elev, rslt.bse[:, 1], rtol=1e-00) np.testing.assert_allclose(t_elev, rslt.tvalues[:, 1], rtol=1e-00) np.testing.assert_allclose(est_slope, rslt.params[:, 2], rtol=1e-00) np.testing.assert_allclose(se_slope, rslt.bse[:, 2], rtol=1e-00) np.testing.assert_allclose(t_slope, rslt.tvalues[:, 2], rtol=1e-00) np.testing.assert_allclose(est_sin, rslt.params[:, 3], rtol=1e01) np.testing.assert_allclose(se_sin, rslt.bse[:, 3], rtol=1e01) np.testing.assert_allclose(t_sin, rslt.tvalues[:, 3], rtol=1e01) np.testing.assert_allclose(est_cos, rslt.params[:, 4], rtol=1e01) np.testing.assert_allclose(se_cos, rslt.bse[:, 4], rtol=1e01) np.testing.assert_allclose(t_cos, rslt.tvalues[:, 4], rtol=1e01) np.testing.assert_allclose(est_south, rslt.params[:, 5], rtol=1e01) np.testing.assert_allclose(se_south, rslt.bse[:, 5], rtol=1e01) np.testing.assert_allclose(t_south, rslt.tvalues[:, 5], rtol=1e01) np.testing.assert_allclose(est_strm, rslt.params[:, 6], rtol=1e02) np.testing.assert_allclose(se_strm, rslt.bse[:, 6], rtol=1e01) np.testing.assert_allclose(t_strm, rslt.tvalues[:, 6], rtol=1e02) np.testing.assert_allclose(yhat, rslt.mu, rtol=1e-00)
def test_BS_F(self): est_Int = self.BS_F.by_col(' est_Intercept') se_Int = self.BS_F.by_col(' se_Intercept') t_Int = self.BS_F.by_col(' t_Intercept') est_elev = self.BS_F.by_col(' est_Elev') se_elev = self.BS_F.by_col(' se_Elev') t_elev = self.BS_F.by_col(' t_Elev') est_slope = self.BS_F.by_col(' est_Slope') se_slope = self.BS_F.by_col(' se_Slope') t_slope = self.BS_F.by_col(' t_Slope') est_sin = self.BS_F.by_col(' est_SinAspct') se_sin = self.BS_F.by_col(' se_SinAspct') t_sin = self.BS_F.by_col(' t_SinAspct') est_cos = self.BS_F.by_col(' est_CosAspct') se_cos = self.BS_F.by_col(' se_CosAspct') t_cos = self.BS_F.by_col(' t_CosAspct') est_south = self.BS_F.by_col(' est_AbsSouth') se_south = self.BS_F.by_col(' se_AbsSouth') t_south = self.BS_F.by_col(' t_AbsSouth') est_strm = self.BS_F.by_col(' est_DistStrm') se_strm = self.BS_F.by_col(' se_DistStrm') t_strm = self.BS_F.by_col(' t_DistStrm') yhat = self.BS_F.by_col(' yhat') pdev = np.array(self.BS_F.by_col(' localpdev')).reshape((-1, 1)) model = GWR(self.coords, self.y, self.X, bw=19642.170, family=Binomial(), kernel='bisquare', fixed=True) rslt = model.fit() AICc = get_AICc(rslt) AIC = get_AIC(rslt) BIC = get_BIC(rslt) self.assertAlmostEquals(np.floor(AICc), 275.0) self.assertAlmostEquals(np.floor(AIC), 271.0) self.assertAlmostEquals(np.floor(BIC), 349.0) np.testing.assert_allclose(est_Int, rslt.params[:, 0], rtol=1e-00) np.testing.assert_allclose(se_Int, rslt.bse[:, 0], rtol=1e-00) np.testing.assert_allclose(t_Int, rslt.tvalues[:, 0], rtol=1e-00) np.testing.assert_allclose(est_elev, rslt.params[:, 1], rtol=1e-00) np.testing.assert_allclose(se_elev, rslt.bse[:, 1], rtol=1e-00) np.testing.assert_allclose(t_elev, rslt.tvalues[:, 1], rtol=1e-00) np.testing.assert_allclose(est_slope, rslt.params[:, 2], rtol=1e-00) np.testing.assert_allclose(se_slope, rslt.bse[:, 2], rtol=1e-00) np.testing.assert_allclose(t_slope, rslt.tvalues[:, 2], rtol=1e-00) np.testing.assert_allclose(est_sin, rslt.params[:, 3], rtol=1e01) np.testing.assert_allclose(se_sin, rslt.bse[:, 3], rtol=1e01) np.testing.assert_allclose(t_sin, rslt.tvalues[:, 3], rtol=1e01) np.testing.assert_allclose(est_cos, rslt.params[:, 4], rtol=1e01) np.testing.assert_allclose(se_cos, rslt.bse[:, 4], rtol=1e01) np.testing.assert_allclose(t_cos, rslt.tvalues[:, 4], rtol=1e01) np.testing.assert_allclose(est_south, rslt.params[:, 5], rtol=1e01) np.testing.assert_allclose(se_south, rslt.bse[:, 5], rtol=1e01) np.testing.assert_allclose(t_south, rslt.tvalues[:, 5], rtol=1e01) np.testing.assert_allclose(est_strm, rslt.params[:, 6], rtol=1e02) np.testing.assert_allclose(se_strm, rslt.bse[:, 6], rtol=1e01) np.testing.assert_allclose(t_strm, rslt.tvalues[:, 6], rtol=1e02) np.testing.assert_allclose(yhat, rslt.mu, rtol=1e-01)