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)