本文整理汇总了Python中statsmodels.datasets.macrodata.load_pandas函数的典型用法代码示例。如果您正苦于以下问题:Python load_pandas函数的具体用法?Python load_pandas怎么用?Python load_pandas使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了load_pandas函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
d = macrodata.load_pandas().data
# growth rates
d["gs_l_realinv"] = 400 * np.log(d["realinv"]).diff()
d["gs_l_realgdp"] = 400 * np.log(d["realgdp"]).diff()
d["lint"] = d["realint"].shift(1)
d["tbilrate"] = d["tbilrate"].shift(1)
d = d.dropna()
self.d = d
endogg = d["gs_l_realinv"]
exogg = add_constant(d[["gs_l_realgdp", "lint"]])
exogg2 = add_constant(d[["gs_l_realgdp", "tbilrate"]])
exogg3 = add_constant(d[["gs_l_realgdp"]])
res_ols = OLS(endogg, exogg).fit()
res_ols2 = OLS(endogg, exogg2).fit()
res_ols3 = OLS(endogg, exogg3).fit()
self.res = res_ols
self.res2 = res_ols2
self.res3 = res_ols3
self.endog = self.res.model.endog
self.exog = self.res.model.exog
开发者ID:AnaMP,项目名称:statsmodels,代码行数:25,代码来源:test_diagnostic.py
示例2: test_stata_writer_pandas
def test_stata_writer_pandas():
buf = BytesIO()
dta = macrodata.load_pandas().data
dta4 = dta.copy()
for col in ('year','quarter'):
dta[col] = dta[col].astype(np.int64)
dta4[col] = dta4[col].astype(np.int32)
# dta is int64 'i8' given to Stata writer
with pytest.warns(FutureWarning):
writer = StataWriter(buf, dta)
with warnings.catch_warnings(record=True) as w:
writer.write_file()
assert len(w) == 0
buf.seek(0)
with pytest.warns(FutureWarning):
dta2 = genfromdta(buf)
dta5 = DataFrame.from_records(dta2)
# dta2 is int32 'i4' returned from Stata reader
if dta5.dtypes[1] is np.dtype('int64'):
ptesting.assert_frame_equal(dta.reset_index(), dta5)
else:
# don't check index because it has different size, int32 versus int64
ptesting.assert_frame_equal(dta4, dta5[dta5.columns[1:]])
开发者ID:bashtage,项目名称:statsmodels,代码行数:27,代码来源:test_foreign.py
示例3: setup_class
def setup_class(cls):
d = macrodata.load_pandas().data
#growth rates
d['gs_l_realinv'] = 400 * np.log(d['realinv']).diff()
d['gs_l_realgdp'] = 400 * np.log(d['realgdp']).diff()
d['lint'] = d['realint'].shift(1)
d['tbilrate'] = d['tbilrate'].shift(1)
d = d.dropna()
cls.d = d
endogg = d['gs_l_realinv']
exogg = add_constant(d[['gs_l_realgdp', 'lint']])
exogg2 = add_constant(d[['gs_l_realgdp', 'tbilrate']])
exogg3 = add_constant(d[['gs_l_realgdp']])
res_ols = OLS(endogg, exogg).fit()
res_ols2 = OLS(endogg, exogg2).fit()
res_ols3 = OLS(endogg, exogg3).fit()
cls.res = res_ols
cls.res2 = res_ols2
cls.res3 = res_ols3
cls.endog = cls.res.model.endog
cls.exog = cls.res.model.exog
开发者ID:bashtage,项目名称:statsmodels,代码行数:25,代码来源:test_diagnostic.py
示例4: setup_class
def setup_class(cls):
d2 = macrodata.load_pandas().data
g_gdp = 400*np.diff(np.log(d2['realgdp'].values))
g_inv = 400*np.diff(np.log(d2['realinv'].values))
exogg = add_constant(np.c_[g_gdp, d2['realint'][:-1].values], prepend=False)
cls.res1 = res_ols = OLS(g_inv, exogg).fit()
开发者ID:bashtage,项目名称:statsmodels,代码行数:7,代码来源:test_robustcov.py
示例5: test_genfromdta_pandas
def test_genfromdta_pandas():
from pandas.util.testing import assert_frame_equal
dta = macrodata.load_pandas().data
curdir = os.path.dirname(os.path.abspath(__file__))
res1 = sm.iolib.genfromdta(curdir+'/../../datasets/macrodata/macrodata.dta',
pandas=True)
res1 = res1.astype(float)
assert_frame_equal(res1, dta)
开发者ID:Code-fish,项目名称:statsmodels,代码行数:8,代码来源:test_foreign.py
示例6: t_est_webuse_pandas
def t_est_webuse_pandas():
# test copied and adjusted from iolib/tests/test_foreign
from pandas.util.testing import assert_frame_equal
from statsmodels.datasets import macrodata
dta = macrodata.load_pandas().data
base_gh = "http://github.com/statsmodels/statsmodels/raw/master/statsmodels/datasets/macrodata/"
res1 = webuse('macrodata', baseurl=base_gh)
res1 = res1.astype(float)
assert_frame_equal(res1, dta)
开发者ID:0ceangypsy,项目名称:statsmodels,代码行数:9,代码来源:test_utils.py
示例7: test_hpfilter_pandas
def test_hpfilter_pandas():
dta = macrodata.load_pandas().data
index = Index(dates_from_range('1959Q1', '2009Q3'))
dta.index = index
cycle, trend = hpfilter(dta["realgdp"])
ndcycle, ndtrend = hpfilter(dta['realgdp'].values)
assert_equal(cycle.values, ndcycle)
assert_equal(cycle.index[0], datetime(1959, 3, 31))
assert_equal(cycle.index[-1], datetime(2009, 9, 30))
assert_equal(cycle.name, "realgdp")
开发者ID:Bonfils-ebu,项目名称:statsmodels,代码行数:10,代码来源:test_filters.py
示例8: test_hpfilter_pandas
def test_hpfilter_pandas():
dta = macrodata.load_pandas().data
index = DatetimeIndex(start='1959-01-01', end='2009-10-01', freq='Q')
dta.index = index
cycle, trend = hpfilter(dta["realgdp"])
ndcycle, ndtrend = hpfilter(dta['realgdp'].values)
assert_equal(cycle.values, ndcycle)
assert_equal(cycle.index[0], datetime(1959, 3, 31))
assert_equal(cycle.index[-1], datetime(2009, 9, 30))
assert_equal(cycle.name, "realgdp")
开发者ID:ChadFulton,项目名称:statsmodels,代码行数:10,代码来源:test_filters.py
示例9: test_genfromdta_pandas
def test_genfromdta_pandas():
from pandas.util.testing import assert_frame_equal
dta = macrodata.load_pandas().data
curdir = os.path.dirname(os.path.abspath(__file__))
with pytest.warns(FutureWarning):
res1 = genfromdta(curdir+'/../../datasets/macrodata/macrodata.dta',
pandas=True)
res1 = res1.astype(float)
assert_frame_equal(res1, dta.astype(float))
开发者ID:bashtage,项目名称:statsmodels,代码行数:11,代码来源:test_foreign.py
示例10: setup_class
def setup_class(cls):
d2 = macrodata.load_pandas().data
g_gdp = 400*np.diff(np.log(d2['realgdp'].values))
g_inv = 400*np.diff(np.log(d2['realinv'].values))
exogg = add_constant(np.c_[g_gdp, d2['realint'][:-1].values], prepend=False)
mod1 = GLSAR(g_inv, exogg, 1)
cls.res = mod1.iterative_fit(5)
from .results.macro_gr_corc_stata import results
cls.results = results
开发者ID:ChadFulton,项目名称:statsmodels,代码行数:11,代码来源:test_glsar_stata.py
示例11: test_webuse_pandas
def test_webuse_pandas():
# test copied and adjusted from iolib/tests/test_foreign
from pandas.util.testing import assert_frame_equal
from statsmodels.datasets import macrodata
dta = macrodata.load_pandas().data
base_gh = "http://github.com/statsmodels/statsmodels/raw/master/statsmodels/datasets/macrodata/"
internet_available = check_internet(base_gh)
if not internet_available:
raise SkipTest('Unable to retrieve file - skipping test')
res1 = webuse('macrodata', baseurl=base_gh)
res1 = res1.astype(float)
assert_frame_equal(res1, dta)
开发者ID:dieterv77,项目名称:statsmodels,代码行数:12,代码来源:test_utils.py
示例12: test_grangercausality
def test_grangercausality(self):
# some example data
mdata = macrodata.load_pandas().data
mdata = mdata[['realgdp', 'realcons']].values
data = mdata.astype(float)
data = np.diff(np.log(data), axis=0)
#R: lmtest:grangertest
r_result = [0.243097, 0.7844328, 195, 2] # f_test
gr = grangercausalitytests(data[:, 1::-1], 2, verbose=False)
assert_almost_equal(r_result, gr[2][0]['ssr_ftest'], decimal=7)
assert_almost_equal(gr[2][0]['params_ftest'], gr[2][0]['ssr_ftest'], decimal=7)
开发者ID:haribharadwaj,项目名称:statsmodels,代码行数:12,代码来源:test_stattools.py
示例13: test_webuse_pandas
def test_webuse_pandas():
# test copied and adjusted from iolib/tests/test_foreign
from pandas.util.testing import assert_frame_equal
from statsmodels.datasets import macrodata
dta = macrodata.load_pandas().data
base_gh = "https://github.com/statsmodels/statsmodels/raw/master/" \
"statsmodels/datasets/macrodata/"
internet_available = check_internet(base_gh)
if not internet_available:
pytest.skip('Unable to retrieve file - skipping test')
try:
res1 = webuse('macrodata', baseurl=base_gh)
except (HTTPError, URLError, SSLError, timeout):
pytest.skip('Failed with HTTP Error, these are random')
res1 = res1.astype(float)
assert_frame_equal(res1, dta.astype(float))
开发者ID:bashtage,项目名称:statsmodels,代码行数:16,代码来源:test_utils.py
示例14: setup_class
def setup_class(cls):
import pandas as pd
from statsmodels.datasets import macrodata, co2
dta = macrodata.load_pandas().data
index = pd.PeriodIndex(start='1959Q1', end='2009Q3', freq='Q')
dta.index = index
cls.quarterly_data = dta.dropna()
dta = co2.load_pandas().data
dta['co2'] = dta.co2.interpolate()
cls.monthly_data = dta.resample('M')
# change in pandas 0.18 resample is deferred object
if not isinstance(cls.monthly_data, (pd.DataFrame, pd.Series)):
cls.monthly_data = cls.monthly_data.mean()
cls.monthly_start_data = dta.resample('MS')
if not isinstance(cls.monthly_start_data, (pd.DataFrame, pd.Series)):
cls.monthly_start_data = cls.monthly_start_data.mean()
开发者ID:cong1989,项目名称:statsmodels,代码行数:18,代码来源:test_x13.py
示例15: setupClass
def setupClass(cls):
if not _have_x13:
raise SkipTest("X13/X12 not available")
import pandas as pd
from statsmodels.datasets import macrodata, co2
dta = macrodata.load_pandas().data
dates = dates_from_range("1959Q1", "2009Q3")
index = pd.DatetimeIndex(dates)
dta.index = index
cls.quarterly_data = dta.dropna()
dta = co2.load_pandas().data
dta["co2"] = dta.co2.interpolate()
cls.monthly_data = dta.resample("M")
cls.monthly_start_data = dta.resample("MS")
开发者ID:Clever-Boy,项目名称:statsmodels,代码行数:18,代码来源:test_x13.py
示例16: test_cfitz_pandas
def test_cfitz_pandas():
# 1d
dta = macrodata.load_pandas().data
index = DatetimeIndex(start='1959-01-01', end='2009-10-01', freq='Q')
dta.index = index
cycle, trend = cffilter(dta["infl"])
ndcycle, ndtrend = cffilter(dta['infl'].values)
assert_allclose(cycle.values, ndcycle, rtol=1e-14)
assert_equal(cycle.index[0], datetime(1959, 3, 31))
assert_equal(cycle.index[-1], datetime(2009, 9, 30))
assert_equal(cycle.name, "infl")
#2d
cycle, trend = cffilter(dta[["infl","unemp"]])
ndcycle, ndtrend = cffilter(dta[['infl', 'unemp']].values)
assert_allclose(cycle.values, ndcycle, rtol=1e-14)
assert_equal(cycle.index[0], datetime(1959, 3, 31))
assert_equal(cycle.index[-1], datetime(2009, 9, 30))
assert_equal(cycle.columns.values, ["infl", "unemp"])
开发者ID:ChadFulton,项目名称:statsmodels,代码行数:19,代码来源:test_filters.py
示例17: test_bking_pandas
def test_bking_pandas():
# 1d
dta = macrodata.load_pandas().data
index = Index(dates_from_range('1959Q1', '2009Q3'))
dta.index = index
filtered = bkfilter(dta["infl"])
nd_filtered = bkfilter(dta['infl'].values)
assert_equal(filtered.values, nd_filtered)
assert_equal(filtered.index[0], datetime(1962, 3, 31))
assert_equal(filtered.index[-1], datetime(2006, 9, 30))
assert_equal(filtered.name, "infl")
#2d
filtered = bkfilter(dta[["infl","unemp"]])
nd_filtered = bkfilter(dta[['infl', 'unemp']].values)
assert_equal(filtered.values, nd_filtered)
assert_equal(filtered.index[0], datetime(1962, 3, 31))
assert_equal(filtered.index[-1], datetime(2006, 9, 30))
assert_equal(filtered.columns.values, ["infl", "unemp"])
开发者ID:Bonfils-ebu,项目名称:statsmodels,代码行数:19,代码来源:test_filters.py
示例18: test_cfitz_pandas
def test_cfitz_pandas():
# 1d
dta = macrodata.load_pandas().data
index = Index(dates_from_range('1959Q1', '2009Q3'))
dta.index = index
cycle, trend = cffilter(dta["infl"])
ndcycle, ndtrend = cffilter(dta['infl'].values)
assert_allclose(cycle.values, ndcycle, rtol=1e-14)
assert_equal(cycle.index[0], datetime(1959, 3, 31))
assert_equal(cycle.index[-1], datetime(2009, 9, 30))
assert_equal(cycle.name, "infl")
#2d
cycle, trend = cffilter(dta[["infl","unemp"]])
ndcycle, ndtrend = cffilter(dta[['infl', 'unemp']].values)
assert_allclose(cycle.values, ndcycle, rtol=1e-14)
assert_equal(cycle.index[0], datetime(1959, 3, 31))
assert_equal(cycle.index[-1], datetime(2009, 9, 30))
assert_equal(cycle.columns.values, ["infl", "unemp"])
开发者ID:Bonfils-ebu,项目名称:statsmodels,代码行数:19,代码来源:test_filters.py
示例19: test_bking_pandas
def test_bking_pandas():
# 1d
dta = macrodata.load_pandas().data
index = DatetimeIndex(start='1959-01-01', end='2009-10-01', freq='Q')
dta.index = index
filtered = bkfilter(dta["infl"])
nd_filtered = bkfilter(dta['infl'].values)
assert_equal(filtered.values, nd_filtered)
assert_equal(filtered.index[0], datetime(1962, 3, 31))
assert_equal(filtered.index[-1], datetime(2006, 9, 30))
assert_equal(filtered.name, "infl")
#2d
filtered = bkfilter(dta[["infl","unemp"]])
nd_filtered = bkfilter(dta[['infl', 'unemp']].values)
assert_equal(filtered.values, nd_filtered)
assert_equal(filtered.index[0], datetime(1962, 3, 31))
assert_equal(filtered.index[-1], datetime(2006, 9, 30))
assert_equal(filtered.columns.values, ["infl", "unemp"])
开发者ID:ChadFulton,项目名称:statsmodels,代码行数:19,代码来源:test_filters.py
示例20: test_alignment
def test_alignment():
#Fix Issue #206
from statsmodels.regression.linear_model import OLS
from statsmodels.datasets.macrodata import load_pandas
d = load_pandas().data
#growth rates
gs_l_realinv = 400 * np.log(d['realinv']).diff().dropna()
gs_l_realgdp = 400 * np.log(d['realgdp']).diff().dropna()
lint = d['realint'][:-1] # incorrect indexing for test purposes
endog = gs_l_realinv
# re-index because they won't conform to lint
realgdp = gs_l_realgdp.reindex(lint.index, method='bfill')
data = dict(const=np.ones_like(lint), lrealgdp=realgdp, lint=lint)
exog = pandas.DataFrame(data)
# which index do we get??
np.testing.assert_raises(ValueError, OLS, *(endog, exog))
开发者ID:philippmuller,项目名称:statsmodels,代码行数:20,代码来源:test_data.py
注:本文中的statsmodels.datasets.macrodata.load_pandas函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论