Get startedGet started for free

Generating ARMA data

In this exercise you will generate 100 days worth of AR/MA/ARMA data. Remember that in the real world applications, this data could be changes in Google stock prices, the energy requirements of New York City, or the number of cases of flu.

You can use the arma_generate_sample() function available in your workspace to generate time series using different AR and MA coefficients.

Remember for any model ARMA(p,q):

  • The list ar_coefs has the form [1, -a_1, -a_2, ..., -a_p].
  • The list ma_coefs has the form [1, m_1, m_2, ..., m_q],

where a_i are the lag-i AR coefficients and m_j are the lag-j MA coefficients.

This exercise is part of the course

ARIMA Models in Python

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Import data generation function and set random seed
from statsmodels.tsa.arima_process import arma_generate_sample
np.random.seed(1)

# Set coefficients
ar_coefs = [____]
ma_coefs = [____]

# Generate data
y = arma_generate_sample(____, ____, nsample=____, scale=0.5)

plt.plot(y)
plt.ylabel(r'$y_t$')
plt.xlabel(r'$t$')
plt.show()
Edit and Run Code