本文整理汇总了Python中statsmodels.tsa.arima_process.ArmaProcess.generate_sample方法的典型用法代码示例。如果您正苦于以下问题:Python ArmaProcess.generate_sample方法的具体用法?Python ArmaProcess.generate_sample怎么用?Python ArmaProcess.generate_sample使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类statsmodels.tsa.arima_process.ArmaProcess
的用法示例。
在下文中一共展示了ArmaProcess.generate_sample方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_from_model
# 需要导入模块: from statsmodels.tsa.arima_process import ArmaProcess [as 别名]
# 或者: from statsmodels.tsa.arima_process.ArmaProcess import generate_sample [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)
示例2: ArmaProcess
# 需要导入模块: from statsmodels.tsa.arima_process import ArmaProcess [as 别名]
# 或者: from statsmodels.tsa.arima_process.ArmaProcess import generate_sample [as 别名]
arma_t.isinvertible()
# <codecell>
arma_t.isstationary()
# <rawcell>
# * What does this mean?
# <codecell>
fig = plt.figure(figsize=(12,8))
ax = fig.add_subplot(111)
ax.plot(arma_t.generate_sample(size=50));
# <codecell>
arparams = np.array([1, .35, -.15, .55, .1])
maparams = np.array([1, .65])
arma_t = ArmaProcess(arparams, maparams)
arma_t.isstationary()
# <codecell>
arma_rvs = arma_t.generate_sample(size=500, burnin=250, scale=2.5)
# <codecell>
fig = plt.figure(figsize=(12,8))
示例3: ArmaProcess
# 需要导入模块: from statsmodels.tsa.arima_process import ArmaProcess [as 别名]
# 或者: from statsmodels.tsa.arima_process.ArmaProcess import generate_sample [as 别名]
axes[3].set_ylabel('Irregular')
fig.tight_layout()
return fig
if __name__ == "__main__":
import numpy as np
from statsmodels.tsa.arima_process import ArmaProcess
np.random.seed(123)
ar = [1, .35, .8]
ma = [1, .8]
arma = ArmaProcess(ar, ma, nobs=100)
assert arma.isstationary()
assert arma.isinvertible()
y = arma.generate_sample()
dates = pd.date_range("1/1/1990", periods=len(y), freq='M')
ts = pd.TimeSeries(y, index=dates)
xpath = "/home/skipper/src/x12arima/x12a"
try:
results = x13_arima_analysis(xpath, ts)
except:
print("Caught exception")
results = x13_arima_analysis(xpath, ts, log=False)
# import pandas as pd
# seas_y = pd.read_csv("usmelec.csv")
# seas_y = pd.TimeSeries(seas_y["usmelec"].values,
示例4: MA
# 需要导入模块: from statsmodels.tsa.arima_process import ArmaProcess [as 别名]
# 或者: from statsmodels.tsa.arima_process.ArmaProcess import generate_sample [as 别名]
,
0.8
,
0.8
2
,
0.8
3
,
…
Simulate 5000 observations of the MA(30) model
Plot the ACF of the simulated series
'''
# import the modules for simulating data and plotting the ACF
from statsmodels.tsa.arima_process import ArmaProcess
from statsmodels.graphics.tsaplots import plot_acf
# Build a list MA parameters
ma = [0.8**i for i in range(30)]
# Simulate the MA(30) model
ar = np.array([1])
AR_object = ArmaProcess(ar, ma)
simulated_data = AR_object.generate_sample(nsample=5000)
# Plot the ACF
plot_acf(simulated_data, lags=30)
plt.show()
示例5: ArmaProcess
# 需要导入模块: from statsmodels.tsa.arima_process import ArmaProcess [as 别名]
# 或者: from statsmodels.tsa.arima_process.ArmaProcess import generate_sample [as 别名]
100XP
Import the class ArmaProcess in the arima_process module.
Plot the simulated AR procesees:
Let ar1 represent an array of the AR parameters [1, −ϕ
−
ϕ
] as explained above. For now, the MA parmater array, ma1, will contain just the lag-zero coefficient of one.
With parameters ar1 and ma1, create an instance of the class ArmaProcess(ar,ma) called AR_object1.
Simulate 1000 data points from the object you just created, AR_object1, using the method .generate_sample(). Plot the simulated data in a subplot.
Repeat for the other AR parameter.
'''
# import the module for simulating data
from statsmodels.tsa.arima_process import ArmaProcess
# Plot 1: AR parameter = +0.9
plt.subplot(2,1,1)
ar1 = np.array([1, -0.9])
ma1 = np.array([1])
AR_object1 = ArmaProcess(ar1, ma1)
simulated_data_1 = AR_object1.generate_sample(nsample=1000)
plt.plot(simulated_data_1)
# Plot 2: AR parameter = -0.9
plt.subplot(2,1,2)
ar2 = np.array([1, 0.9])
ma2 = np.array([1])
AR_object2 = ArmaProcess(ar2, ma2)
simulated_data_2 = AR_object2.generate_sample(nsample=1000)
plt.plot(simulated_data_2)
plt.show()