当前位置: 首页>>代码示例>>Python>>正文


Python ArmaProcess.from_coeffs方法代码示例

本文整理汇总了Python中statsmodels.tsa.arima_process.ArmaProcess.from_coeffs方法的典型用法代码示例。如果您正苦于以下问题:Python ArmaProcess.from_coeffs方法的具体用法?Python ArmaProcess.from_coeffs怎么用?Python ArmaProcess.from_coeffs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在statsmodels.tsa.arima_process.ArmaProcess的用法示例。


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

示例1: test_generate_sample

# 需要导入模块: from statsmodels.tsa.arima_process import ArmaProcess [as 别名]
# 或者: from statsmodels.tsa.arima_process.ArmaProcess import from_coeffs [as 别名]
    def test_generate_sample(self):
        process = ArmaProcess.from_coeffs([0.9])
        np.random.seed(12345)
        sample = process.generate_sample()
        np.random.seed(12345)
        expected = np.random.randn(100)
        for i in range(1, 100):
            expected[i] = 0.9 * expected[i - 1] + expected[i]
        assert_almost_equal(sample, expected)

        process = ArmaProcess.from_coeffs([1.6, -0.9])
        np.random.seed(12345)
        sample = process.generate_sample()
        np.random.seed(12345)
        expected = np.random.randn(100)
        expected[1] = 1.6 * expected[0] + expected[1]
        for i in range(2, 100):
            expected[i] = 1.6 * expected[i - 1] - 0.9 * expected[i - 2] + expected[i]
        assert_almost_equal(sample, expected)

        process = ArmaProcess.from_coeffs([1.6, -0.9])
        np.random.seed(12345)
        sample = process.generate_sample(burnin=100)
        np.random.seed(12345)
        expected = np.random.randn(200)
        expected[1] = 1.6 * expected[0] + expected[1]
        for i in range(2, 200):
            expected[i] = 1.6 * expected[i - 1] - 0.9 * expected[i - 2] + expected[i]
        assert_almost_equal(sample, expected[100:])


        np.random.seed(12345)
        sample = process.generate_sample(nsample=(100,5))
        assert_equal(sample.shape, (100,5))
开发者ID:cong1989,项目名称:statsmodels,代码行数:36,代码来源:test_arima_process.py

示例2: test_isstationary

# 需要导入模块: from statsmodels.tsa.arima_process import ArmaProcess [as 别名]
# 或者: from statsmodels.tsa.arima_process.ArmaProcess import from_coeffs [as 别名]
    def test_isstationary(self):
        process1 = ArmaProcess.from_coeffs([1.1])
        assert_equal(process1.isstationary, False)

        process1 = ArmaProcess.from_coeffs([1.8, -0.9])
        assert_equal(process1.isstationary, True)

        process1 = ArmaProcess.from_coeffs([1.5, -0.5])
        print(np.abs(process1.arroots))
        assert_equal(process1.isstationary, False)
开发者ID:cong1989,项目名称:statsmodels,代码行数:12,代码来源:test_arima_process.py

示例3: test_invertroots

# 需要导入模块: from statsmodels.tsa.arima_process import ArmaProcess [as 别名]
# 或者: from statsmodels.tsa.arima_process.ArmaProcess import from_coeffs [as 别名]
    def test_invertroots(self):
        process1 = ArmaProcess.from_coeffs([], [2.5])
        process2 = process1.invertroots(True)
        assert_almost_equal(process2.ma, np.array([1.0, 0.4]))

        process1 = ArmaProcess.from_coeffs([], [0.4])
        process2 = process1.invertroots(True)
        assert_almost_equal(process2.ma, np.array([1.0, 0.4]))

        process1 = ArmaProcess.from_coeffs([], [2.5])
        roots, invertable = process1.invertroots(False)
        assert_equal(invertable, False)
        assert_almost_equal(roots, np.array([1, 0.4]))
开发者ID:cong1989,项目名称:statsmodels,代码行数:15,代码来源:test_arima_process.py

示例4: test_acf

# 需要导入模块: from statsmodels.tsa.arima_process import ArmaProcess [as 别名]
# 或者: from statsmodels.tsa.arima_process.ArmaProcess import from_coeffs [as 别名]
    def test_acf(self):
        process1 = ArmaProcess.from_coeffs([.9])
        acf = process1.acf(10)
        expected = np.array(0.9) ** np.arange(10.0)
        assert_array_almost_equal(acf, expected)

        acf = process1.acf()
        assert_(acf.shape[0] == process1.nobs)
开发者ID:cong1989,项目名称:statsmodels,代码行数:10,代码来源:test_arima_process.py

示例5: test_pacf

# 需要导入模块: from statsmodels.tsa.arima_process import ArmaProcess [as 别名]
# 或者: from statsmodels.tsa.arima_process.ArmaProcess import from_coeffs [as 别名]
    def test_pacf(self):
        process1 = ArmaProcess.from_coeffs([.9])
        pacf = process1.pacf(10)
        expected = np.array([1, 0.9] + [0] * 8)
        assert_array_almost_equal(pacf, expected)

        pacf = process1.pacf()
        assert_(pacf.shape[0] == process1.nobs)
开发者ID:cong1989,项目名称:statsmodels,代码行数:10,代码来源:test_arima_process.py

示例6: test_str_repr

# 需要导入模块: from statsmodels.tsa.arima_process import ArmaProcess [as 别名]
# 或者: from statsmodels.tsa.arima_process.ArmaProcess import from_coeffs [as 别名]
    def test_str_repr(self):
        process1 = ArmaProcess.from_coeffs([.9], [.2])
        out = process1.__str__()
        print(out)
        assert_(out.find('AR: [1.0, -0.9]') != -1)
        assert_(out.find('MA: [1.0, 0.2]') != -1)

        out = process1.__repr__()
        assert_(out.find('nobs=100') != -1)
        assert_(out.find('at ' + str(hex(id(process1)))) != -1)
开发者ID:cong1989,项目名称:statsmodels,代码行数:12,代码来源:test_arima_process.py

示例7: test_process_multiplication

# 需要导入模块: from statsmodels.tsa.arima_process import ArmaProcess [as 别名]
# 或者: from statsmodels.tsa.arima_process.ArmaProcess import from_coeffs [as 别名]
    def test_process_multiplication(self):
        process1 = ArmaProcess.from_coeffs([.9])
        process2 = ArmaProcess.from_coeffs([.7])
        process3 = process1 * process2
        assert_equal(process3.arcoefs, np.array([1.6, -0.7 * 0.9]))
        assert_equal(process3.macoefs, np.array([]))

        process1 = ArmaProcess.from_coeffs([.9], [.2])
        process2 = ArmaProcess.from_coeffs([.7])
        process3 = process1 * process2

        assert_equal(process3.arcoefs, np.array([1.6, -0.7 * 0.9]))
        assert_equal(process3.macoefs, np.array([0.2]))

        process1 = ArmaProcess.from_coeffs([.9], [.2])
        process2 = process1 * (np.array([1.0, -0.7]), np.array([1.0]))
        assert_equal(process2.arcoefs, np.array([1.6, -0.7 * 0.9]))

        assert_raises(TypeError, process1.__mul__, [3])
开发者ID:cong1989,项目名称:statsmodels,代码行数:21,代码来源:test_arima_process.py

示例8: test_from_model

# 需要导入模块: from statsmodels.tsa.arima_process import ArmaProcess [as 别名]
# 或者: from statsmodels.tsa.arima_process.ArmaProcess import from_coeffs [as 别名]
    def test_from_model(self):
        process = ArmaProcess([1, -.8], [1, .3], 1000)
        t = 1000
        rs = np.random.RandomState(12345)
        y = process.generate_sample(t, burnin=100, distrvs=rs.standard_normal)
        res = ARMA(y, (1, 1)).fit(disp=False)
        process_model = ArmaProcess.from_estimation(res)
        process_coef = ArmaProcess.from_coeffs(res.arparams, res.maparams, t)

        assert_equal(process_model.arcoefs, process_coef.arcoefs)
        assert_equal(process_model.macoefs, process_coef.macoefs)
        assert_equal(process_model.nobs, process_coef.nobs)
        assert_equal(process_model.isinvertible, process_coef.isinvertible)
        assert_equal(process_model.isstationary, process_coef.isstationary)
开发者ID:cong1989,项目名称:statsmodels,代码行数:16,代码来源:test_arima_process.py

示例9: test_from_coeff

# 需要导入模块: from statsmodels.tsa.arima_process import ArmaProcess [as 别名]
# 或者: from statsmodels.tsa.arima_process.ArmaProcess import from_coeffs [as 别名]
    def test_from_coeff(self):
        ar = [1.8, -0.9]
        ma = [0.3]
        process = ArmaProcess.from_coeffs(np.array(ar), np.array(ma))

        ar.insert(0, -1)
        ma.insert(0, 1)
        ar_p = -1 * np.array(ar)
        ma_p = ma
        process_direct = ArmaProcess(ar_p, ma_p)

        assert_equal(process.arcoefs, process_direct.arcoefs)
        assert_equal(process.macoefs, process_direct.macoefs)
        assert_equal(process.nobs, process_direct.nobs)
        assert_equal(process.maroots, process_direct.maroots)
        assert_equal(process.arroots, process_direct.arroots)
        assert_equal(process.isinvertible, process_direct.isinvertible)
        assert_equal(process.isstationary, process_direct.isstationary)
开发者ID:cong1989,项目名称:statsmodels,代码行数:20,代码来源:test_arima_process.py

示例10: test_impulse_response

# 需要导入模块: from statsmodels.tsa.arima_process import ArmaProcess [as 别名]
# 或者: from statsmodels.tsa.arima_process.ArmaProcess import from_coeffs [as 别名]
 def test_impulse_response(self):
     process = ArmaProcess.from_coeffs([0.9])
     ir = process.impulse_response(10)
     assert_almost_equal(ir, 0.9 ** np.arange(10))
开发者ID:cong1989,项目名称:statsmodels,代码行数:6,代码来源:test_arima_process.py

示例11: test_arma2ar

# 需要导入模块: from statsmodels.tsa.arima_process import ArmaProcess [as 别名]
# 或者: from statsmodels.tsa.arima_process.ArmaProcess import from_coeffs [as 别名]
 def test_arma2ar(self):
     process1 = ArmaProcess.from_coeffs([], [0.8])
     vals = process1.arma2ar(100)
     assert_almost_equal(vals, (-0.8) ** np.arange(100.0))
开发者ID:cong1989,项目名称:statsmodels,代码行数:6,代码来源:test_arima_process.py

示例12: arma_generate_sample

# 需要导入模块: from statsmodels.tsa.arima_process import ArmaProcess [as 别名]
# 或者: from statsmodels.tsa.arima_process.ArmaProcess import from_coeffs [as 别名]
nobs = 500
ar = [1, -0.6, -0.1]
ma = [1, 0.7]
dist = lambda n: np.random.standard_t(3, size=n)
np.random.seed(8659567)
x = arma_generate_sample(ar, ma, nobs, sigma=1, distrvs=dist,
                         burnin=500)

mod = TArma(x)
order = (2, 1)
res = mod.fit(order=order)
res2 = mod.fit_mle(order=order, start_params=np.r_[res[0], 5, 1], method='nm')

print(res[0])
proc = ArmaProcess.from_coeffs(res[0][:order[0]], res[0][:order[1]])

print(ar, ma)
proc.nobs = nobs
# TODO: bug nobs is None, not needed ?, used in ArmaProcess.__repr__
print(proc.ar, proc.ma)

print(proc.ar_roots(), proc.ma_roots())

from statsmodels.tsa.arma_mle import Arma
modn = Arma(x)
resn = modn.fit_mle(order=order)

moda = ARMA(x, order=order)
resa = moda.fit( trend='nc')
开发者ID:0ceangypsy,项目名称:statsmodels,代码行数:31,代码来源:ex_misc_tarma.py


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