示例#1
0
 def test_reg_unif(self):
     std = reg(self.df, self.y, self.x, cluster=self.cluster, addcons=True)
     shac = reg(self.df,
                self.y,
                self.x,
                shac=self.spatial_hac,
                addcons=True)
     expected = std.vce / std._vce_correct
     result = shac.vce / shac._vce_correct
     assert_array_almost_equal(expected, result)
示例#2
0
 def test_colinear_reg(self):
     """Stata reg output from `sysuse auto; reg price mpg`"""
     test_path = path.split(path.relpath(__file__))[0]
     auto_path = path.join(test_path, 'data', 'auto.dta')
     autodata = pd.read_stata(auto_path)
     autodata['mpg2'] = autodata['mpg'] * 2
     y = 'price'
     x = ['mpg', 'length', 'mpg2']
     # Check without check (Singular matrix error)
     with pytest.raises(np.linalg.linalg.LinAlgError):
         reg(autodata, y, x, addcons=True)
     # Check with check (my ValueError, with message)
     with pytest.raises(ValueError) as e:
         reg(autodata, y, x, addcons=True, check_colinear=True)
     assert 'Colinear variables: \nmpg2' == str(e.value)
示例#3
0
 def setup_class(cls):
     """Stata reg output from `sysuse auto; reg price mpg`"""
     test_path = path.split(path.relpath(__file__))[0]
     auto_path = path.join(test_path, 'data', 'auto.dta')
     autodata = pd.read_stata(auto_path)
     y = 'price'
     x = ['mpg', 'length']
     cls.result = reg(autodata, y, x, addcons=True, save_mem=True)
示例#4
0
 def setup_class(cls):
     """Stata reg output from `sysuse auto; reg price mpg`"""
     cls.init(cls)
     test_path = path.split(path.relpath(__file__))[0]
     auto_path = path.join(test_path, 'data', 'auto.dta')
     autodata = pd.read_stata(auto_path)
     y = 'price'
     x = ['mpg', 'length']
     cls.result = reg(autodata, y, x, cluster='gear_ratio', addcons=True)
     cls.expected = ols_cluster
 def setup_class(cls):
     """Stata reg output from `sysuse auto; reg price mpg`"""
     cls.init(cls)
     test_path = path.split(path.relpath(__file__))[0]
     auto_path = path.join(test_path, 'data', 'auto.dta')
     autodata = pd.read_stata(auto_path)
     y = 'price'
     x = ['mpg', 'length']
     cls.result = reg(autodata, y, x, cluster='gear_ratio', addcons=True)
     cls.expected = ols_cluster
示例#6
0
 def setup_class(cls):
     """Stata reg output from `sysuse auto; reg price mpg`"""
     cls.init(cls)
     test_path = path.split(path.relpath(__file__))[0]
     auto_path = path.join(test_path, 'data', 'auto.dta')
     autodata = pd.read_stata(auto_path)
     y = 'price'
     x = ['mpg', 'length']
     fe_name = 'gear_ratio'
     cls.result = reg(autodata, y, x, fe_name=fe_name, vce_type='hc1')
     cls.expected = areg_robust
示例#7
0
 def setup_class(cls):
     """Stata reg output from `sysuse auto; reg price mpg`"""
     cls.init(cls)
     test_path = path.split(path.relpath(__file__))[0]
     auto_path = path.join(test_path, 'data', 'auto.dta')
     autodata = pd.read_stata(auto_path)
     y = 'price'
     x = ['mpg', 'length']
     fe_name = 'gear_ratio'
     cls.result = reg(autodata, y, x, fe_name=fe_name, vce_type='hc1')
     cls.expected = areg_robust
示例#8
0
 def setup_class(cls):
     """Stata reg output from `sysuse auto; reg price mpg`"""
     cls.init(cls)
     cls.precision['vce'] = 6
     test_path = path.split(path.relpath(__file__))[0]
     auto_path = path.join(test_path, 'data', 'auto.dta')
     autodata = pd.read_stata(auto_path)
     y = ['price']
     x = ['mpg', 'length']
     cls.result = reg(autodata, y, x, addcons=True)
     cls.expected = ols_std
 def setup_class(cls):
     """Stata reg output from `sysuse auto; reg price mpg`"""
     cls.init(cls)
     cls.precision['vce'] = 6
     test_path = path.split(path.relpath(__file__))[0]
     auto_path = path.join(test_path, 'data', 'auto.dta')
     autodata = pd.read_stata(auto_path)
     y = ['price']
     x = ['mpg', 'length']
     cls.result = reg(autodata, y, x, addcons=True)
     cls.expected = ols_std