• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python longley.load函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中statsmodels.datasets.longley.load函数的典型用法代码示例。如果您正苦于以下问题:Python load函数的具体用法?Python load怎么用?Python load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了load函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: setupClass

 def setupClass(cls):
     R = np.zeros(7)
     R[4:6] = [1,-1]
     data = longley.load()
     data.exog = add_constant(data.exog, prepend=False)
     res1 = OLS(data.endog, data.exog).fit()
     cls.Ttest1 = res1.t_test(R)
开发者ID:NanoResearch,项目名称:statsmodels,代码行数:7,代码来源:test_regression.py


示例2: setupClass

 def setupClass(cls):
     data = longley.load()
     data.exog = add_constant(data.exog, prepend=False)
     ols_res = OLS(data.endog, data.exog).fit()
     gls_res = GLS(data.endog, data.exog).fit()
     cls.res1 = gls_res
     cls.res2 = ols_res
开发者ID:Code-fish,项目名称:statsmodels,代码行数:7,代码来源:test_regression.py


示例3: test_missing

 def test_missing(self):
     data = longley.load()
     data.exog = add_constant(data.exog, prepend=False)
     data.endog[[3, 7, 14]] = np.nan
     mod = OLS(data.endog, data.exog, missing='drop')
     assert_equal(mod.endog.shape[0], 13)
     assert_equal(mod.exog.shape[0], 13)
开发者ID:NanoResearch,项目名称:statsmodels,代码行数:7,代码来源:test_regression.py


示例4: __init__

 def __init__(self):
     from statsmodels.datasets.cpunish import load
     self.data = load()
     self.endog = self.data.endog
     self.exog = self.data.exog
     np.random.seed(1234)
     self.weight = np.random.randint(5, 100, len(self.endog))
     self.endog_big = np.repeat(self.endog, self.weight)
     self.exog_big = np.repeat(self.exog, self.weight, axis=0)
开发者ID:0ceangypsy,项目名称:statsmodels,代码行数:9,代码来源:test_glm.py


示例5: setup_class

 def setup_class(cls):
     data = longley.load(as_pandas=False)
     data.exog = add_constant(data.exog, prepend=False)
     ols_res = OLS(data.endog, data.exog).fit()
     gls_res = GLS(data.endog, data.exog).fit()
     gls_res_scalar = GLS(data.endog, data.exog, sigma=1)
     cls.endog = data.endog
     cls.exog = data.exog
     cls.res1 = gls_res
     cls.res2 = ols_res
     cls.res3 = gls_res_scalar
开发者ID:statsmodels,项目名称:statsmodels,代码行数:11,代码来源:test_regression.py


示例6: setupClass

 def setupClass(cls):
     from results.results_glm import Cpunish
     from statsmodels.datasets.cpunish import load
     data = load()
     data.exog[:,3] = np.log(data.exog[:,3])
     data.exog = add_constant(data.exog)
     exposure = [100] * len(data.endog)
     cls.res1 = GLM(data.endog, data.exog, family=sm.families.Poisson(),
                 exposure=exposure).fit()
     cls.res1.params[-1] += np.log(100) # add exposure back in to param
                                         # to make the results the same
     cls.res2 = Cpunish()
开发者ID:CRP,项目名称:statsmodels,代码行数:12,代码来源:test_glm.py


示例7: setupClass

    def setupClass(cls):
        from results.results_regression import LongleyGls

        data = longley.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()
        cls.res1 = GLS_results
        cls.res2 = LongleyGls()
开发者ID:Tskatom,项目名称:Embers_VT,代码行数:14,代码来源:test_regression.py


示例8: __init__

    def __init__(self):
        '''
        Tests Poisson family with canonical log link.

        Test results were obtained by R.
        '''
        from results.results_glm import Cpunish
        from 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()
开发者ID:CRP,项目名称:statsmodels,代码行数:14,代码来源:test_glm.py


示例9: setupClass

    def setupClass(cls):
#        if skipR:
#            raise SkipTest, "Rpy not installed"
#        try:
#            r.library('car')
#        except RPyRException:
#            raise SkipTest, "car library not installed for R"
        R = np.zeros(7)
        R[4:6] = [1,-1]
#        self.R = R
        data = longley.load()
        data.exog = add_constant(data.exog)
        res1 = OLS(data.endog, data.exog).fit()
        cls.Ttest1 = res1.t_test(R)
开发者ID:CRP,项目名称:statsmodels,代码行数:14,代码来源:test_regression.py


示例10: __init__

    def __init__(self):
        '''
        Tests Poisson family with canonical log link.

        Test results were obtained by R.
        '''
        from .results.results_glm import Cpunish
        from 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, prepend=False)
        self.res1 = GLM(self.data.endog, self.data.exog,
                    family=sm.families.Poisson()).fit()
        self.res2 = Cpunish()
        # compare with discrete, start close to save time
        modd = discrete.Poisson(self.data.endog, self.data.exog)
        self.resd = modd.fit(start_params=self.res1.params * 0.9, disp=False)
开发者ID:JerWatson,项目名称:statsmodels,代码行数:17,代码来源:test_glm.py


示例11: test_wtd_patsy_missing

def test_wtd_patsy_missing():
    from statsmodels.datasets.cpunish import load
    import pandas as pd
    data = load()
    data.exog[0, 0] = np.nan
    data.endog[[2, 4, 6, 8]] = np.nan
    data.pandas = pd.DataFrame(data.exog, columns=data.exog_name)
    data.pandas['EXECUTIONS'] = data.endog
    weights = np.arange(1, len(data.endog)+1)
    formula = """EXECUTIONS ~ INCOME + PERPOVERTY + PERBLACK + VC100k96 +
                 SOUTH + DEGREE"""
    mod_misisng = GLM.from_formula(formula, data=data.pandas, freq_weights=weights)
    assert_equal(mod_misisng.freq_weights.shape[0],
                 mod_misisng.endog.shape[0])
    assert_equal(mod_misisng.freq_weights.shape[0],
                 mod_misisng.exog.shape[0])
    assert_equal(mod_misisng.freq_weights.shape[0], 12)
    keep_weights = np.array([ 2,  4,  6,  8, 10, 11, 12, 13, 14, 15, 16, 17])
    assert_equal(mod_misisng.freq_weights, keep_weights)
开发者ID:0ceangypsy,项目名称:statsmodels,代码行数:19,代码来源:test_glm.py


示例12: load

"""Example: statsmodels.OLS
"""

from statsmodels.datasets.longley import load
import statsmodels.api as sm
from statsmodels.iolib.table import SimpleTable, default_txt_fmt
import numpy as np

data = load()

data_orig = (data.endog.copy(), data.exog.copy())

# Note: In this example using zscored/standardized variables has no effect on
#   regression estimates. Are there no numerical problems?

rescale = 0
# 0: no rescaling, 1:demean, 2:standardize, 3:standardize and transform back
rescale_ratio = data.endog.std() / data.exog.std(0)
if rescale > 0:
    # rescaling
    data.endog -= data.endog.mean()
    data.exog -= data.exog.mean(0)
if rescale > 1:
    data.endog /= data.endog.std()
    data.exog /= data.exog.std(0)

# skip because mean has been removed, but dimension is hardcoded in table
data.exog = sm.tools.add_constant(data.exog, prepend=False)


ols_model = sm.OLS(data.endog, data.exog)
开发者ID:bashtage,项目名称:statsmodels,代码行数:31,代码来源:ols_table.py


示例13: setupClass

 def setupClass(cls):
     cls.data = load()
开发者ID:Tskatom,项目名称:Embers_VT,代码行数:2,代码来源:test_formula.py



注:本文中的statsmodels.datasets.longley.load函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python longley.load_pandas函数代码示例发布时间:2022-05-27
下一篇:
Python ccard.load函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap