def __init__(self): np.random.seed(54321) self.endog_n_ = np.random.uniform(0,20,size=30) self.endog_n_one = self.endog_n_[:,None] self.exog_n_ = np.random.uniform(0,20,size=30) self.exog_n_one = self.exog_n_[:,None] self.degen_exog = self.exog_n_one[:-1] self.mod1 = OLS(self.endog_n_one, self.exog_n_one) self.mod1.df_model += 1 #self.mod1.df_resid -= 1 self.res1 = self.mod1.fit() # Note that these are created for every subclass.. # A little extra overhead probably self.mod2 = OLS(self.endog_n_one, self.exog_n_one) self.mod2.df_model += 1 self.res2 = self.mod2.fit()
def __init__(self): from scikits.statsmodels.datasets.longley import load data = load() data.exog = add_constant(data.exog) self.res1 = OLS(data.endog, data.exog).fit() R = np.identity(7)[:-1,:] self.Ftest = self.res1.f_test(R)
class TestDataDimensions(CheckRegressionResults): def __init__(self): np.random.seed(54321) self.endog_n_ = np.random.uniform(0,20,size=30) self.endog_n_one = self.endog_n_[:,None] self.exog_n_ = np.random.uniform(0,20,size=30) self.exog_n_one = self.exog_n_[:,None] self.degen_exog = self.exog_n_one[:-1] self.mod1 = OLS(self.endog_n_one, self.exog_n_one) self.mod1.df_model += 1 #self.mod1.df_resid -= 1 self.res1 = self.mod1.fit() # Note that these are created for every subclass.. # A little extra overhead probably self.mod2 = OLS(self.endog_n_one, self.exog_n_one) self.mod2.df_model += 1 self.res2 = self.mod2.fit() def check_confidenceintervals(self, conf1, conf2): assert_almost_equal(conf1, conf2(), DECIMAL_4)
def __init__(self): from scikits.statsmodels.datasets.longley import load data = load() self.data = data data.exog = add_constant(data.exog) self.res1 = OLS(data.endog, data.exog).fit() # def setup(self): # if skipR: # raise SkipTest, "Rpy not installed" # else: R = np.identity(7) self.Ttest = self.res1.t_test(R)
class TestTtest(object): ''' Test individual t-tests. Ie., are the coefficients significantly different than zero. ''' def __init__(self): from scikits.statsmodels.datasets.longley import load data = load() self.data = data data.exog = add_constant(data.exog) self.res1 = OLS(data.endog, data.exog).fit() # def setup(self): # if skipR: # raise SkipTest, "Rpy not installed" # else: R = np.identity(7) self.Ttest = self.res1.t_test(R) # self.R_Results = RModel(data.endog, data.exog, r.lm).robj def test_tvalue(self): assert_almost_equal(self.Ttest.tvalue, self.res1.t(), DECIMAL_4) def test_sd(self): assert_almost_equal(self.Ttest.sd, self.res1.bse, DECIMAL_4) def test_pvalue(self): assert_almost_equal(self.Ttest.pvalue, student_t.sf(np.abs(self.res1.t()),self.res1.model.df_resid), DECIMAL_4) def test_df_denom(self): assert_equal(self.Ttest.df_denom, self.res1.model.df_resid) def test_effect(self): assert_almost_equal(self.Ttest.effect, self.res1.params)
class TestFtest(object): """ Tests f_test vs. RegressionResults """ def __init__(self): from scikits.statsmodels.datasets.longley import load data = load() data.exog = add_constant(data.exog) self.res1 = OLS(data.endog, data.exog).fit() R = np.identity(7)[:-1,:] self.Ftest = self.res1.f_test(R) def test_F(self): assert_almost_equal(self.Ftest.fvalue, self.res1.fvalue, DECIMAL_4) def test_p(self): assert_almost_equal(self.Ftest.pvalue, self.res1.f_pvalue, DECIMAL_4) def test_Df_denom(self): assert_equal(self.Ftest.df_denom, self.res1.model.df_resid) def test_Df_num(self): assert_equal(self.Ftest.df_num, 6)
def __init__(self): super(TestNxNxOne, self).__init__() self.mod2 = OLS(self.endog_n_, self.exog_n_one) self.mod2.df_model += 1 self.res2 = self.mod2.fit()
class TestNxNxOne(TestDataDimensions): def __init__(self): super(TestNxNxOne, self).__init__() self.mod2 = OLS(self.endog_n_, self.exog_n_one) self.mod2.df_model += 1 self.res2 = self.mod2.fit()