Advanced Data Analytics Using Python_ With Machine Learning, Deep Learning and NLP Examples ( 2023)
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Chapter 6
Time Series
Mixed ARMA Models
Mixed ARMA models are a combination of MA and AR processes. A mixed
autoregressive/moving average process containing p AR terms and q
MA terms is said to be an ARMA process of order (p,q). It is given by the
following:
X = a X + + a X + Z + b Z + +
b Z
t 1 t-1 p t-p t 1 t-1
q t-q
The following example code was taken from the stat model site to
realize time-series data as an ARMA model:
r1,q1,p1 = sm.tsa.acf(resid.values.squeeze(), qstat=True)
data1 = np.c_[range(1,40), r1[1:], q1, p1]
table1 = pandas.DataFrame(data1, columns=['lag', "AC", "Q",
"Prob(>Q)"])
predict_sunspots1 = arma_mod40.predict('startyear', 'endyear',
dynamic=True)
Here is the simulated ARMA (4,1) model identification code:
from statsmodels. import tsa.arima_processimportarma_generate_
sample, ArmaProcess
np.random.seed(1234)
data = np.array([1, .85, -.43, -.63, .8])
parameter = np.array([1, .41]
model = ArmaProcess(data, parameter)
model.isinvertible()
True
Model.isstationary()
True
137