コード例 #1
0
ファイル: gimnl_unit_test.py プロジェクト: hknd23/idcempy
 def test_gimmnlmodel(self):
     self.assertEqual(len(
         gimnl.gimnlmod(DAT, x, y, z, order_Kerry, "baseline").coefs),
         45)
     self.assertAlmostEqual(gimnl.gimnlmod(
         DAT, x, y, z, order_Bush, "baseline").coefs.iloc[0, 0], -4.938,
                            places=1)
     self.assertAlmostEqual(gimnl.gimnlmod(
         DAT, x, y, z, order_Bush, "baseline").coefs.iloc[5, 0], -1.632,
                            places=1)
     self.assertAlmostEqual(gimnl.gimnlmod(
         DAT, x, y, z, order_Bush, "baseline").coefs.iloc[10, 0], -0.390,
                            places=1)
     self.assertAlmostEqual(gimnl.gimnlmod(
         DAT, x, y, z, order_Kerry, "baseline").coefs.iloc[0, 0], -4.938,
                            places=1)
     self.assertAlmostEqual(gimnl.gimnlmod(
         DAT, x, y, z, order_Kerry, "baseline").coefs.iloc[5, 0], -0.724,
                            places=1)
     self.assertAlmostEqual(gimnl.gimnlmod(
         DAT, x, y, z, order_Kerry, "baseline").coefs.iloc[10, 0], 0.344,
                            places=1)
コード例 #2
0
ファイル: gimnl_unit_test.py プロジェクト: hknd23/idcempy
 def test_vuongmnlgimnl(self):
     self.assertAlmostEqual(gimnl.vuong_gimnl(gimnl.mnlmod(
         DAT, x, y, order_Kerry), gimnl.gimnlmod(
         DAT, x, y, z, order_Kerry, "baseline")), -1.9174562877, places=4)
コード例 #3
0
ファイル: GIMNL_Example.py プロジェクト: hknd23/idcempy
    'south', 'gayban2', 'agegroup2', 'bornagn_w', 'brnag_wXgmb2', 'catholic',
    'cathXgmb2', 'other_rel', 'secular', 'secXgmb2', 'ideo', 'w3mobidx'
]
z = ['educ', 'agegroup2', 'w3mobidx', 'secular']
y = ['vote_turn']

order_Kerry = [0, 1, 2]
order_Bush = [0, 2, 1]

start_time = time.time()
modelmnl = gimnl.mnlmod(DAT, x, y, order_Kerry)
model_time = time.time() - start_time
print("%s seconds" % model_time)

start_time = time.time()
model = gimnl.gimnlmod(DAT, x, y, z, order_Kerry, "baseline")
model_time = time.time() - start_time
print("%s seconds" % model_time)

x2 = ['educ', 'party7', 'agegroup2']
z2 = ['educ', 'agegroup2']

start_time = time.time()
model_small = gimnl.gimnlmod(DAT, x2, y, z2, order_Kerry, "baseline")
model_time = time.time() - start_time
print("%s seconds" % model_time)

start_time = time.time()
mnl_small = gimnl.mnlmod(DAT, x2, y, order_Kerry)
model_time = time.time() - start_time
print("%s seconds" % model_time)
コード例 #4
0
def test_gimnls():
    model = gimnl.gimnlmod(DAT, x, y, z, order, binflatecat)
    smodel = gimnl.gimnlmod(DAT, x, y, z, second_order, sinflatecat)
    tmodel = gimnl.gimnlmod(DAT, x, y, z, torder, tinflatecat)
    assert model.modeltype == smodel.modeltype == tmodel.modeltype
コード例 #5
0
ファイル: biml_tests.py プロジェクト: zhangc927/idcempy
y = ['vote_turn']

order = [0, 1, 2]
orders = [0, 2, 1]
second_order = [1, 0, 2]
second_order2 = [2, 0, 1]
torder = [2, 1, 0]
torders = [1, 2, 0]

binflatecat = "baseline"
sinflatecat = "second"
tinflatecat = "third"

modelmnl = gimnl.mnlmod(DAT, x, y, order)

model = gimnl.gimnlmod(DAT, x, y, z, order, binflatecat)

gimnl.vuong_gimnl(modelmnl, model)
models = gimnl.gimnlmod(DAT, x, y, z, orders, binflatecat)

smodel = gimnl.gimnlmod(DAT, x, y, z, second_order, sinflatecat, method='BFGS')
smodels = gimnl.gimnlmod(DAT,
                         x,
                         y,
                         z,
                         second_order2,
                         sinflatecat,
                         method='BFGS')

tmodel = gimnl.gimnlmod(DAT, x, y, z, torder, tinflatecat, method='BFGS')
tmodels = gimnl.gimnlmod(DAT, x, y, z, torders, tinflatecat, method='BFGS')