def test_nominal(self): family = Multinomial(3) endog, exog, groups = load_data("gee_nominal_1.csv", icept=False) # Test with independence correlation va = Independence() mod1 = NominalGEE(endog, exog, groups, None, family, va) rslt1 = mod1.fit() # Regression test cf1 = np.r_[0.44944752, 0.45569985, -0.92007064, -0.46766728] se1 = np.r_[0.09801821, 0.07718842, 0.13229421, 0.08544553] assert_almost_equal(rslt1.params, cf1, decimal=5) assert_almost_equal(rslt1.standard_errors(), se1, decimal=5) # Test with global odds ratio dependence va = GlobalOddsRatio("nominal") mod2 = NominalGEE(endog, exog, groups, None, family, va) rslt2 = mod2.fit(start_params=rslt1.params) # Regression test cf2 = np.r_[0.45448248, 0.41945568, -0.92008924, -0.50485758] se2 = np.r_[0.09632274, 0.07433944, 0.13264646, 0.0911768] assert_almost_equal(rslt2.params, cf2, decimal=5) assert_almost_equal(rslt2.standard_errors(), se2, decimal=5) # Make sure we get the correct results type assert_equal(type(rslt1), NominalGEEResultsWrapper) assert_equal(type(rslt1._results), NominalGEEResults)
def test_nominal(self): family = Multinomial(3) endog, exog, groups = load_data("gee_nominal_1.csv", icept=False) # Test with independence correlation v = Independence() md = NominalGEE(endog, exog, groups, None, family, v) mdf1 = md.fit() # From statsmodels.GEE (not an independent test) cf1 = np.r_[0.44944752, 0.45569985, -0.92007064, -0.46766728] se1 = np.r_[0.09801821, 0.07718842, 0.13229421, 0.08544553] assert_almost_equal(mdf1.params, cf1, decimal=5) assert_almost_equal(mdf1.standard_errors(), se1, decimal=5) # Test with global odds ratio dependence v = GlobalOddsRatio("nominal") md = NominalGEE(endog, exog, groups, None, family, v) mdf2 = md.fit(start_params=mdf1.params) # From statsmodels.GEE (not an independent test) cf2 = np.r_[0.45448248, 0.41945568, -0.92008924, -0.50485758] se2 = np.r_[0.09632274, 0.07433944, 0.13264646, 0.0911768] assert_almost_equal(mdf2.params, cf2, decimal=5) assert_almost_equal(mdf2.standard_errors(), se2, decimal=5)
def test_nominal(self): endog, exog, groups = load_data("gee_nominal_1.csv", icept=False) # Test with independence correlation va = Independence() mod1 = NominalGEE(endog, exog, groups, cov_struct=va) rslt1 = mod1.fit() # Regression test cf1 = np.r_[0.450009, 0.451959, -0.918825, -0.468266] se1 = np.r_[0.08915936, 0.07005046, 0.12198139, 0.08281258] assert_allclose(rslt1.params, cf1, rtol=1e-5, atol=1e-5) assert_allclose(rslt1.standard_errors(), se1, rtol=1e-5, atol=1e-5) # Test with global odds ratio dependence va = GlobalOddsRatio("nominal") mod2 = NominalGEE(endog, exog, groups, cov_struct=va) rslt2 = mod2.fit(start_params=rslt1.params) # Regression test cf2 = np.r_[0.455365, 0.415334, -0.916589, -0.502116] se2 = np.r_[0.08803614, 0.06628179, 0.12259726, 0.08411064] assert_allclose(rslt2.params, cf2, rtol=1e-5, atol=1e-5) assert_allclose(rslt2.standard_errors(), se2, rtol=1e-5, atol=1e-5) # Make sure we get the correct results type assert_equal(type(rslt1), NominalGEEResultsWrapper) assert_equal(type(rslt1._results), NominalGEEResults)
def setup_class(cls): endog, exog, groups = load_data("gee_nominal_1.csv", icept=False) # Test with independence correlation va = Independence() cls.mod = NominalGEE(endog, exog, groups, cov_struct=va) cls.start_params = np.array( [0.44944752, 0.45569985, -0.92007064, -0.46766728])
def test_wrapper(self): endog, exog, groups = load_data("gee_nominal_1.csv", icept=False) endog = pd.Series(endog, name='yendog') exog = pd.DataFrame(exog) groups = pd.Series(groups, name='the_group') va = Independence() mod = NominalGEE(endog, exog, groups, cov_struct=va) rslt2 = mod.fit() check_wrapper(rslt2)