예제 #1
0
    def test_margins(self):

        n = 300
        exog = np.random.normal(size=(n, 4))
        exog[:,0] = 1
        exog[:,1] = 1*(exog[:,2] < 0)

        group = np.kron(np.arange(n/4), np.ones(4))
        time = np.zeros((n, 1))

        beta = np.r_[0, 1, -1, 0.5]
        lpr = np.dot(exog, beta)
        prob = 1 / (1 + np.exp(-lpr))

        endog = 1*(np.random.uniform(size=n) < prob)

        fa = Binomial()
        ex = Exchangeable()

        md = GEE(endog, exog, group, time, fa, ex)
        mdf = md.fit()

        marg = GEEMargins(mdf, ())
        marg.summary()
예제 #2
0
    def test_margins(self):

        n = 300
        exog = np.random.normal(size=(n, 4))
        exog[:, 0] = 1
        exog[:, 1] = 1 * (exog[:, 2] < 0)

        group = np.kron(np.arange(n / 4), np.ones(4))
        time = np.zeros((n, 1))

        beta = np.r_[0, 1, -1, 0.5]
        lpr = np.dot(exog, beta)
        prob = 1 / (1 + np.exp(-lpr))

        endog = 1 * (np.random.uniform(size=n) < prob)

        fa = Binomial()
        ex = Exchangeable()

        md = GEE(endog, exog, group, time, fa, ex)
        mdf = md.fit()

        marg = GEEMargins(mdf, ())
        marg.summary()
예제 #3
0
'''
>>> mdf2.predict(da.exog.mean(0))
Traceback (most recent call last):
  File "<pyshell#11>", line 1, in <module>
    mdf2.predict(da.exog.mean(0))
  File "e:\josef\eclipsegworkspace\statsmodels-git\statsmodels-all-new2_py27\statsmodels\statsmodels\base\model.py", line 963, in predict
    return self.model.predict(self.params, exog, *args, **kwargs)
  File "e:\josef\eclipsegworkspace\statsmodels-git\statsmodels-all-new2_py27\statsmodels\statsmodels\genmod\generalized_estimating_equations.py", line 621, in predict
    fitted = offset + np.dot(exog, params)
TypeError: unsupported operand type(s) for +: 'NoneType' and 'numpy.float64'
'''
mdf2.predict(da.exog.mean(0), offset=0)
# -0.10867809062890971

marg2 = GEEMargins(mdf2, ())
print marg2.summary()


mdf_nc = md2.fit(covariance_type='naive')
mdf_bc = md2.fit(covariance_type='bias_reduced')

mdf_nc.use_t = False
mdf_nc.df_resid = np.diff(mdf2.model.exog.shape)
mdf_bc.use_t = False
mdf_bc.df_resid = np.diff(mdf2.model.exog.shape)

tt_nc = mdf_nc.t_test(np.eye(len(mdf2.params)))
tt_bc = mdf_bc.t_test(np.eye(len(mdf2.params)))

print '\nttest robust'
예제 #4
0
"""
>>> mdf2.predict(da.exog.mean(0))
Traceback (most recent call last):
  File "<pyshell#11>", line 1, in <module>
    mdf2.predict(da.exog.mean(0))
  File "e:\josef\eclipsegworkspace\statsmodels-git\statsmodels-all-new2_py27\statsmodels\statsmodels\base\model.py", line 963, in predict
    return self.model.predict(self.params, exog, *args, **kwargs)
  File "e:\josef\eclipsegworkspace\statsmodels-git\statsmodels-all-new2_py27\statsmodels\statsmodels\genmod\generalized_estimating_equations.py", line 621, in predict
    fitted = offset + np.dot(exog, params)
TypeError: unsupported operand type(s) for +: 'NoneType' and 'numpy.float64'
"""
mdf2.predict(da.exog.mean(0), offset=0)
# -0.10867809062890971

marg2 = GEEMargins(mdf2, ())
print(marg2.summary())


mdf_nc = md2.fit(cov_type="naive")
mdf_bc = md2.fit(cov_type="bias_reduced")

mdf_nc.use_t = False
mdf_nc.df_resid = np.diff(mdf2.model.exog.shape)
mdf_bc.use_t = False
mdf_bc.df_resid = np.diff(mdf2.model.exog.shape)

tt_nc = mdf_nc.t_test(np.eye(len(mdf2.params)))
tt_bc = mdf_bc.t_test(np.eye(len(mdf2.params)))

print("\nttest robust")
예제 #5
0
'''
>>> mdf2.predict(da.exog.mean(0))
Traceback (most recent call last):
  File "<pyshell#11>", line 1, in <module>
    mdf2.predict(da.exog.mean(0))
  File "e:\josef\eclipsegworkspace\statsmodels-git\statsmodels-all-new2_py27\statsmodels\statsmodels\base\model.py", line 963, in predict
    return self.model.predict(self.params, exog, *args, **kwargs)
  File "e:\josef\eclipsegworkspace\statsmodels-git\statsmodels-all-new2_py27\statsmodels\statsmodels\genmod\generalized_estimating_equations.py", line 621, in predict
    fitted = offset + np.dot(exog, params)
TypeError: unsupported operand type(s) for +: 'NoneType' and 'numpy.float64'
'''
mdf2.predict(da.exog.mean(0), offset=0)
# -0.10867809062890971

marg2 = GEEMargins(mdf2, ())
print(marg2.summary())


mdf_nc = md2.fit(cov_type='naive')
mdf_bc = md2.fit(cov_type='bias_reduced')

mdf_nc.use_t = False
mdf_nc.df_resid = np.diff(mdf2.model.exog.shape)
mdf_bc.use_t = False
mdf_bc.df_resid = np.diff(mdf2.model.exog.shape)

tt_nc = mdf_nc.t_test(np.eye(len(mdf2.params)))
tt_bc = mdf_bc.t_test(np.eye(len(mdf2.params)))

print('\nttest robust')