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 __init__(self): from scikits.statsmodels.datasets.longley import load data = load() data.exog = add_constant(data.exog) ols_res = OLS(data.endog, data.exog).fit() gls_res = GLS(data.endog, data.exog).fit() self.res1 = gls_res self.res2 = ols_res
def __init__(self): from scikits.statsmodels.datasets.longley import load from results.results_regression import Longley data = load() data.exog = add_constant(data.exog) res1 = OLS(data.endog, data.exog).fit() res2 = Longley() res2.wresid = res1.wresid # workaround hack self.res1 = res1 self.res2 = res2
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)
def __init__(self): ''' Tests Poisson family with canonical log link. Test results were obtained by R. ''' from results.results_glm import Cpunish from scikits.statsmodels.datasets.cpunish import load self.data = load() self.data.exog[:,3] = np.log(self.data.exog[:,3]) self.data.exog = add_constant(self.data.exog) self.res1 = GLM(self.data.endog, self.data.exog, family=sm.families.Poisson()).fit() self.res2 = Cpunish()
def __init__(self): from scikits.statsmodels.datasets.longley import load from results.results_regression import LongleyGls data = load() exog = add_constant(np.column_stack(\ (data.exog[:,1],data.exog[:,4]))) tmp_results = OLS(data.endog, exog).fit() rho = np.corrcoef(tmp_results.resid[1:], tmp_results.resid[:-1])[0][1] # by assumption order = toeplitz(np.arange(16)) sigma = rho**order GLS_results = GLS(data.endog, exog, sigma=sigma).fit() self.res1 = GLS_results self.res2 = LongleyGls()
def __init__(self): ''' Test Gaussian family with canonical identity link ''' # Test Precisions self.decimal_resids = DECIMAL_3 self.decimal_params = DECIMAL_2 self.decimal_bic = DECIMAL_0 self.decimal_bse = DECIMAL_3 from scikits.statsmodels.datasets.longley import load self.data = load() self.data.exog = add_constant(self.data.exog) self.res1 = GLM(self.data.endog, self.data.exog, family=sm.families.Gaussian()).fit() from results.results_glm import Longley self.res2 = Longley()
def __init__(self): ''' Tests Gamma family with canonical inverse link (power -1) ''' # Test Precisions self.decimal_aic_R = -1 #TODO: off by about 1, we are right with Stata self.decimal_resids = DECIMAL_2 from scikits.statsmodels.datasets.scotland import load from results.results_glm import Scotvote data = load() data.exog = add_constant(data.exog) res1 = GLM(data.endog, data.exog, \ family=sm.families.Gamma()).fit() self.res1 = res1 # res2 = RModel(data.endog, data.exog, r.glm, family=r.Gamma) res2 = Scotvote() res2.aic_R += 2 # R doesn't count degree of freedom for scale with gamma self.res2 = res2
def __init__(self): ''' Test Binomial family with canonical logit link using star98 dataset. ''' self.decimal_resids = DECIMAL_1 self.decimal_bic = DECIMAL_2 from scikits.statsmodels.datasets.star98 import load from results.results_glm import Star98 data = load() data.exog = add_constant(data.exog) trials = data.endog[:,:2].sum(axis=1) self.res1 = GLM(data.endog, data.exog, \ family=sm.families.Binomial()).fit(data_weights = trials) #NOTE: if you want to replicate with RModel #res2 = RModel(data.endog[:,0]/trials, data.exog, r.glm, # family=r.binomial, weights=trials) self.res2 = Star98()
def __init__(self): ''' Test Negative Binomial family with canonical log link ''' # Test Precision self.decimal_resid = DECIMAL_1 self.decimal_params = DECIMAL_3 self.decimal_resids = -1 # 1 % mismatch at 0 self.decimal_fittedvalues = DECIMAL_1 from scikits.statsmodels.datasets.committee import load self.data = load() self.data.exog[:,2] = np.log(self.data.exog[:,2]) interaction = self.data.exog[:,2]*self.data.exog[:,1] self.data.exog = np.column_stack((self.data.exog,interaction)) self.data.exog = add_constant(self.data.exog) self.res1 = GLM(self.data.endog, self.data.exog, family=sm.families.NegativeBinomial()).fit() from results.results_glm import Committee res2 = Committee() res2.aic_R += 2 # They don't count a degree of freedom for the scale self.res2 = res2