示例#1
0
    def setup_class(cls):
        mod1 = cls.model_cls(endog, exog, **cls.mod_kwargs)
        cls.res1 = mod1.fit(disp=False, **cls.fit_kwargs)

        mod2 = OLS(endog, exog)
        cls.res2 = mod2.fit(disp=False, **cls.fit_kwargs)

        # for debugging
        cls.res3 = mod2.fit(cov_type=cls.cov_type, cov_kwds={'maxlags': 2})
示例#2
0
    def setup_class(cls):
        mod1 = cls.model_cls(endog, exog, **cls.mod_kwargs)
        cls.res1 = mod1.fit(disp=False, **cls.fit_kwargs)
        cls.res1b = mod1.fit(disp=False, **cls.fit_kwargs)

        mod2 = OLS(endog, exog)
        cls.res2 = mod2.fit(disp=False, **cls.fit_kwargs)
示例#3
0
    def setup_class(cls):
        mod1 = cls.model_cls(endog, exog, **cls.mod_kwargs)
        cls.res1 = mod1.fit(disp=False, **cls.fit_kwargs)
        cls.res1b = mod1.fit(cov_type='nw-panel', cov_kwds=cls.cov_kwds)

        mod2 = OLS(endog, exog)
        cls.res2 = mod2.fit(disp=False, **cls.fit_kwargs)
示例#4
0
    def setup_class(cls):
        mod1 = cls.model_cls(endog, exog, **cls.mod_kwargs)
        cls.res1 = mod1.fit(**cls.fit_kwargs)

        mod2 = OLS(endog, exog)
        # check kernel as string
        kwds2 = {'kernel': 'uniform', 'maxlags': 2}
        cls.res2 = mod2.fit(cov_type=cls.cov_type, cov_kwds=kwds2)
示例#5
0
    def setup_class(cls):
        # check kernel specified as string
        mod1 = cls.model_cls(endog, exog, **cls.mod_kwargs)
        cls.res1 = mod1.fit(disp=False, **cls.fit_kwargs)

        mod2 = OLS(endog, exog)
        cls.res2 = mod2.fit(disp=False,
                            cov_type=cls.cov_type,
                            cov_kwds={'maxlags': 2})
示例#6
0
 def setup(self):
     model = OLS(self.res1.model.endog, self.res1.model.exog)
     res_ols = model.fit(cov_type='cluster',
                         cov_kwds=dict(groups=self.groups,
                                       use_correction=False,
                                       use_t=False,
                                       df_correction=True))
     self.res3 = self.res1
     self.res1 = res_ols
     self.bse_robust = res_ols.bse
     self.cov_robust = res_ols.cov_params()
     cov1 = sw.cov_cluster(self.res1, self.groups, use_correction=False)
     se1 = sw.se_cov(cov1)
     self.bse_robust2 = se1
     self.cov_robust2 = cov1
示例#7
0
def test_regularized_refit():
    n = 100
    p = 5
    np.random.seed(3132)
    xmat = np.random.normal(size=(n, p))
    # covariates 0 and 2 matter
    yvec = xmat[:, 0] + xmat[:, 2] + np.random.normal(size=n)
    model1 = OLS(yvec, xmat)
    result1 = model1.fit_regularized(alpha=2., L1_wt=0.5, refit=True)

    model2 = OLS(yvec, xmat[:, [0, 2]])
    result2 = model2.fit()
    ii = [0, 2]
    assert_allclose(result1.params[ii], result2.params)
    assert_allclose(result1.bse[ii], result2.bse)
示例#8
0
    def setup_class(cls):
        data = datasets.longley.load(as_pandas=False)
        data.exog = add_constant(data.exog, prepend=False)
        cls.res1 = OLS(data.endog, data.exog).fit()
        #cls.res2.wresid = cls.res1.wresid  # workaround hack

        res_qr = OLS(data.endog, data.exog).fit(method="qr")

        model_qr = OLS(data.endog, data.exog)
        Q, R = np.linalg.qr(data.exog)
        model_qr.exog_Q, model_qr.exog_R = Q, R
        model_qr.normalized_cov_params = np.linalg.inv(np.dot(R.T, R))
        model_qr.rank = np.linalg.matrix_rank(R)
        res_qr2 = model_qr.fit(method="qr")

        cls.res_qr = res_qr
        cls.res_qr_manual = res_qr2
示例#9
0
    def setup_class(cls):  # TODO: Why does upstream copy endog/exog?
        mod1 = cls.model_cls(endog, exog, **cls.mod_kwargs)
        cls.res1 = mod1.fit(disp=False, **cls.fit_kwargs)

        mod2 = OLS(endog, exog)
        cls.res2 = mod2.fit(disp=False, **cls.fit_kwargs)
示例#10
0
    def setup_class(cls):  # TODO: de-dup with other setup_classes
        mod1 = cls.model_cls(endog, exog, **cls.mod_kwargs)
        cls.res1 = mod1.fit(disp=False, **cls.fit_kwargs)

        mod2 = OLS(endog, exog)
        cls.res2 = mod2.fit(disp=False, **cls.fit_kwargs)