示例#1
0
 def test_ziopcmodel(self):
     self.assertAlmostEqual(zmiopc.iopcmod('ziopc',
                                           data,
                                           X,
                                           Y,
                                           Z,
                                           pstart=pstartziopc,
                                           method='bfgs',
                                           weights=1,
                                           offsetx=0,
                                           offsetz=0).coefs.iloc[-1, 0],
                            -0.889,
                            places=1)
     self.assertAlmostEqual(zmiopc.iopcmod('ziopc',
                                           data,
                                           X,
                                           Y,
                                           Z,
                                           pstart=pstartziopc,
                                           method='bfgs',
                                           weights=1,
                                           offsetx=0,
                                           offsetz=0).coefs.iloc[4, 0],
                            -0.37,
                            places=1)
     self.assertAlmostEqual(zmiopc.iopcmod('ziopc',
                                           data,
                                           X,
                                           Y,
                                           Z,
                                           pstart=pstartziopc,
                                           method='bfgs',
                                           weights=1,
                                           offsetx=0,
                                           offsetz=0).coefs.iloc[5, 0],
                            0.33,
                            places=1)
示例#2
0
 def test_vuongopziopc(self):
     self.assertAlmostEqual(zmiopc.vuong_opiop(
         zmiopc.opmod(data,
                      X,
                      Y,
                      pstart=pstartop,
                      method='bfgs',
                      weights=1,
                      offsetx=0),
         zmiopc.iopmod('ziop',
                       data,
                       X,
                       Y,
                       Z,
                       pstart=pstartziop,
                       method='bfgs',
                       weights=1,
                       offsetx=0,
                       offsetz=0)),
                            -4.909,
                            places=1)
     self.assertAlmostEqual(zmiopc.vuong_opiopc(
         zmiopc.opmod(data,
                      X,
                      Y,
                      pstart=pstartop,
                      method='bfgs',
                      weights=1,
                      offsetx=0),
         zmiopc.iopcmod('ziopc',
                        data,
                        X,
                        Y,
                        Z,
                        pstart=pstartziopc,
                        method='bfgs',
                        weights=1,
                        offsetx=0,
                        offsetz=0)),
                            -5.424,
                            places=1)
示例#3
0
 def test_miopcmodel(self):
     self.assertAlmostEqual(zmiopc.iopcmod('miopc', DAT, X, Y,
                                           Z).coefs.iloc[14, 0],
                            0.84,
                            places=1)
示例#4
0
# Ziop and ziopc examples
# Specifying Xs, Zs, and Y

X = ['logGDPpc', 'parliament', 'disaster', 'major_oil', 'major_primary']
Z = ['logGDPpc', 'parliament']
Y = ['rep_civwar_DV']
data = DAT

pstartziop = [-1.31, .32, 2.5, -.21, .2, -0.2, -0.4, 0.2, .9, -.4]

pstartziopc = [-1.31, .32, 2.5, -.21,
               .2, -0.2, -0.4, 0.2, .9, -.4, .1]

start_time = time.time()
ziopc_JCR = zmiopc.iopcmod('ziopc',
                           data, X, Y, Z, pstart=pstartziopc, method='bfgs',
                           weights=1,
                           offsetx=0, offsetz=0)
model_time = time.time() - start_time
print("%s seconds" % model_time)

start_time = time.time()
ziop_JCR = zmiopc.iopmod('ziop',
                         data, X, Y, Z, pstart=pstartziop,
                         method='bfgs', weights=1,
                         offsetx=0,
                         offsetz=0)
model_time = time.time() - start_time
print("%s seconds" % model_time)

# OP Model
pstartop = [-1, 0.3, -0.2, -0.5, 0.2, .9, -.4]
示例#5
0
X = ["polit_trust", "Xenophobia", "discuss_politics", "Professional",
     "Executive", "Manual", "Farmer", "Unemployed", "rural", "female", "age",
     "student", "income", "Educ_high", "Educ_high_mid", "Educ_low_mid"]

Z = ["discuss_politics", "rural", "female", "age",
     "student", "EUbid_Know", "EU_Know_obj", "TV", "Educ_high",
     "Educ_high_mid", "Educ_low_mid"]

start_time = time.time()
miop_model_paper = zmiopc.iopmod('miop', DAT, X, Y, Z)
model_time = time.time() - start_time
print("%s seconds" % model_time)

start_time = time.time()
miopc_model_paper = zmiopc.iopcmod('miopc', DAT, X, Y, Z)
model_time = time.time() - start_time
print("%s seconds" % model_time)

# This is the specification for the Documentation Example:

X2 = ['Xenophobia', 'discuss_politics']
Z2 = ['discuss_politics', 'EU_Know_obj']

start_time = time.time()
miop_model_short = zmiopc.iopmod('miop', DAT, X2, Y, Z2)
model_time = time.time() - start_time
print("%s seconds" % model_time)

start_time = time.time()
miopc_model_short = zmiopc.iopcmod('miopc', DAT, X2, Y, Z2)
示例#6
0
def test_miopc_coefs():
    miopc_EU = zmiopc.iopcmod('miopc', dataeu, X2, Y2, Z2)
    assert len(miopc_EU.coefs) == len(X2 + Z2) + len(yvar) + 1
示例#7
0
def test_iopc_fitted():
    ziopc_JCR = zmiopc.iopcmod('ziopc', data, X, Y, Z, pstart=pstartziopc)
    fitttedziopc = zmiopc.iopcfit(ziopc_JCR)
    assert len(fitttedziopc.responseordered) == len(fitttedziopc.responsefull)
示例#8
0
def test_ziopc_coefs():
    ziopc_JCR = zmiopc.iopcmod('ziopc', data, X, Y, Z, pstart=pstartziopc)
    assert len(ziopc_JCR.coefs) == len(pstartziopc)